How to Earn Money ADFLY

Monday 20 February 2017

Add Button in JFrame Java Program

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Simple extends JFrame{
JButton bt;
public Simple(){
setBounds(0,0,600,400);
setTitle("Simple Java Program");
setLayout(null);

bt=new JButton("Submit");//create object of button
bt.setBounds(30,50,100,30);

add(bt);//add the button
setVisible(true);
}
public static void main(String args[]){
JFrame f=new Simple();
}
}import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Simple extends JFrame{
JButton bt;
public Simple(){
setBounds(0,0,600,400);
setTitle("Simple Java Program");
setLayout(null);

bt=new JButton("Submit");//create object of button
bt.setBounds(30,50,100,30);

add(bt);//add the button
setVisible(true);
}
public static void main(String args[]){
JFrame f=new Simple();
}
}

No comments:

Post a Comment