-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
517 additions
and
308 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package de.mpg.molgen.buczek.portifix; | ||
|
||
import java.awt.Color; | ||
import java.awt.Component; | ||
import java.awt.Container; | ||
import java.awt.Graphics; | ||
import java.awt.GridBagConstraints; | ||
import java.awt.GridBagLayout; | ||
import java.awt.Insets; | ||
import javax.swing.BorderFactory; | ||
import javax.swing.JButton; | ||
import javax.swing.JLabel; | ||
import javax.swing.JTextField; | ||
import javax.swing.border.Border; | ||
|
||
/** | ||
* | ||
* @author buczek | ||
*/ | ||
public class GridBagTest extends javax.swing.JFrame { | ||
|
||
Container pane; | ||
|
||
|
||
public GridBagTest() { | ||
pane=getContentPane(); | ||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); | ||
pane.setLayout(new GridBagLayout()); | ||
addComponent(0,0,false,new JLabel("Bla:")); | ||
addComponent(0,1,true, new JLabel("lalaalallaala")); | ||
addComponent(1,0,false,new JLabel("Label:")); | ||
addComponent(1,1,true, new JLabel("lalallaala")); | ||
addComponent(2,0,false,new JLabel("Label:")); | ||
addComponent(2,1,true, new JTextField()); | ||
|
||
addComponent(0,2,false,new JLabel(" ")); | ||
|
||
addComponent(0,3,false,new JLabel("Bla:")); | ||
addComponent(0,4,true, new JLabel("lalaalallaala")); | ||
addComponent(1,3,false,new JLabel("Label:")); | ||
addComponent(1,4,true, new JLabel("lalallaala")); | ||
addComponent(2,3,false,new JLabel("Label:")); | ||
addComponent(2,4,true, new JTextField()); | ||
|
||
|
||
|
||
|
||
pack(); | ||
setVisible(true); | ||
} | ||
|
||
public static void main(String args[]) { | ||
java.awt.EventQueue.invokeLater(new Runnable() { | ||
public void run() { | ||
new GridBagTest(); | ||
} | ||
}); | ||
} | ||
|
||
|
||
GridBagConstraints constraints=new GridBagConstraints(); | ||
|
||
private void addComponent(int row,int col,boolean fill,Component component) { | ||
constraints.gridx=col; | ||
constraints.gridy=row; | ||
constraints.fill=fill ? GridBagConstraints.HORIZONTAL : GridBagConstraints.NONE; | ||
// constraints.fill=GridBagConstraints.HORIZONTAL; | ||
constraints.weightx=fill ? 1 : 0; | ||
constraints.weighty=0; | ||
constraints.anchor=GridBagConstraints.LINE_START; | ||
//constraints.ipadx=10; | ||
//constraints.ipady=10; | ||
constraints.insets=new Insets(5,10,5,10); | ||
pane.add(component,constraints); | ||
} | ||
|
||
|
||
} |
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
Oops, something went wrong.