List of usage examples for java.awt GridBagConstraints GridBagConstraints
public GridBagConstraints()
From source file:GUIManagerQuery.java
/*************************************************************************** * Construct the GUIManagerQuery object, constructing the various components * and laying them out on the screen.//from w w w . ja va2 s . c o m **************************************************************************/ public GUIManagerQuery() { super("GUIManagerQuery"); setLayout(new BorderLayout()); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); versionLabel = new Label("JMF v" + Manager.getVersion()); add(versionLabel, "North"); Panel lower = new Panel(); lower.add(new Label("Content/Protocol")); contentsField = new TextField(32); lower.add(contentsField); add(lower, "South"); results = new TextArea(20, 80); results.setEditable(false); add(results, "Center"); Panel controls = new Panel(); controls.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); hintsButton = new Button("Hints"); gbc.gridx = 0; gbc.gridy = 0; controls.add(hintsButton, gbc); hintsButton.addActionListener(this); playersButton = new Button("Players"); gbc.gridy = 1; controls.add(playersButton, gbc); playersButton.addActionListener(this); processorsButton = new Button("Processors"); gbc.gridy = 2; controls.add(processorsButton, gbc); processorsButton.addActionListener(this); sourcesButton = new Button("DataSources"); gbc.gridy = 3; controls.add(sourcesButton, gbc); sourcesButton.addActionListener(this); add(controls, "East"); }
From source file:cz.alej.michalik.totp.client.AddDialog.java
public AddDialog(final Properties prop) { System.out.println("Pridat novy zaznam"); this.setTitle("Pidat"); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.setMinimumSize(new Dimension(600, 150)); this.setLocationByPlatform(true); // Panel pro vytvoen okraj JPanel panel = new JPanel(); panel.setBorder(new EmptyBorder(10, 10, 10, 10)); panel.setLayout(new GridBagLayout()); // Vlastnosti pro popisky GridBagConstraints label = new GridBagConstraints(); label.insets = new Insets(2, 2, 2, 2); label.fill = GridBagConstraints.NONE; label.weightx = 1;//from w w w .j av a 2 s . c o m // Vlastnosti pro pole GridBagConstraints field = new GridBagConstraints(); field.insets = new Insets(2, 2, 2, 2); field.fill = GridBagConstraints.HORIZONTAL; field.weightx = 10; this.add(panel); // Nastavm ikonu okna try { String path = "/material-design-icons/content/drawable-xhdpi/ic_create_black_48dp.png"; this.setIconImage(Toolkit.getDefaultToolkit().getImage(App.class.getResource(path))); } catch (NullPointerException ex) { System.out.println("Icon not found"); } // Pole pro pojmenovn zznamu // Ikona ImageIcon icon = null; try { String path = "/material-design-icons/editor/drawable-xhdpi/ic_format_color_text_black_18dp.png"; icon = new ImageIcon(App.class.getResource(path)); } catch (NullPointerException ex) { System.out.println("Icon not found"); } // Pidn labelu s ikonou a nastavm velikost psma label.gridy = 0; field.gridy = 0; JLabel nameLabel = new JLabel("Nzev: ", icon, JLabel.CENTER); nameLabel.setFont(nameLabel.getFont().deriveFont(App.FONT_SIZE * 2 / 3)); panel.add(nameLabel, label); // Pole pro jmno final JTextField name = new JTextField(); name.setMaximumSize(new Dimension(Integer.MAX_VALUE, 50)); name.setFont(name.getFont().deriveFont(App.FONT_SIZE * 2 / 3)); panel.add(name, field); // Pole pro zadn sdlenho hesla // Ikona icon = null; try { String path = "/material-design-icons/hardware/drawable-xhdpi/ic_security_black_18dp.png"; icon = new ImageIcon(App.class.getResource(path)); } catch (NullPointerException ex) { System.out.println("Icon not found"); } // Pidn labelu s ikonou label.gridy = 1; field.gridy = 1; JLabel secretLabel = new JLabel("Heslo: ", icon, JLabel.CENTER); secretLabel.setFont(secretLabel.getFont().deriveFont(App.FONT_SIZE * 2 / 3)); panel.add(secretLabel, label); // Pole pro heslo final JTextField secret = new JTextField(); secret.setMaximumSize(new Dimension(Integer.MAX_VALUE, 50)); secret.setFont(secret.getFont().deriveFont(App.FONT_SIZE * 2 / 3)); panel.add(secret, field); this.setVisible(true); // Akce pro odesln formule ActionListener submit = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { submit(prop, name, secret, false); } }; // Pi stisku klvesy Enter odele formul name.addActionListener(submit); secret.addActionListener(submit); // Pi zmn pole pro heslo se vstup okamit zformtuje final Runnable sanitizer = new Runnable() { @Override public void run() { sanitize(secret); } }; secret.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { } @Override public void insertUpdate(DocumentEvent e) { SwingUtilities.invokeLater(sanitizer); } @Override public void changedUpdate(DocumentEvent e) { } }); // Pi zaven okna odele formul this.addWindowListener(new WindowListener() { @Override public void windowOpened(WindowEvent e) { // Ignorovat } @Override public void windowIconified(WindowEvent e) { // Ignorovat } @Override public void windowDeiconified(WindowEvent e) { // Ignorovat } @Override public void windowDeactivated(WindowEvent e) { // Ignorovat } @Override public void windowClosing(WindowEvent e) { // Odeslat submit(prop, name, secret, true); } @Override public void windowClosed(WindowEvent e) { // Ignorovat } @Override public void windowActivated(WindowEvent e) { // Ignorovat } }); }
From source file:com.att.aro.ui.view.menu.file.BPVideoWarnFailPanel.java
public BPVideoWarnFailPanel() { JPanel mainPanel = new JPanel(); this.add(mainPanel); mainPanel.setLayout(new GridBagLayout()); GridBagConstraints constraint = new GridBagConstraints(); mainPanel.add(getGridPanel(), constraint); mainPanel.add(getDefaultButton("Default", (ActionEvent arg) -> setDefault()), constraint); compileResultsField.setEditable(false); if (sError.isEmpty()) { compileResultsField.setBackground(mainPanel.getBackground()); compileResultsField.setForeground(Color.red); compileResultsField.setFont(compileResultsField.getFont().deriveFont(Font.BOLD)); compileResultsField.setText(""); compileResultsField.setVisible(false); } else {/*from w w w. j a v a 2 s.co m*/ compileResultsField.setVisible(true); compileResultsField.setForeground(Color.red); compileResultsField.setText(String.format("ERRORS: %s", sError)); } constraint.anchor = GridBagConstraints.FIRST_LINE_START; constraint.gridy = 300; constraint.gridwidth = 2; mainPanel.add(compileResultsField, constraint); }
From source file:com.sec.ose.osi.ui.frm.main.identification.JPanMatchTypeSelection.java
private void init() { GridBagConstraints gridBagConstraints12 = new GridBagConstraints(); gridBagConstraints12.gridx = 3;//ww w. j av a 2s . c o m gridBagConstraints12.ipadx = 5; gridBagConstraints12.gridy = 0; jLabelArrow2 = new JLabel(); jLabelArrow2.setText(""); GridBagConstraints gridBagConstraints11 = new GridBagConstraints(); gridBagConstraints11.gridx = 1; gridBagConstraints11.ipadx = 5; gridBagConstraints11.gridy = 0; jLabelArrow1 = new JLabel(); jLabelArrow1.setText(""); GridBagConstraints gridBagConstraints8 = new GridBagConstraints(); gridBagConstraints8.ipadx = 10; gridBagConstraints8.insets = new Insets(10, 0, 10, 10); GridBagConstraints gridBagConstraints7 = new GridBagConstraints(); gridBagConstraints7.gridx = 4; gridBagConstraints7.ipadx = 5; gridBagConstraints7.gridy = 0; GridBagConstraints gridBagConstraints4 = new GridBagConstraints(); gridBagConstraints4.gridx = 2; gridBagConstraints4.ipadx = 18; gridBagConstraints4.insets = new Insets(0, 0, 0, 10); gridBagConstraints4.gridy = 0; this.setLayout(new GridBagLayout()); this.add(getJButtonStringSearch(), gridBagConstraints8); this.add(getJButtonCodeMatch(), gridBagConstraints4); this.add(getJButtonPatternMatch(), gridBagConstraints7); this.add(jLabelArrow1, gridBagConstraints11); this.add(jLabelArrow2, gridBagConstraints12); }
From source file:com.jostrobin.battleships.view.panels.PlacementPanel.java
@Override public void afterPropertiesSet() throws Exception { setLayout(new GridBagLayout()); battleField = new BattleFieldPanel(""); GridBagConstraints gamePanelConstraints = new GridBagConstraints(); gamePanelConstraints.weightx = 0.6;/*w ww. j ava 2 s . c o m*/ gamePanelConstraints.weighty = 1.0; gamePanelConstraints.gridy = y; gamePanelConstraints.gridheight = 4; gamePanelConstraints.anchor = GridBagConstraints.ABOVE_BASELINE; gamePanelConstraints.fill = GridBagConstraints.BOTH; add(battleField, gamePanelConstraints); rotate = new JButton("Rotate ship"); rotate.addActionListener(this); GridBagConstraints leftButtonConstraints = new GridBagConstraints(); leftButtonConstraints.gridy = y++; leftButtonConstraints.gridx = 1; leftButtonConstraints.fill = GridBagConstraints.NONE; leftButtonConstraints.anchor = GridBagConstraints.ABOVE_BASELINE; add(rotate, leftButtonConstraints); random = new JButton("Random"); random.addActionListener(this); GridBagConstraints randomButtonConstraints = new GridBagConstraints(); randomButtonConstraints.gridy = y++; randomButtonConstraints.gridx = 1; randomButtonConstraints.fill = GridBagConstraints.NONE; randomButtonConstraints.anchor = GridBagConstraints.ABOVE_BASELINE; random.addActionListener(this); add(random, randomButtonConstraints); shipsPanel = new ShipsPanel(); GridBagConstraints shipsPanelConstraints = new GridBagConstraints(); shipsPanelConstraints.weightx = 1.0; shipsPanelConstraints.weighty = 1.0; shipsPanelConstraints.anchor = GridBagConstraints.BASELINE; shipsPanelConstraints.fill = GridBagConstraints.BOTH; shipsPanelConstraints.gridy = y++; shipsPanelConstraints.gridx = 1; add(shipsPanel, shipsPanelConstraints); ready = new JButton("I'm ready"); ready.addActionListener(this); GridBagConstraints readyButtonConstraints = new GridBagConstraints(); readyButtonConstraints.gridy = y++; readyButtonConstraints.gridx = 1; readyButtonConstraints.anchor = GridBagConstraints.ABOVE_BASELINE; ready.setEnabled(false); add(ready, readyButtonConstraints); updateShips(); }
From source file:MessageViewer.java
public MessageViewer(Message what) { // set our layout super(new GridBagLayout()); // add the toolbar addToolbar();//from w ww . j a v a2s . c om GridBagConstraints gb = new GridBagConstraints(); gb.gridwidth = GridBagConstraints.REMAINDER; gb.fill = GridBagConstraints.BOTH; gb.weightx = 1.0; gb.weighty = 0.0; // add the headers headers = new TextArea("", 4, 80, TextArea.SCROLLBARS_NONE); headers.setEditable(false); add(headers, gb); // now display our message setMessage(what); }
From source file:com.sec.ose.osi.ui.frm.main.report.JPanReportMain.java
/** * This method initializes this/*from w w w .j a va2s.c om*/ * * @return void */ private void initialize() { this.setSize(482, 200); this.setLayout(new GridBagLayout()); GridBagConstraints gridBagConstraints11 = new GridBagConstraints(); gridBagConstraints11.fill = GridBagConstraints.BOTH; gridBagConstraints11.weighty = 1.0; gridBagConstraints11.weightx = 1.0; gridBagConstraints11.gridx = 0; gridBagConstraints11.gridy = 0; GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); gridBagConstraints1.gridx = 10; gridBagConstraints1.insets = new Insets(10, 0, 0, 0); gridBagConstraints1.anchor = GridBagConstraints.NORTH; gridBagConstraints1.gridy = 0; this.add(getJSplitPane(), gridBagConstraints11); this.add(getJPanelbutton(), gridBagConstraints1); }
From source file:ModalMessage.java
/** * This method initializes jPanel // www . j a va 2s. co m * * @return javax.swing.JPanel */ private JPanel getJPanel() { if (jPanel == null) { GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); gridBagConstraints1.gridx = 0; // Generated gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; // Generated gridBagConstraints1.gridy = 1; // Generated GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; // Generated gridBagConstraints.gridy = 0; // Generated gridBagConstraints.weightx = 1.0; // Generated gridBagConstraints.weighty = 1.0; // Generated gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); // Generated gridBagConstraints.gridx = 0; // Generated jPanel = new JPanel(); jPanel.setLayout(new GridBagLayout()); // Generated jPanel.add(getJScrollPane(), gridBagConstraints); // Generated jPanel.add(getButtonPanel(), gridBagConstraints1); } return jPanel; }
From source file:de.codesourcery.jasm16.ide.ui.viewcontainers.ViewFrame.java
public ViewFrame(String title, final IView component) { super(title); if (component == null) { throw new IllegalArgumentException("component must not be NULL."); }// w ww. ja v a 2 s.c om this.component = component; addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { disposeView(component); helper.fireViewContainerClosed(ViewFrame.this); } }); setDefaultCloseOperation(DISPOSE_ON_CLOSE); final JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); final GridBagConstraints cnstrs = new GridBagConstraints(); cnstrs.weightx = 1.0d; cnstrs.weighty = 1.0d; cnstrs.fill = GridBagConstraints.BOTH; cnstrs.gridheight = GridBagConstraints.REMAINDER; cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.gridx = 0; cnstrs.gridy = 0; panel.add(component.getPanel(this), cnstrs); getContentPane().add(panel); pack(); }
From source file:client.gui.ConnectionDialog.java
public ConnectionDialog() { connect = new JButton("Connect"); connectDev = new JButton("Connect (Developer)"); connectSame = new JButton("Connect (a as nick)"); nick = new JTextField(); host = new JTextField(); port = new JTextField(); setLayout(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(); setSize(new Dimension(400, 200)); host.setPreferredSize(new Dimension(200, 24)); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.0;/*from ww w . ja va2 s . c om*/ c.gridx = 0; c.gridy = 0; add(new JLabel("Nick:"), c); c.gridy = 1; add(new JLabel("Host:"), c); c.gridy = 2; add(new JLabel("Port:"), c); c.gridx = 1; c.gridy = 0; add(nick, c); c.gridy = 1; add(host, c); c.gridy = 2; add(port, c); c.gridx = 0; c.gridy = 3; c.gridwidth = 2; add(connect, c); // c.gridy = 4; // add(connectDev, c); // c.gridy = 5; // add(connectSame, c); connect.addActionListener(this); connectDev.addActionListener(this); connectSame.addActionListener(this); addWindowListener(new WindowAdapter() { public void windowClosing(final WindowEvent event) { dispose(); } }); final Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); this.setLocation(dim.width / 2 - this.getSize().width / 2, dim.height / 2 - this.getSize().height / 2); }