Example usage for java.awt GridBagConstraints GridBagConstraints

List of usage examples for java.awt GridBagConstraints GridBagConstraints

Introduction

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

Prototype

public GridBagConstraints(int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty,
        int anchor, int fill, Insets insets, int ipadx, int ipady) 

Source Link

Document

Creates a GridBagConstraints object with all of its fields set to the passed-in arguments.

Usage

From source file:dk.dma.epd.common.prototype.notification.StrategicRouteNotificationDetailPanelCommon.java

/**
 * Adds the strategic route message panels
 * @param notification the route notification
 *///from w w  w .  jav a 2s. co m
private void addStrategicRouteMessages(T notification) {
    messagesPanel.removeAll();

    if (notification == null) {
        return;
    }

    // for each route message
    Insets insets = new Insets(5, 5, 0, 5);
    StrategicRouteNegotiationData routeData = notification.get();
    for (int i = 0; i < routeData.getRouteMessage().size(); i++) {

        int routeIndex = routeData.getRouteMessage().size() - 1 - i;
        StrategicRouteMessage routeMessage = routeData.getRouteMessage().get(routeIndex);
        StrategicRouteMessage prevRouteMessage = (routeIndex == 0) ? null
                : routeData.getRouteMessage().get(routeIndex - 1);

        String routeChanges = (prevRouteMessage != null)
                ? StrategicRouteNotificationCommon.findChanges(new Route(prevRouteMessage.getRoute()),
                        new Route(routeMessage.getRoute()))
                : null;

        String title = getMessageViewTitle(routeMessage);
        StrategicNotificationMessageView messageView = new StrategicNotificationMessageView(title, routeMessage,
                routeChanges, i);

        messagesPanel.add(messageView,
                new GridBagConstraints(0, i + 1, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets, 0, 0));
    }

    // Add filler
    messagesPanel.add(new JLabel(" "), new GridBagConstraints(0, routeData.getRouteMessage().size() + 10, 1, 1,
            1.0, 1.0, WEST, BOTH, insets, 0, 0));
}

From source file:geva.Operator.Operations.UserSelect.java

/**
 * Helper for adding a control to a GridBagLayout control
 * @param container The control to add <var>control</var> to
 * @param control The control being added to <var>container</var>
 * @param gridX The grid column to add the control
 * @param gridY The grid row to add the control
 * @param gridW The number of columns to span
 * @param gridH The number of rows to span
 * @param weightX The amount of horizontal space this column should take
 *  relative to other columns// ww  w.j  a v  a2  s  .  co m
 * @param weightY The amount of vertical space this column should take
 *  relative to other rows
 */
protected static void gridAdd(Container container, Container control, int gridX, int gridY, int gridW,
        int gridH, double weightX, double weightY) {
    container.add(control, new GridBagConstraints(gridX, gridY, gridW, gridH, weightX, weightY,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0));
}

From source file:dk.dma.epd.common.prototype.gui.voct.VOCTAdditionalInfoPanel.java

/**
 * Updates the chat message panel in the Swing event thread
 */// w  w w . j  a va 2  s  .  c om
public void updateChatMessagePanel() {
    // Ensure that we operate in the Swing event thread
    if (!SwingUtilities.isEventDispatchThread()) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                updateChatMessagePanel();
            }
        });
        return;
    }

    // Only enable send-function when there is chat data, and hence a target
    addBtn.setEnabled(true);
    messageText.setEditable(true);

    // Remove all components from the messages panel
    messagesPanel.removeAll();

    Insets insets = new Insets(0, 2, 2, 2);
    Insets insets2 = new Insets(6, 2, 0, 2);

    // if (chatData != null && chatData.getMessageCount() > 0) {

    // First, add a filler component
    int y = 0;
    messagesPanel.add(new JLabel(""),
            new GridBagConstraints(0, y++, 1, 1, 0.0, 1.0, NORTH, VERTICAL, insets, 0, 0));

    // Add the messages
    long lastMessageTime = 0;

    long ownMMSI = MaritimeCloudUtils.toMmsi(EPD.getInstance().getMaritimeId());

    for (VOCTSARInfoMessage message : EPD.getInstance().getVoctHandler().getAdditionalInformationMsgs()) {

        boolean ownMessage = false;

        if (message.getSender() == ownMMSI) {
            ownMessage = true;
        }

        // EPD.getInstance().getIdentityHandler().getActor(mmsi)

        // Check if we need to add a time label
        if (message.getDate() - lastMessageTime > PRINT_DATE_INTERVAL) {

            JLabel dateLabel = new JLabel(String.format(ownMessage ? "Added %s" : "Received %s",
                    Formatter.formatShortDateTimeNoTz(new Date(message.getDate()))));
            dateLabel.setFont(dateLabel.getFont().deriveFont(9.0f).deriveFont(Font.PLAIN));
            dateLabel.setHorizontalAlignment(SwingConstants.CENTER);
            dateLabel.setForeground(Color.LIGHT_GRAY);
            messagesPanel.add(dateLabel,
                    new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, NORTH, HORIZONTAL, insets2, 0, 0));
        }

        // Add a chat message field
        JPanel msg = new JPanel();
        msg.setBorder(new ChatMessageBorder(message, ownMessage));
        JLabel msgLabel = new ChatMessageLabel(message.getMessage(), ownMessage);
        msg.add(msgLabel);
        messagesPanel.add(msg, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, NORTH, HORIZONTAL, insets, 0, 0));

        lastMessageTime = message.getDate();
    }

    // Scroll to the bottom
    validate();
    scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getMaximum());
    messagesPanel.repaint();

    // } else if (chatData == null && noDataComponent != null) {
    // // The noDataComponent may e.g. be a message
    // messagesPanel.add(noDataComponent, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, NORTH, BOTH, insets, 0, 0));
    // }
}

From source file:dk.dma.epd.common.prototype.notification.StrategicRouteNotificationDetailPanelCommon.java

/**
 * Installs the given replyPanel at the top of the list of route messages
 * @param replyPanel the reply panel to install
 */// w w  w . j ava2 s  .c o  m
public void addReplyPanelInMessagesPanel(JPanel replyPanel) {
    Insets insets = new Insets(5, 5, 0, 5);
    messagesPanel.add(replyPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets, 0, 0));
}

From source file:dk.dma.epd.shore.gui.views.SendRouteDialog.java

/**
 * Initialize the GUI/*from   ww w . j  av a  2  s  .  c  o m*/
 */
public void initGUI() {

    JPanel content = new JPanel(new GridBagLayout());
    setContentPane(content);
    Insets insets1 = new Insets(5, 5, 5, 0);
    Insets insets2 = new Insets(5, 0, 5, 5);
    Insets insets5 = new Insets(5, 5, 5, 5);

    // *******************
    // *** Target panel
    // *******************
    JPanel targetPanel = new JPanel(new GridBagLayout());
    targetPanel.setBorder(new TitledBorder("Target"));
    content.add(targetPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));

    mmsiListComboBox.addActionListener(this);
    targetPanel.add(new JLabel("MMSI:"),
            new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));
    targetPanel.add(mmsiListComboBox,
            new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));

    nameComboBox.addActionListener(this);
    targetPanel.add(new JLabel("Name:"),
            new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));
    targetPanel.add(nameComboBox,
            new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));

    chatBtn.setEnabled(false);
    chatBtn.addActionListener(this);
    targetPanel.add(new JLabel("Call Sign:"),
            new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));
    targetPanel.add(callsignLbl, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));
    targetPanel.add(chatBtn, new GridBagConstraints(2, 2, 1, 1, 1.0, 0.0, EAST, NONE, insets5, 0, 0));

    statusLbl.setVisible(false);
    targetPanel.add(statusLbl, new GridBagConstraints(0, 3, 3, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));

    // *******************
    // *** Route panel
    // *******************
    JPanel routePanel = new JPanel(new GridBagLayout());
    routePanel.setBorder(new TitledBorder("Route"));
    content.add(routePanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));

    routeListComboBox.addActionListener(this);
    routePanel.add(new JLabel("Route name:"),
            new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));
    routePanel.add(routeListComboBox,
            new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));

    routePanel.add(new JLabel("Route length:"),
            new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));
    routePanel.add(routeLengthLbl,
            new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));

    int h = (int) departurePicker.getPreferredSize().getHeight();
    initDatePicker(departurePicker, departureSpinner);
    routePanel.add(new JLabel("ETD:"), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));
    routePanel.add(fixSize(departurePicker, 120),
            new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0));
    routePanel.add(fixSize(departureSpinner, 60, h),
            new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, WEST, NONE, insets2, 0, 0));

    initDatePicker(arrivalPicker, arrivalSpinner);
    routePanel.add(new JLabel("ETA:"), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));
    routePanel.add(fixSize(arrivalPicker, 120),
            new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0));
    routePanel.add(fixSize(arrivalSpinner, 60, h),
            new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, WEST, NONE, insets2, 0, 0));

    speedTxtField.getDocument().addDocumentListener(new TextFieldChangeListener(speedTxtField));
    speedTxtField.setHorizontalAlignment(JTextField.RIGHT);
    routePanel.add(new JLabel("Avg. speed:"),
            new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));
    routePanel.add(speedTxtField,
            new GridBagConstraints(1, 4, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));

    zoomBtn.addActionListener(this);
    routePanel.add(zoomBtn, new GridBagConstraints(0, 5, 3, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));

    // *******************
    // *** Send panel
    // *******************
    JPanel sendPanel = new JPanel(new GridBagLayout());
    sendPanel.setBorder(new TitledBorder("Send"));
    content.add(sendPanel, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, CENTER, BOTH, insets5, 0, 0));

    messageTxtField.setLineWrap(true);
    JScrollPane scrollPane = new JScrollPane(messageTxtField);
    scrollPane.setMinimumSize(new Dimension(180, 40));
    scrollPane.setPreferredSize(new Dimension(180, 40));

    sendPanel.add(new JLabel("Message:"),
            new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, NORTHWEST, NONE, insets5, 0, 0));
    sendPanel.add(scrollPane, new GridBagConstraints(0, 1, 2, 1, 1.0, 1.0, WEST, BOTH, insets5, 0, 0));

    sendBtn.addActionListener(this);
    cancelBtn.addActionListener(this);
    sendPanel.add(sendBtn, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));
    sendPanel.add(cancelBtn, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, EAST, NONE, insets5, 0, 0));
}

From source file:org.nuclos.client.layout.wysiwyg.component.properties.PropertyChartPropertyDomainStep.java

@Override
public void prepare() {
    super.prepare();

    chart = model.getChart();/* w w  w.  j a v a 2  s . c o m*/
    wysiwygChart = model.getWYSIWYGChart();

    String sPrefix = getChartProperty(Chart.PROPERTY_COMBINED_PREFIXES);
    combinedPrefixes = (sPrefix == null) ? new StringBuffer("") : new StringBuffer(sPrefix);

    panel = new JPanel();
    panel.setLayout(new BorderLayout());

    final ChartFunction chartFunction = getChartFunction();

    if (!chartFunction.isCombinedChart()) {
        panel.add(getPanelComponent(chartFunction, ""), BorderLayout.CENTER);
    } else {
        JPanel editorType = new JPanel();
        editorType.setLayout(new GridBagLayout());
        JLabel propTypeValue = new JLabel(
                //SpringLocaleDelegate.getInstance().getMessage("wysiwyg.chart.wizard.domain.value",
                "Diagramm hinzufgen:"/*)*/);
        editorType.add(propTypeValue, new GridBagConstraints(0, 0, 0, 1, 1D, 1D, GridBagConstraints.NORTHWEST,
                GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0));
        final JComboBox propTypeComponent = new JComboBox(chartFunction.getCombinedChartFunctions());
        editorType.add(propTypeComponent, new GridBagConstraints(0, 1, 1, 1, 1D, 1D,
                GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 15, 0), 0, 0));

        final JTabbedPane tabbedPane = new JTabbedPane();

        JButton removeButton = new JButton(iconRemove);
        removeButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (tabbedPane.getSelectedIndex() != -1) {
                    PanelComponent panelComponent = (PanelComponent) tabbedPane.getSelectedComponent();
                    combinedPrefixes = new StringBuffer(
                            combinedPrefixes.toString().replaceAll(panelComponent.prefix, ""));
                    tabbedPane.remove(panelComponent);
                }
            }
        });
        editorType.add(removeButton, new GridBagConstraints(1, 1, 1, 1, 1D, 1D, GridBagConstraints.NORTHEAST,
                GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0));
        JButton addButton = new JButton(iconAdd);
        addButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                ChartFunction cFunction = (ChartFunction) propTypeComponent.getSelectedItem();
                String prefix = cFunction.name() + "." + (Math.random() + "").replaceAll("\\.", "") + ":";

                combinedPrefixes.append(prefix);
                tabbedPane.add(cFunction.name(), getPanelComponent(cFunction, prefix));
                tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
            }
        });
        editorType.add(addButton, new GridBagConstraints(2, 1, 1, 1, 1D, 1D, GridBagConstraints.NORTHWEST,
                GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0));

        String[] prefixes = combinedPrefixes.toString().split(":");
        for (String prefix : prefixes) {
            if (prefix.length() > 0) {
                try {
                    ChartFunction cFunction = ChartFunction.valueOf(prefix.split("\\.")[0]);
                    tabbedPane.add(cFunction.name(), getPanelComponent(cFunction, prefix + ":"));
                } catch (Exception e) {
                    // ignore.
                }
            }
        }
        panel.add(editorType, BorderLayout.NORTH);
        panel.add(tabbedPane, BorderLayout.CENTER);
    }
}

From source file:rhinova.gui.main.view.controller.GISViewController.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner non-commercial license
    createUIComponents();/*from   w w w  .j  a  v a 2  s.c o m*/

    panel2 = new JPanel();
    btnSkipBack = new JButton();
    btnBack = new JButton();
    btnPlay = new JButton();
    btnPause = new JButton();
    btnStop = new JButton();
    btnForward = new JButton();
    btnSkipForward = new JButton();
    panel1 = new JPanel();
    label3 = new JLabel();
    lblTime = new JLabel();
    label11 = new JLabel();
    lblFinalTime = new JLabel();
    label4 = new JLabel();
    lblStage = new JLabel();
    label13 = new JLabel();
    lblInitialPopulation = new JLabel();
    label5 = new JLabel();
    lblPopulation = new JLabel();
    label12 = new JLabel();
    lblFinalPopulation = new JLabel();
    label1 = new JLabel();
    lblSlide = new JLabel();
    label18 = new JLabel();
    lblCapacity = new JLabel();
    label2 = new JLabel();
    lblFinalSlide = new JLabel();

    //======== this ========
    setLayout(null);

    //======== panel2 ========
    {
        panel2.setLayout(null);

        //---- btnSkipBack ----
        btnSkipBack.setIcon(new ImageIcon(getClass().getResource("/resoursource/icon/skip_backward.png")));
        btnSkipBack.setBackground(Color.white);
        btnSkipBack.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                btnSkipBackActionPerformed(e);
            }
        });
        panel2.add(btnSkipBack);
        btnSkipBack.setBounds(5, 5, 58, btnSkipBack.getPreferredSize().height);

        //---- btnBack ----
        btnBack.setIcon(new ImageIcon(getClass().getResource("/resoursource/icon/back.png")));
        btnBack.setBackground(Color.white);
        btnBack.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                btnBackActionPerformed(e);
            }
        });
        panel2.add(btnBack);
        btnBack.setBounds(65, 5, 58, btnBack.getPreferredSize().height);

        //---- btnPlay ----
        btnPlay.setIcon(new ImageIcon(getClass().getResource("/resoursource/icon/play.png")));
        btnPlay.setBackground(Color.white);
        btnPlay.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                btnPlayActionPerformed(e);
            }
        });
        panel2.add(btnPlay);
        btnPlay.setBounds(125, 5, 58, btnPlay.getPreferredSize().height);

        //---- btnPause ----
        btnPause.setIcon(new ImageIcon(getClass().getResource("/resoursource/icon/pause.png")));
        btnPause.setBackground(Color.white);
        btnPause.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                btnPauseActionPerformed(e);
            }
        });
        panel2.add(btnPause);
        btnPause.setBounds(185, 5, 58, btnPause.getPreferredSize().height);

        //---- btnStop ----
        btnStop.setIcon(new ImageIcon(getClass().getResource("/resoursource/icon/stop.png")));
        btnStop.setBackground(Color.white);
        btnStop.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                btnStopActionPerformed(e);
            }
        });
        panel2.add(btnStop);
        btnStop.setBounds(245, 5, 58, btnStop.getPreferredSize().height);

        //---- btnForward ----
        btnForward.setIcon(new ImageIcon(getClass().getResource("/resoursource/icon/forward.png")));
        btnForward.setBackground(Color.white);
        btnForward.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                btnForwardActionPerformed(e);
            }
        });
        panel2.add(btnForward);
        btnForward.setBounds(305, 5, 58, btnForward.getPreferredSize().height);

        //---- btnSkipForward ----
        btnSkipForward.setIcon(new ImageIcon(getClass().getResource("/resoursource/icon/skip_forward.png")));
        btnSkipForward.setBackground(Color.white);
        btnSkipForward.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                btnSkipForwardActionPerformed(e);
            }
        });
        panel2.add(btnSkipForward);
        btnSkipForward.setBounds(365, 5, 58, btnSkipForward.getPreferredSize().height);
    }
    add(panel2);
    panel2.setBounds(5, 0, 470, 75);

    //======== panel1 ========
    {
        panel1.setLayout(new GridBagLayout());
        ((GridBagLayout) panel1.getLayout()).columnWidths = new int[] { 82, 113, 92, 130, 0 };
        ((GridBagLayout) panel1.getLayout()).rowHeights = new int[] { 0, 0, 0, 0, 0, 0 };
        ((GridBagLayout) panel1.getLayout()).columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 1.0E-4 };
        ((GridBagLayout) panel1.getLayout()).rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4 };

        //---- label3 ----
        label3.setText("Year:");
        panel1.add(label3, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

        //---- lblTime ----
        lblTime.setText("0000000000");
        panel1.add(lblTime, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                GridBagConstraints.VERTICAL, new Insets(0, 0, 5, 5), 0, 0));

        //---- label11 ----
        label11.setText("Final Time:");
        panel1.add(label11, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

        //---- lblFinalTime ----
        lblFinalTime.setText("0000000000");
        panel1.add(lblFinalTime, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                GridBagConstraints.VERTICAL, new Insets(0, 0, 5, 0), 0, 0));

        //---- label4 ----
        label4.setText("Stage:");
        panel1.add(label4, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

        //---- lblStage ----
        lblStage.setText("0000000000");
        panel1.add(lblStage, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                GridBagConstraints.VERTICAL, new Insets(0, 0, 5, 5), 0, 0));

        //---- label13 ----
        label13.setText("Initial Population:");
        panel1.add(label13, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

        //---- lblInitialPopulation ----
        lblInitialPopulation.setText("0000000000");
        panel1.add(lblInitialPopulation, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                GridBagConstraints.VERTICAL, new Insets(0, 0, 5, 0), 0, 0));

        //---- label5 ----
        label5.setText("Population:");
        panel1.add(label5, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

        //---- lblPopulation ----
        lblPopulation.setText("0000000000");
        panel1.add(lblPopulation, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                GridBagConstraints.VERTICAL, new Insets(0, 0, 5, 5), 0, 0));

        //---- label12 ----
        label12.setText("Final Population:");
        panel1.add(label12, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

        //---- lblFinalPopulation ----
        lblFinalPopulation.setText("0000000000");
        panel1.add(lblFinalPopulation, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                GridBagConstraints.VERTICAL, new Insets(0, 0, 5, 0), 0, 0));

        //---- label1 ----
        label1.setText("Slide");
        panel1.add(label1, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

        //---- lblSlide ----
        lblSlide.setText("0.0");
        panel1.add(lblSlide, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                GridBagConstraints.VERTICAL, new Insets(0, 0, 5, 5), 0, 0));

        //---- label18 ----
        label18.setText("Capacity:");
        panel1.add(label18, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

        //---- lblCapacity ----
        lblCapacity.setText("0000000000");
        panel1.add(lblCapacity, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                GridBagConstraints.VERTICAL, new Insets(0, 0, 5, 0), 0, 0));

        //---- label2 ----
        label2.setText("No Pictures");
        panel1.add(label2, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0));

        //---- lblFinalSlide ----
        lblFinalSlide.setText("0.0");
        panel1.add(lblFinalSlide, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 5), 0, 0));
    }
    add(panel1);
    panel1.setBounds(10, 75, 420, 105);

    { // compute preferred size
        Dimension preferredSize = new Dimension();
        for (int i = 0; i < getComponentCount(); i++) {
            Rectangle bounds = getComponent(i).getBounds();
            preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
            preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
        }
        Insets insets = getInsets();
        preferredSize.width += insets.right;
        preferredSize.height += insets.bottom;
        setMinimumSize(preferredSize);
        setPreferredSize(preferredSize);
    }

    //---- bindings ----
    bindingGroup = new BindingGroup();
    bindingGroup.addBinding(Bindings.createAutoBinding(UpdateStrategy.READ, abstractMovie1,
            BeanProperty.create("year"), lblTime, BeanProperty.create("text")));
    bindingGroup.addBinding(Bindings.createAutoBinding(UpdateStrategy.READ, abstractMovie1,
            BeanProperty.create("stage"), lblStage, BeanProperty.create("text")));
    bindingGroup.addBinding(Bindings.createAutoBinding(UpdateStrategy.READ, abstractMovie1,
            BeanProperty.create("population"), lblPopulation, BeanProperty.create("text")));
    bindingGroup.addBinding(Bindings.createAutoBinding(UpdateStrategy.READ, abstractMovie1,
            BeanProperty.create("finalPopulation"), lblFinalTime, BeanProperty.create("text")));
    bindingGroup.addBinding(Bindings.createAutoBinding(UpdateStrategy.READ, abstractMovie1,
            BeanProperty.create("initialPopulation"), lblInitialPopulation, BeanProperty.create("text")));
    bindingGroup.addBinding(Bindings.createAutoBinding(UpdateStrategy.READ, abstractMovie1,
            BeanProperty.create("finalPopulation"), lblFinalPopulation, BeanProperty.create("text")));
    bindingGroup.addBinding(Bindings.createAutoBinding(UpdateStrategy.READ, abstractMovie1,
            BeanProperty.create("capacity"), lblCapacity, BeanProperty.create("text")));
    bindingGroup.addBinding(Bindings.createAutoBinding(UpdateStrategy.READ, abstractMovie1,
            BeanProperty.create("noPictures"), lblFinalSlide, BeanProperty.create("text")));
    bindingGroup.addBinding(Bindings.createAutoBinding(UpdateStrategy.READ, abstractMovie1,
            BeanProperty.create("currentPictureIndex"), lblSlide, BeanProperty.create("text")));
    bindingGroup.bind();
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:org.jfree.chart.demo.CompassDemo.java

/**
 * Initialises the user interface.//from   w w w  .j ava2 s  .  co  m
 *
 * @throws Exception if there are any exceptions.
 */
void jbInit() throws Exception {
    this.titledBorder1 = new TitledBorder("");
    this.titledBorder2 = new TitledBorder("");
    this.titledBorder3 = new TitledBorder("");
    setLayout(this.gridLayout1);
    this.panelCompassHolder.setLayout(this.borderLayout);
    this.windNullCheckBox.setHorizontalTextPosition(SwingConstants.LEADING);
    this.windNullCheckBox.setText("Null");
    this.windNullCheckBox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            checkWindNullActionPerformed(e);
        }
    });
    this.shipNullCheckBox.setHorizontalTextPosition(SwingConstants.LEFT);
    this.shipNullCheckBox.setText("Null");
    this.shipNullCheckBox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            checkShipNullActionPerformed(e);
        }
    });

    this.spinShip.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(final PropertyChangeEvent evt) {
            if (DEBUG) {
                System.out.println("compassDemo:spinShipPropertyChange");
            }
            final Spinner spinner = (Spinner) evt.getSource();
            if (spinner.isEnabled()) {
                shipData.setValue(new Double(spinner.getValue()));
            }
        }
    });

    this.spinWind.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(final PropertyChangeEvent evt) {
            if (DEBUG) {
                System.out.println("compassDemo:spinWindPropertyChange");
            }
            final Spinner spinner = (Spinner) evt.getSource();
            if (spinner.isEnabled()) {
                compassData.setValue(new Double(spinner.getValue()));
            }
        }
    });
    this.jPanel12.setLayout(this.gridLayout2);
    this.jPanel2.setBorder(this.titledBorder1);
    this.jPanel2.setLayout(this.gridBagLayout2);
    this.jPanel1.setBorder(this.titledBorder2);
    this.jPanel1.setLayout(this.gridBagLayout1);
    this.titledBorder1.setTitle("Second Pointer");
    this.titledBorder2.setTitle("First Pointer");
    this.titledBorder3.setTitle("Plot Options");
    this.pick2Pointer.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            pick2PointerActionPerformed(e);
        }
    });
    this.pick1Pointer.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            pick1PointerActionPerformed(e);
        }
    });
    add(this.panelCompassHolder, null);
    this.panelCompassHolder.add(this.jPanel12, BorderLayout.SOUTH);
    this.jPanel12.add(this.jPanel1, null);

    this.jPanel1.add(this.pick1Pointer, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    this.jPanel1.add(this.windNullCheckBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    this.jPanel1.add(this.spinWind, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    this.jPanel12.add(this.jPanel2, null);

    this.jPanel2.add(this.pick2Pointer, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    this.jPanel2.add(this.shipNullCheckBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    this.jPanel2.add(this.spinShip, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    this.panelCompassHolder.add(this.panelCompass, BorderLayout.CENTER);

}