Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Links:
- https://stackoverflow.com/questions/9543320/how-to-position-the-form-in-the-center-screen
- https://www.youtube.com/watch?v=mjOicuXEvwg
- */
- package com.samkough.main;
- import java.awt.*;
- import javax.swing.*;
- @SuppressWarnings("serial")
- public class FirstGui extends JFrame
- {
- private JLabel l1;
- private JButton b1;
- private JTextField tf1;
- public static void main(String args[])
- {
- FirstGui frame = new FirstGui();
- // Terminates when you press red x button
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setSize(200, 125);
- frame.setVisible(true);
- frame.setTitle("First Gui");
- frame.setLocationRelativeTo(null);
- }
- public FirstGui()
- {
- setLayout(new FlowLayout());
- l1 = new JLabel("Hi, I'm a label.");
- add(l1);
- tf1 = new JTextField(15);
- add(tf1);
- b1 = new JButton("Hey, I'm a button");
- add(b1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment