Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
code for student feedback surveyin java by using swing
#1

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
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Powered By MyBB, © 2002-2024 iAndrew & Melroy van den Berg.