Sample of what you want?
Try using JFrame,JButton,JPanel, or try this codes and see.
//import java's core pakage
import java.awt.*;
//import java's extensive pakage
import javax.swing.*;
//class definition
public class SimpleGui extends JFrame {
JButton cbtn; //close button
JButton obtn; //open button
JPanel panel;
//setting the GUI window
public SimpleGui() {
super("Simple GUI");
Container c = getContentPane();
c.setLayout(new BorderLayout());
panel = new JPanel();
panel.setLayout(new FlowLayout());
cbtn = new JButton("Open");
panel.add(cbtn);
obtn = new JButton("Close");
panel.add(obtn);
c.add(panel, BorderLayout.SOUTH);
setSize(200,200);
setVisible(true);
//pack();
}
public static void main(String args[]) {
SimpleGui sg = new SimpleGui();
sg.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
|