import java.awt.*;
import javax.swing.*;
public class JButtons extends JFrame {
public static void main(String[] args) {
new JButtons();
}
public JButtons() {
super("Using JButton");
setSize(500,500);
setLocation(100,100);
Container content = getContentPane();
content.setBackground(Color.white);
content.setLayout(new FlowLayout());
JButton button1 = new JButton("Button1");
content.add(button1);
JButton button2 = new JButton("Button2");
content.add(button2);
JButton button3 = new JButton("Button3");
content.add(button3);
JButton button4 = new JButton("Button4");
button4.setHorizontalTextPosition(SwingConstants.LEFT);
content.add(button4);
pack();
setVisible(true);
}
}
OUTPUT :
import javax.swing.*;
public class JButtons extends JFrame {
public static void main(String[] args) {
new JButtons();
}
public JButtons() {
super("Using JButton");
setSize(500,500);
setLocation(100,100);
Container content = getContentPane();
content.setBackground(Color.white);
content.setLayout(new FlowLayout());
JButton button1 = new JButton("Button1");
content.add(button1);
JButton button2 = new JButton("Button2");
content.add(button2);
JButton button3 = new JButton("Button3");
content.add(button3);
JButton button4 = new JButton("Button4");
button4.setHorizontalTextPosition(SwingConstants.LEFT);
content.add(button4);
pack();
setVisible(true);
}
}
OUTPUT :
No comments:
Post a Comment