Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package example;
- import java.awt.Color;
- import javax.swing.GroupLayout;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import javax.swing.JTextField;
- public class Example {
- public JFrame frame;
- public JPanel panel;
- public JButton btn;
- public JTextField txt;
- public Example()
- {
- init();
- }
- void init()
- {
- frame = new JFrame();
- frame.setVisible(true);
- frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- frame.setSize(3 * 100, 3 * 100);
- frame.setLocation(350, 50);
- frame.setBackground(Color.BLUE);
- panel = new JPanel();
- frame.add(panel);
- panel.setVisible(true);
- //panel.setBackground(Color.GRAY);
- panel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
- panel.setPreferredSize(new java.awt.Dimension(100, 100));
- btn = new JButton();
- panel.add(btn);
- btn.setSize(150, 50);
- btn.setVisible(true);
- btn.setLocation(100, 180);
- btn.setText("Button");
- txt = new JTextField();
- panel.add(txt);
- txt.setSize(50, 50);
- txt.setVisible(true);
- txt.setText("Text");
- txt.setLocation(100, 100);
- GroupLayout layout = new GroupLayout(panel);
- panel.setLayout(layout);
- }
- public static void main(String[] args) {
- // TODO code application logic here
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new Example();
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement