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 ImageIcon i1;
- private ImageIcon i2;
- private JLabel l1;
- private JLabel l2;
- public FirstGui()
- {
- setLayout(new FlowLayout());
- i1 = new ImageIcon(getClass().getResource("cat.jpg"));
- l1 = new JLabel(i1);
- add(l1);
- i2 = new ImageIcon(getClass().getResource("drakepls.jpeg"));
- l2 = new JLabel(i2);
- add(l2);
- }
- public static void main(String args[])
- {
- FirstGui frame = new FirstGui();
- frame.setTitle("First GUI");
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- //frame.setSize(600, 600);
- frame.pack();
- frame.setVisible(true);
- frame.isOpaque();
- frame.setLocationRelativeTo(null);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment