Example usage for java.awt GridBagLayout GridBagLayout

List of usage examples for java.awt GridBagLayout GridBagLayout

Introduction

In this page you can find the example usage for java.awt GridBagLayout GridBagLayout.

Prototype

public GridBagLayout() 

Source Link

Document

Creates a grid bag layout manager.

Usage

From source file:events.FocusEventDemo.java

public void addComponentsToPane(final Container pane) {
    GridBagLayout gridbag = new GridBagLayout();
    pane.setLayout(gridbag);/*from   w w  w  .  j  a  v a 2s  .com*/

    GridBagConstraints c = new GridBagConstraints();

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0; //Make column as wide as possible.
    JTextField textField = new JTextField("A TextField");
    textField.setMargin(new Insets(0, 2, 0, 2));
    textField.addFocusListener(this);
    gridbag.setConstraints(textField, c);
    add(textField);

    c.weightx = 0.1; //Widen every other column a bit, when possible.
    c.fill = GridBagConstraints.NONE;
    JLabel label = new JLabel("A Label");
    label.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    label.addFocusListener(this);
    gridbag.setConstraints(label, c);
    add(label);

    String comboPrefix = "ComboBox Item #";
    final int numItems = 15;
    Vector<String> vector = new Vector<String>(numItems);
    for (int i = 0; i < numItems; i++) {
        vector.addElement(comboPrefix + i);
    }
    JComboBox comboBox = new JComboBox(vector);
    comboBox.addFocusListener(this);
    gridbag.setConstraints(comboBox, c);
    add(comboBox);

    c.gridwidth = GridBagConstraints.REMAINDER;
    JButton button = new JButton("A Button");
    button.addFocusListener(this);
    gridbag.setConstraints(button, c);
    add(button);

    c.weightx = 0.0;
    c.weighty = 0.1;
    c.fill = GridBagConstraints.BOTH;
    String listPrefix = "List Item #";
    Vector<String> listVector = new Vector<String>(numItems);
    for (int i = 0; i < numItems; i++) {
        listVector.addElement(listPrefix + i);
    }
    JList list = new JList(listVector);
    list.setSelectedIndex(1); //It's easier to see the focus change
    //if an item is selected.
    list.addFocusListener(this);
    JScrollPane listScrollPane = new JScrollPane(list);

    gridbag.setConstraints(listScrollPane, c);
    add(listScrollPane);

    c.weighty = 1.0; //Make this row as tall as possible.
    c.gridheight = GridBagConstraints.REMAINDER;
    //Set up the area that reports focus-gained and focus-lost events.
    display = new JTextArea();
    display.setEditable(false);
    //The setRequestFocusEnabled method prevents a
    //component from being clickable, but it can still
    //get the focus through the keyboard - this ensures
    //user accessibility.
    display.setRequestFocusEnabled(false);
    display.addFocusListener(this);
    JScrollPane displayScrollPane = new JScrollPane(display);

    gridbag.setConstraints(displayScrollPane, c);
    add(displayScrollPane);
    setPreferredSize(new Dimension(450, 450));
    ((JPanel) pane).setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:com.sec.ose.osi.ui.dialog.progress.JDlgProgress.java

/**
 * This method initializes this/*from w ww  .j  a v  a  2s.c om*/
 * 
 * @return void
 */
private void initialize() {
    this.setLayout(new GridBagLayout());
    this.setResizable(false);
    this.setModal(true);
    this.setContentPane(getJContentPane());

    this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    this.addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosing(java.awt.event.WindowEvent e) {
            log.debug("windowClosing() - Progress Dialog");
            mEventHandler.handle(EventHandler.CLOSING_EVENT);
        }
    });
}

From source file:EditorPaneExample10.java

public EditorPaneExample10() {
    super("JEditorPane Example 10");

    pane = new JEditorPane();
    pane.setEditable(false); // Read-only
    getContentPane().add(new JScrollPane(pane), "Center");

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;// w w w  .  j ava2 s.  com
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);
    c.gridy = 3;
    panel.add(new JLabel(LOAD_TIME), c);

    c.gridy = 4;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    onlineLoad = new JCheckBox("Online Load");
    panel.add(onlineLoad, c);
    onlineLoad.setSelected(true);
    onlineLoad.setForeground(typeLabel.getForeground());

    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;

    urlCombo = new JComboBox();
    panel.add(urlCombo, c);
    urlCombo.setEditable(true);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);
    timeLabel = new JLabel("");
    c.gridy = 3;
    panel.add(timeLabel, c);

    getContentPane().add(panel, "South");

    // Change page based on combo selection
    urlCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (populatingCombo == true) {
                return;
            }
            Object selection = urlCombo.getSelectedItem();
            try {
                // Check if the new page and the old
                // page are the same.
                URL url;
                if (selection instanceof URL) {
                    url = (URL) selection;
                } else {
                    url = new URL((String) selection);
                }

                URL loadedURL = pane.getPage();
                if (loadedURL != null && loadedURL.sameFile(url)) {
                    return;
                }

                // Try to display the page
                urlCombo.setEnabled(false); // Disable input
                urlCombo.paintImmediately(0, 0, urlCombo.getSize().width, urlCombo.getSize().height);
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                // Busy cursor
                loadingState.setText("Loading...");
                loadingState.paintImmediately(0, 0, loadingState.getSize().width,
                        loadingState.getSize().height);
                loadedType.setText("");
                loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height);

                timeLabel.setText("");
                timeLabel.paintImmediately(0, 0, timeLabel.getSize().width, timeLabel.getSize().height);

                startTime = System.currentTimeMillis();

                // Choose the loading method
                if (onlineLoad.isSelected()) {
                    // Usual load via setPage
                    pane.setPage(url);
                    loadedType.setText(pane.getContentType());
                } else {
                    pane.setContentType("text/html");
                    loadedType.setText(pane.getContentType());
                    if (loader == null) {
                        loader = new HTMLDocumentLoader();
                    }
                    HTMLDocument doc = loader.loadDocument(url);
                    loadComplete();
                    pane.setDocument(doc);
                    displayLoadTime();
                    populateCombo(findLinks(doc, null));
                    enableInput();
                }
            } catch (Exception e) {
                System.out.println(e);
                JOptionPane.showMessageDialog(pane,
                        new String[] { "Unable to open file", selection.toString() }, "File Open Error",
                        JOptionPane.ERROR_MESSAGE);
                loadingState.setText("Failed");
                enableInput();
            }
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadComplete();
                displayLoadTime();
                populateCombo(findLinks(pane.getDocument(), null));
                enableInput();
            }
        }
    });
}

From source file:DesktopAppTest.java

public DesktopAppFrame() {
    setLayout(new GridBagLayout());
    final JFileChooser chooser = new JFileChooser();
    JButton fileChooserButton = new JButton("...");
    final JTextField fileField = new JTextField(20);
    fileField.setEditable(false);//from w ww.  j  av a2 s . c o  m
    JButton openButton = new JButton("Open");
    JButton editButton = new JButton("Edit");
    JButton printButton = new JButton("Print");
    final JTextField browseField = new JTextField();
    JButton browseButton = new JButton("Browse");
    final JTextField toField = new JTextField();
    final JTextField subjectField = new JTextField();
    JButton mailButton = new JButton("Mail");

    openButton.setEnabled(false);
    editButton.setEnabled(false);
    printButton.setEnabled(false);
    browseButton.setEnabled(false);
    mailButton.setEnabled(false);

    if (Desktop.isDesktopSupported()) {
        Desktop desktop = Desktop.getDesktop();
        if (desktop.isSupported(Desktop.Action.OPEN))
            openButton.setEnabled(true);
        if (desktop.isSupported(Desktop.Action.EDIT))
            editButton.setEnabled(true);
        if (desktop.isSupported(Desktop.Action.PRINT))
            printButton.setEnabled(true);
        if (desktop.isSupported(Desktop.Action.BROWSE))
            browseButton.setEnabled(true);
        if (desktop.isSupported(Desktop.Action.MAIL))
            mailButton.setEnabled(true);
    }

    fileChooserButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (chooser.showOpenDialog(DesktopAppFrame.this) == JFileChooser.APPROVE_OPTION)
                fileField.setText(chooser.getSelectedFile().getAbsolutePath());
        }
    });

    openButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                Desktop.getDesktop().open(chooser.getSelectedFile());
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    });

    editButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                Desktop.getDesktop().edit(chooser.getSelectedFile());
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    });

    printButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                Desktop.getDesktop().print(chooser.getSelectedFile());
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    });

    browseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                Desktop.getDesktop().browse(new URI(browseField.getText()));
            } catch (URISyntaxException ex) {
                ex.printStackTrace();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    });

    mailButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                String subject = percentEncode(subjectField.getText());
                URI uri = new URI("mailto:" + toField.getText() + "?subject=" + subject);

                System.out.println(uri);
                Desktop.getDesktop().mail(uri);
            } catch (URISyntaxException ex) {
                ex.printStackTrace();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    });

    JPanel buttonPanel = new JPanel();
    ((FlowLayout) buttonPanel.getLayout()).setHgap(2);
    buttonPanel.add(openButton);
    buttonPanel.add(editButton);
    buttonPanel.add(printButton);

    add(fileChooserButton, new GBC(0, 0).setAnchor(GBC.EAST).setInsets(2));
    add(fileField, new GBC(1, 0).setFill(GBC.HORIZONTAL));
    add(buttonPanel, new GBC(2, 0).setAnchor(GBC.WEST).setInsets(0));
    add(browseField, new GBC(1, 1).setFill(GBC.HORIZONTAL));
    add(browseButton, new GBC(2, 1).setAnchor(GBC.WEST).setInsets(2));
    add(new JLabel("To:"), new GBC(0, 2).setAnchor(GBC.EAST).setInsets(5, 2, 5, 2));
    add(toField, new GBC(1, 2).setFill(GBC.HORIZONTAL));
    add(mailButton, new GBC(2, 2).setAnchor(GBC.WEST).setInsets(2));
    add(new JLabel("Subject:"), new GBC(0, 3).setAnchor(GBC.EAST).setInsets(5, 2, 5, 2));
    add(subjectField, new GBC(1, 3).setFill(GBC.HORIZONTAL));

    pack();
}

From source file:com.github.boogey.progressview.swing.JProgressPanel.java

/**
 * Initialize the attributes of this classes. This method will be called in the constructor of this class.
 *//*w  ww. j ava2 s.c  om*/
protected void initObjects() {
    setLayout(new GridBagLayout());
    progressBar = new JProgressBar();
    messageLabel = new JLabel();
    positionElements();
}

From source file:de.codesourcery.eve.skills.ui.components.impl.TotalItemVolumeComponent.java

@Override
protected JPanel createPanel() {
    textField.setColumns(10);//www .  jav a2s  .c o  m
    textField.setEditable(false);
    textField.setHorizontalAlignment(JTextField.TRAILING);

    JPanel textFieldPanel = new JPanel();
    textField.setLayout(new GridBagLayout());
    textFieldPanel.setBorder(BorderFactory.createTitledBorder(title));
    textFieldPanel.add(textField,
            constraints(0, 0).weightX(0.5).weightY(0.5).resizeHorizontally().useRelativeWidth().end());

    setVolumeLabel(0.0d);

    return textFieldPanel;
}

From source file:GUIManagerQuery.java

/***************************************************************************
 * Construct the GUIManagerQuery object, constructing the various components
 * and laying them out on the screen./* w w  w .  j  a va  2  s. com*/
 **************************************************************************/
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:MailTest.java

public MailTestFrame() {
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
    setTitle("MailTest");

    setLayout(new GridBagLayout());

    // we use the GBC convenience class of Core Java Volume 1 Chapter 9
    add(new JLabel("From:"), new GBC(0, 0).setFill(GBC.HORIZONTAL));

    from = new JTextField(20);
    add(from, new GBC(1, 0).setFill(GBC.HORIZONTAL).setWeight(100, 0));

    add(new JLabel("To:"), new GBC(0, 1).setFill(GBC.HORIZONTAL));

    to = new JTextField(20);
    add(to, new GBC(1, 1).setFill(GBC.HORIZONTAL).setWeight(100, 0));

    add(new JLabel("SMTP server:"), new GBC(0, 2).setFill(GBC.HORIZONTAL));

    smtpServer = new JTextField(20);
    add(smtpServer, new GBC(1, 2).setFill(GBC.HORIZONTAL).setWeight(100, 0));

    message = new JTextArea();
    add(new JScrollPane(message), new GBC(0, 3, 2, 1).setFill(GBC.BOTH).setWeight(100, 100));

    comm = new JTextArea();
    add(new JScrollPane(comm), new GBC(0, 4, 2, 1).setFill(GBC.BOTH).setWeight(100, 100));

    JPanel buttonPanel = new JPanel();
    add(buttonPanel, new GBC(0, 5, 2, 1));

    JButton sendButton = new JButton("Send");
    buttonPanel.add(sendButton);/* w w w .j  a v  a  2 s . c o m*/
    sendButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            new SwingWorker<Void, Void>() {
                protected Void doInBackground() throws Exception {
                    comm.setText("");
                    sendMail();
                    return null;
                }
            }.execute();
        }
    });
}

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   www  .ja va2s  . c  om*/
    // 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.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;/*from  w  ww  . j a va2s .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();
}