Free Academic Seminars And Projects Reports

Full Version: code for student feedback surveyin java by using swing
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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