0% found this document useful (0 votes)
30 views3 pages

Materi UAS Kelas/Pewarisan Class Polimorfisme Interface Inner Class Pengenalan GUI

The document contains details about an exam for a GUI class, including 5 questions to be completed in 75 minutes with an open book. It provides code snippets for two of the questions - the first asks to complete a program to display a frame properly, and the second asks to modify code to add an interface for handling button clicks that displays a message.

Uploaded by

Naufal Wael
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views3 pages

Materi UAS Kelas/Pewarisan Class Polimorfisme Interface Inner Class Pengenalan GUI

The document contains details about an exam for a GUI class, including 5 questions to be completed in 75 minutes with an open book. It provides code snippets for two of the questions - the first asks to complete a program to display a frame properly, and the second asks to modify code to add an interface for handling button clicks that displays a message.

Uploaded by

Naufal Wael
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Materi UAS

Kelas/Pewarisan Class

Polimorfisme

Interface

Inner Class

Pengenalan GUI

5 soal , waktu 75 menit, buku terbuka

1. Lengkapilah program berikut agar sesuai tampilan:

import java.awt.*;
import java.awt.event.*;

public class TesFrame3 extends Frame {


public static void main(String[] args) {
TesFrame3 apl = new TesFrame3();
}

public TesFrame3() {
super(“Tes Frame” );
setSize(300, 100);

addWindowListener(
new TesFrame3. apl.. ;

show();
}

class TesFrame3 extends WindowAdapter {


public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
}
2. Lengaka

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class DemoJButtonInterface extends JFrame


implements ActionListener {

private JButton btn;

public DemoJButtonInterface()
{
super(Frame);

Container c = getContentPane();
c.setLayout( new FlowLayout() );

btn = new JButton("Button");


Frame.add(btn);

btn.addActionListener(this);

setSize( 275, 100 );


show();
}

public static void main( String args[] )


{
DemoJButtonInterface app = new DemoJButtonInterface();

apr .addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent event)
{
System.exit( 0 );
}
}
);
}

public void actionPerformed(ActionEvent event)


{
JOptionPane.showMessageDialog( null,
"Anda telah menekan : " + btn.getActionCommand() + "\n" +
"Handler Button ini menggunakan prinsip interface");
}

You might also like