request for student feedback system project....
Posts: 6,843
Threads: 4
Joined: Mar 2015
import javax.swing.*;
class MyFirstSwingProgram {
JFrame frame;
public static void main(String[] args) {
MyFirstSwingProgram gui = new MyFirstSwingProgram();
gui.go();
}
public void go() {
frame = new JFrame("My first java program"); //this is the frame
//to end the program when the window is closed
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel label = new JLabel("I'm a Label"); // create a label
JButton button = new JButton("I'm a button. Click me"); //create a button
frame.add(label); //adding the label to the frame
frame.add(button);
frame.setSize(300,300); //setting the size of the frame
frame.setVisible(true); //make the frame visible
}
}
Java Swing Button