List of usage examples for java.awt GridBagLayout GridBagLayout
public GridBagLayout()
From source file:Main.java
public Main() { JFrame frame = new JFrame(); JPanel contentPane = (JPanel) frame.getContentPane(); addKeyBind(contentPane, "F10"); clicker = new JButton("Clicker"); contentPane.add(clicker);// www .ja v a2 s.c o m frame.setLayout(new GridBagLayout()); frame.setSize(300, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:GridBagConstraintsSimplePanel.java
public GridBagConstraintsSimplePanel() { super();//w ww .jav a 2 s.com GridBagConstraints constraints = new GridBagConstraints(); GridBagLayout layout = new GridBagLayout(); setLayout(layout); constraints.anchor = GridBagConstraints.WEST; constraints.gridy = 0; JLabel label = new JLabel("First name:"); add(label, constraints); JTextField tf = new JTextField(8); add(tf, constraints); label = new JLabel("Last name:"); add(label, constraints); tf = new JTextField(8); add(tf, constraints); constraints.gridy = 1; label = new JLabel("Address:"); add(label, constraints); tf = new JTextField(10); add(tf, constraints); }
From source file:Main.java
public TestPane() { setLayout(new BorderLayout()); JPanel top = new JPanel(new GridBagLayout()); top.setOpaque(false);//from w w w . java2 s . c om top.add(new JLabel("OK")); JScrollPane sp = new JScrollPane(); sp.setOpaque(false); sp.getViewport().setOpaque(false); sp.setViewportView(top); add(sp); }
From source file:Main.java
public TestPane() { setLayout(new GridBagLayout()); label = new JLabel(); add(label);//from w ww. j a va2 s . c om Timer timer = new Timer(1000, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String labelText = label.getText(); labelText += text.charAt(charIndex); label.setText(labelText); charIndex++; if (charIndex >= text.length()) { ((Timer) e.getSource()).stop(); } } }); timer.start(); }
From source file:Main.java
public TestPane() { JLabel longText = new JLabel("Long Long Text"); JLabel shortText = new JLabel("Short"); JLabel medText = new JLabel("Medium"); setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0;//from ww w . j ava 2 s . c o m gbc.gridy = 0; gbc.anchor = GridBagConstraints.EAST; add(longText, gbc); addFields(gbc); gbc.gridx = 0; gbc.gridy++; gbc.anchor = GridBagConstraints.EAST; add(shortText, gbc); addFields(gbc); gbc.gridx = 0; gbc.gridy++; gbc.anchor = GridBagConstraints.EAST; add(medText, gbc); addFields(gbc); }
From source file:Main.java
/** * @param panel//from w ww.jav a2s . co m * @return pre-configured constraints */ public static GridBagConstraints initPanel(JPanel panel) { panel.setLayout(new GridBagLayout()); panel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); GridBagConstraints gb = new GridBagConstraints(); gb.gridx = 0; gb.gridy = 0; gb.insets = new Insets(2, 2, 2, 2); return gb; }
From source file:Main.java
public GridBagLayoutPanel() { GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints constraints = new GridBagConstraints(); setLayout(gridbag);//ww w . j a v a 2 s . com constraints.weightx = constraints.weighty = 10.0; constraints.fill = constraints.NONE; constraints.ipadx = 30; constraints.ipady = 10; addButton("Press", constraints, gridbag); constraints.weightx = 5.0; constraints.fill = constraints.BOTH; constraints.ipadx = constraints.ipady = 0; constraints.insets = new Insets(10, 30, 10, 20); constraints.gridwidth = constraints.RELATIVE; constraints.gridheight = 2; addButton("GO", constraints, gridbag); constraints.insets = new Insets(0, 0, 0, 0); constraints.gridx = 0; constraints.fill = constraints.NONE; constraints.ipadx = 30; constraints.ipady = 10; constraints.gridwidth = 1; constraints.gridheight = 1; addButton("Push", constraints, gridbag); }
From source file:Main.java
public BlinkPane() { label = new JLabel("Hello"); setLayout(new GridBagLayout()); add(label);//from w w w. java2s. co m Timer timer = new Timer(1000, new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { on = !on; repaint(); } }); timer.setRepeats(true); timer.setCoalesce(true); timer.start(); }
From source file:Main.java
public TestPane() { label = new JLabel("..."); setLayout(new GridBagLayout()); add(label);/*from w w w .j av a 2 s . c om*/ timer = new Timer(500, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { count++; if (count < 100000) { label.setText(Integer.toString(count)); } else { ((Timer) (e.getSource())).stop(); } } }); timer.setInitialDelay(0); timer.start(); }
From source file:MainClass.java
public MainClass() { super("Clipboard Test"); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag);// ww w . j a v a 2 s . c o m srcText = new TextArea(8, 32); c.gridwidth = 2; c.anchor = GridBagConstraints.CENTER; gridbag.setConstraints(srcText, c); add(srcText); copyButton = new Button("Copy Above"); copyButton.setActionCommand("copy"); copyButton.addActionListener(this); c.gridy = 1; c.gridwidth = 1; gridbag.setConstraints(copyButton, c); add(copyButton); pasteButton = new Button("Paste Below"); pasteButton.setActionCommand("paste"); pasteButton.addActionListener(this); pasteButton.setEnabled(false); c.gridx = 1; gridbag.setConstraints(pasteButton, c); add(pasteButton); dstText = new TextArea(8, 32); c.gridx = 0; c.gridy = 2; c.gridwidth = 2; gridbag.setConstraints(dstText, c); add(dstText); pack(); }