How to add button to frame using Java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
///////////////////
// ThirdJava.java
//
//
// This program adds button to the frame
//
// Since no eventhandler is there
// nothing happens when button is clicked
//
// javac ThirdJava.java
//
// produces ThirdJava.class
//
// To execute
// ----------
// java ThirdJava
//
//
//
public class ThirdJava
{
private JFrame mainFrame;
private JLabel headerLabel;
private JLabel statusLabel;
private JPanel controlPanel;
private JButton submit;
private void prepareGUI(){
mainFrame = new JFrame("Sandeep's Window");
mainFrame.setSize(400,400);
submit = new JButton(" Press Me");
mainFrame.add(submit);
mainFrame.setVisible(true);
}
public static void main(String[] args){
ThirdJava sv = new ThirdJava();
sv.prepareGUI();
}
}
No comments:
Post a Comment