Created
March 21, 2017 12:48
-
-
Save ornirus/60d8b2a58cb045fccc2ed4444f59e12e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.*; | |
import java.awt.event.*; | |
import javax.swing.*; | |
import java.awt.image.BufferedImage; | |
public class GUI extends JFrame | |
{ | |
private JTextField username; | |
private JTextField password; | |
private JButton login; | |
private JButton register; | |
private JPanel panel; | |
public GUI() | |
{ | |
setDefaultCloseOperation(EXIT_ON_CLOSE); | |
Container window = getContentPane(); | |
window.setLayout(new GridLayout(0,3)); | |
GridBagConstraints c = new GridBagConstraints(); | |
int i = 3; | |
int j = 3; | |
JPanel[][] panelHolder = new JPanel[i][j]; | |
setLayout(new GridLayout(i,j)); | |
for(int m = 0; m < i; m++) { | |
for(int n = 0; n < j; n++) { | |
panelHolder[m][n] = new JPanel(); | |
add(panelHolder[m][n]); | |
} | |
} | |
panelHolder[1][2].setBackground(Color.lightGray); | |
login = new JButton("Login"); | |
c.fill = GridBagConstraints.HORIZONTAL; | |
c.ipady = 0; //reset to default | |
c.weighty = 1.0; //request any extra vertical space | |
c.anchor = GridBagConstraints.PAGE_END; //bottom of space | |
c.insets = new Insets(10,0,0,0); //top padding | |
c.gridx = 1; //aligned with button 2 | |
c.gridwidth = 2; //2 columns wide | |
c.gridy = 2; //third row | |
panelHolder[1][2].add(login, c); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String[] args) { | |
GUI frame = new GUI(); | |
frame.setSize(800, 800); | |
frame.setVisible(true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment