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:edu.harvard.mcz.imagecapture.RunnableJobReportDialog.java

/**
 * This method initializes jPanel   //from w w w. j a  v a 2s .c  o  m
 *    
 * @return javax.swing.JPanel   
 */
private JPanel getJPanel() {
    if (jPanel == null) {
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.fill = GridBagConstraints.BOTH;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.gridheight = 3;
        gridBagConstraints.gridx = 0;
        jLabel = new JLabel();
        jLabel.setText(title);
        jPanel = new JPanel();
        jPanel.setLayout(new GridBagLayout());
        jPanel.add(jLabel, new GridBagConstraints());
        jPanel.add(getJTextArea(), gridBagConstraints);
    }
    return jPanel;
}

From source file:cool.pandora.modeller.ui.jpanel.base.NewBagInPlaceFrame.java

/**
 * createComponents.//from  w  ww . j  a  va 2s.c om
 *
 * @return pageControl
 */
private JPanel createComponents() {

    final TitlePane titlePane = new TitlePane();
    initStandardCommands();
    final JPanel pageControl = new JPanel(new BorderLayout());
    final JPanel titlePaneContainer = new JPanel(new BorderLayout());
    titlePane.setTitle(bagView.getPropertyMessage("NewBagInPlace.title"));
    titlePane.setMessage(new DefaultMessage(bagView.getPropertyMessage("NewBagInPlace" + ".description")));
    titlePaneContainer.add(titlePane.getControl());
    titlePaneContainer.add(new JSeparator(), BorderLayout.SOUTH);
    pageControl.add(titlePaneContainer, BorderLayout.NORTH);

    final JPanel contentPanel = new JPanel(new GridBagLayout());
    contentPanel.setBorder(new EmptyBorder(10, 10, 10, 10));

    int row = 0;
    layoutSelectDataContent(contentPanel, row++);
    layoutProfileSelectionContent(contentPanel, row++);
    layoutAddKeepFilesToEmptyCheckBox(contentPanel, row++);
    layoutSpacer(contentPanel, row++);

    GuiStandardUtils.attachDialogBorder(contentPanel);
    pageControl.add(contentPanel);
    final JComponent buttonBar = createButtonBar();
    pageControl.add(buttonBar, BorderLayout.SOUTH);

    this.pack();
    return pageControl;

}

From source file:org.keyboardplaying.xtt.ui.UIController.java

/** Builds and shows the main window. */
public void showMainWindow() {
    /* Create UI. */
    JPanel pane = new JPanel(new GridBagLayout());

    /* Arrange the components */
    GridBagConstraints c;/*ww  w .  j av  a  2s . c  o m*/

    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.BOTH;
    pane.add(makeProjectActionButton("action.construct", "action-construct", ImageSize.W_16, constructAction),
            c);

    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.BOTH;
    pane.add(makeProjectActionButton("action.deconstruct", "action-deconstruct", ImageSize.W_16,
            deconstructAction), c);

    c = new GridBagConstraints();
    c.gridx = 2;
    c.gridy = 0;
    c.gridheight = 2;
    c.fill = GridBagConstraints.BOTH;
    pane.add(makeActionButton(null, "icon-settings", ImageSize.W_32, settingsAction), c);

    Window window = makeWindow("app.name", "icon-timetracker", pane);
    window.addWindowListener(new WindowAdapter() {

        /*
         * (non-Javadoc)
         *
         * @see java.awt.event.WindowAdapter#windowClosing(java.awt.event. WindowEvent)
         */
        @Override
        public void windowClosing(WindowEvent e) {
            super.windowClosing(e);
            Frame[] windows = JFrame.getFrames();
            for (Frame w : windows) {
                w.dispose();
            }
        }
    });
    window.setVisible(true);
}

From source file:org.gridchem.client.gui.panels.myccg.resource.HPCChartPanel.java

public HPCChartPanel(StatusListener statusListener) {
    super();/* w w  w .ja  v  a 2  s.  c  o m*/
    this.statusListener = statusListener;
    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    c.fill = GridBagConstraints.BOTH;

    JPanel captionPanel = new JPanel();
    captionPanel.setLayout(new GridLayout(1, 2));
    captionPanel.add(new JLabel());
    captionPanel.add(new JLabel(DEFAULT_MESSAGE));
    captionPanel.add(new JLabel());
    add(captionPanel, c);
    c.weightx = 0;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 1;

    navPanel = createSelectionBar();

    add(navPanel, c);
    enableSelectionBar(false);
    revalidate();

}

From source file:com.sec.ose.osi.ui.frm.main.manage.dialog.JDlgProjectCreate.java

/**
 * This method initializes this/* ww w  .j av  a  2 s .co m*/
 * 
 * @return void
 */
private void initialize() {
    GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
    gridBagConstraints5.gridx = 0;
    gridBagConstraints5.weightx = 0.1;
    gridBagConstraints5.weighty = 0.0;
    gridBagConstraints5.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints5.insets = new Insets(0, 10, 0, 0);
    gridBagConstraints5.gridy = 1;
    GridBagConstraints gridBagConstraints41 = new GridBagConstraints();
    gridBagConstraints41.gridx = 0;
    gridBagConstraints41.weightx = 0.1;
    gridBagConstraints41.anchor = GridBagConstraints.CENTER;
    gridBagConstraints41.insets = new Insets(0, 10, 20, 0);
    gridBagConstraints41.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints41.gridy = 0;
    GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
    gridBagConstraints3.gridx = 1;
    gridBagConstraints3.gridheight = 2;
    gridBagConstraints3.anchor = GridBagConstraints.NORTH;
    gridBagConstraints3.insets = new Insets(10, 0, 0, 0);
    gridBagConstraints3.gridy = 0;
    this.setSize(600, 250);
    this.setLayout(new GridBagLayout());
    this.add(getJPanelButton(), gridBagConstraints3);
    this.add(getJPanelPjtName(), gridBagConstraints41);
    this.add(getJPanelSourceLocation(), gridBagConstraints5);

    getJTextFieldSourceLocation().setText(strPath);
    getJTextFieldSourceLocation().setToolTipText(strPath);
}

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

/**
 * Constructor//from www.  j ava2s .  c o  m
 * 
 * @param compactLayout
 *            if false, there will be message type selectors in the panel
 */
public ChatServicePanel(boolean compactLayout) {
    super(new BorderLayout());

    // Prepare the title header
    titleHeader.setBackground(getBackground().darker());
    titleHeader.setOpaque(true);
    titleHeader.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    titleHeader.setHorizontalAlignment(SwingConstants.CENTER);
    add(titleHeader, BorderLayout.NORTH);

    // Add messages panel
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    messagesPanel.setBackground(UIManager.getColor("List.background"));
    messagesPanel.setOpaque(false);
    messagesPanel.setLayout(new GridBagLayout());
    messagesPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(scrollPane, BorderLayout.CENTER);

    JPanel sendPanel = new JPanel(new GridBagLayout());
    add(sendPanel, BorderLayout.SOUTH);
    Insets insets = new Insets(2, 2, 2, 2);

    // Add text area
    if (compactLayout) {
        messageText = new JTextField();
        ((JTextField) messageText).addActionListener(this);
        sendPanel.add(messageText, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, NORTH, BOTH, insets, 0, 0));

    } else {
        messageText = new JTextArea();
        JScrollPane scrollPane2 = new JScrollPane(messageText);
        scrollPane2.setPreferredSize(new Dimension(100, 50));
        scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        scrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
        sendPanel.add(scrollPane2, new GridBagConstraints(0, 0, 1, 2, 1.0, 1.0, NORTH, BOTH, insets, 0, 0));
    }

    // Add buttons
    ButtonGroup group = new ButtonGroup();
    messageTypeBtn = createMessageTypeButton("Send messages", ICON_MESSAGE, true, group);
    warningTypeBtn = createMessageTypeButton("Send warnings", ICON_WARNING, false, group);
    alertTypeBtn = createMessageTypeButton("Send alerts", ICON_ALERT, false, group);

    if (!compactLayout) {
        JToolBar msgTypePanel = new JToolBar();
        msgTypePanel.setBorderPainted(false);
        msgTypePanel.setOpaque(true);
        msgTypePanel.setFloatable(false);
        sendPanel.add(msgTypePanel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));
        msgTypePanel.add(messageTypeBtn);
        msgTypePanel.add(warningTypeBtn);
        msgTypePanel.add(alertTypeBtn);
    }

    if (compactLayout) {
        sendBtn = new JButton("Send");
        sendPanel.add(sendBtn, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));
    } else {
        sendBtn = new JButton("Send", ICON_MESSAGE);
        sendBtn.setPreferredSize(new Dimension(100, sendBtn.getPreferredSize().height));
        sendPanel.add(sendBtn, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));
    }
    sendBtn.setEnabled(false);
    messageText.setEditable(false);
    sendBtn.addActionListener(this);
}

From source file:com.sec.ose.osi.ui.frm.main.identification.JPanIdentifyResetComment.java

private Component getJPanelOkResetBtn() {
    if (jPanOKCancelBtn == null) {

        jPanOKCancelBtn = new JPanel();

        GridBagConstraints gridBagConstraintsOKBtn = new GridBagConstraints();
        gridBagConstraintsOKBtn.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraintsOKBtn.insets = new Insets(0, 0, 10, 0);
        gridBagConstraintsOKBtn.gridx = 0;
        gridBagConstraintsOKBtn.gridy = 0;

        GridBagConstraints gridBagConstraintsResetBtn = new GridBagConstraints();
        gridBagConstraintsResetBtn.gridx = 0;
        gridBagConstraintsResetBtn.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraintsResetBtn.insets = new Insets(0, 0, 10, 0);
        gridBagConstraintsResetBtn.gridy = 1;

        jPanOKCancelBtn.setLayout(new GridBagLayout());
        jPanOKCancelBtn.add(getJButtonOK(), gridBagConstraintsOKBtn);
        jPanOKCancelBtn.add(getJButtonReset(), gridBagConstraintsResetBtn);
    }//from w  w w .j  a  v a  2 s.  c  o m
    return jPanOKCancelBtn;
}

From source file:com.intel.stl.ui.main.view.HealthHistoryView.java

@Override
protected JPanel getMainComponent() {
    if (mainPanel != null) {
        return mainPanel;
    }//from   w  w  w  . ja  va2s  .co m

    mainPanel = new JPanel();
    GridBagLayout gridBag = new GridBagLayout();
    mainPanel.setLayout(gridBag);
    GridBagConstraints gc = new GridBagConstraints();

    gc.fill = GridBagConstraints.BOTH;
    gc.weightx = 1;
    gc.weighty = 1;
    gc.gridwidth = GridBagConstraints.REMAINDER;
    chartPanel = new ChartPanel(null);
    // chart.PanelsetBorder(BorderFactory.createMatteBorder(0, 0, 1, 0,
    // UIConstants.INTEL_BORDER_GRAY));
    chartPanel.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            chartPanel.setMaximumDrawHeight(e.getComponent().getHeight());
            chartPanel.setMaximumDrawWidth(e.getComponent().getWidth());
            chartPanel.setMinimumDrawWidth(e.getComponent().getWidth());
            chartPanel.setMinimumDrawHeight(e.getComponent().getHeight());
        }
    });
    mainPanel.add(chartPanel, gc);

    gc.gridwidth = 1;
    gc.insets = new Insets(0, 5, 0, 5);
    gc.fill = GridBagConstraints.NONE;
    gc.anchor = GridBagConstraints.WEST;
    gc.weighty = 0;
    startTimeLabel = ComponentFactory.getH5Label("start", Font.PLAIN);
    mainPanel.add(startTimeLabel, gc);

    gc.gridwidth = GridBagConstraints.REMAINDER;
    gc.anchor = GridBagConstraints.EAST;
    endTimeLabel = ComponentFactory.getH5Label("end", Font.PLAIN);
    mainPanel.add(endTimeLabel, gc);

    return mainPanel;
}

From source file:com.sec.ose.osi.ui.frm.login.JPanLogin.java

/**
 * This method initializes jPanelUserInfo   
 *    /* ww  w  .j ava2  s.c o m*/
 * @return javax.swing.JPanel   
 */
private JPanel getJPanelUserInfo() {

    if (jPanelUserInfo == null) {

        jPanelUserInfo = new JPanel();
        jPanelUserInfo.setLayout(new GridBagLayout());

        // User ID
        JLabel jLabelUser = new JLabel("User ID:");
        jLabelUser.setHorizontalAlignment(SwingConstants.RIGHT);
        jLabelUser.setText("User ID :");
        jLabelUser.setEnabled(true);
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridx = 0;
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new Insets(0, 10, 0, 0);
        jPanelUserInfo.add(jLabelUser, gridBagConstraints);

        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.fill = GridBagConstraints.BOTH;
        gridBagConstraints1.gridy = 0;
        gridBagConstraints1.gridx = 1;
        gridBagConstraints1.weightx = 1.0;
        gridBagConstraints1.insets = new Insets(5, 5, 5, 5);
        jPanelUserInfo.add(getJTextFieldUser(), gridBagConstraints1);

        // Password
        JLabel jLabelPwd = new JLabel();
        jLabelPwd.setText("Password :");
        jLabelPwd.setHorizontalAlignment(SwingConstants.RIGHT);
        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.gridy = 1;
        gridBagConstraints2.gridx = 0;
        gridBagConstraints2.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints2.insets = new Insets(0, 10, 0, 0);
        jPanelUserInfo.add(jLabelPwd, gridBagConstraints2);

        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
        gridBagConstraints3.fill = GridBagConstraints.BOTH;
        gridBagConstraints3.gridy = 1;
        gridBagConstraints3.gridx = 1;
        gridBagConstraints3.weightx = 1.0;
        gridBagConstraints3.insets = new Insets(5, 5, 5, 5);
        jPanelUserInfo.add(getJPasswordField(), gridBagConstraints3);

        // Protex Server IP
        JLabel jLabelServer = new JLabel();
        jLabelServer.setText("Protex Server IP :");
        jLabelServer.setHorizontalAlignment(SwingConstants.RIGHT);
        jLabelServer.setDisplayedMnemonic(KeyEvent.VK_UNDEFINED);
        GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
        gridBagConstraints11.gridy = 2;
        gridBagConstraints11.gridx = 0;
        gridBagConstraints11.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints11.insets = new Insets(0, 10, 5, 0);
        jPanelUserInfo.add(jLabelServer, gridBagConstraints11);

        GridBagConstraints gridBagConstraints21 = new GridBagConstraints();
        gridBagConstraints21.gridy = 2;
        gridBagConstraints21.gridx = 1;
        gridBagConstraints21.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints21.insets = new Insets(5, 5, 10, 5);

        jPanelUserInfo.add(getJTextFieldServerIP(), gridBagConstraints21);
    }
    return jPanelUserInfo;
}

From source file:com.excilys.ebi.gatling.recorder.ui.component.RunningFrame.java

public RunningFrame() {

    /* Initialization of the frame */
    setTitle("Gatling Recorder - Running...");
    setMinimumSize(new Dimension(800, 640));
    setLocationRelativeTo(null);//from   w w  w . j a  v  a 2  s.com
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GridBagLayout gbl = new GridBagLayout();
    setLayout(gbl);

    setIconImages(Commons.getIconList());

    /* Declaration & initialization of components */
    JButton btnClear = new JButton("Clear");
    final JButton btnStop = new JButton("Stop !");
    btnStop.setSize(120, 30);

    JScrollPane panelFilters = new JScrollPane(executedEvents);
    panelFilters.setPreferredSize(new Dimension(300, 100));

    stringRequest.setPreferredSize(new Dimension(330, 100));
    JSplitPane requestResponsePane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(stringRequest),
            new JScrollPane(stringResponse));
    final JSplitPane sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, requestResponsePane, stringRequestBody);

    JScrollPane panelHostsCertificate = new JScrollPane(requiredHostsCertificate);
    panelHostsCertificate.setPreferredSize(new Dimension(300, 100));

    /* Layout */
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(10, 5, 0, 0);

    gbc.gridx = 0;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.gridy = 0;
    add(new JLabel("Tag :"), gbc);

    gbc.gridx = 1;
    add(txtTag, gbc);

    gbc.gridx = 2;
    gbc.weightx = 0.5;
    add(btnTag, gbc);

    gbc.gridx = 3;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.weightx = 0.25;
    add(btnClear, gbc);

    gbc.gridx = 4;
    gbc.anchor = GridBagConstraints.LINE_END;
    add(btnStop, gbc);

    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.weightx = 0;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    add(new JLabel("Executed Events:"), gbc);

    gbc.gridy = 2;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.weightx = 1;
    gbc.weighty = 0.20;
    gbc.fill = GridBagConstraints.BOTH;
    add(panelFilters, gbc);

    gbc.gridy = 4;
    gbc.weightx = 1;
    gbc.weighty = 0.75;
    gbc.fill = GridBagConstraints.BOTH;
    add(sp, gbc);

    gbc.gridy = 5;
    gbc.weighty = 0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.anchor = GridBagConstraints.CENTER;
    add(new JLabel("Secured hosts requiring accepting a certificate:"), gbc);

    gbc.gridy = 6;
    gbc.weighty = 0.05;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    add(panelHostsCertificate, gbc);

    /* Listeners */
    btnTag.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (!txtTag.getText().equals(EMPTY)) {
                TagEvent tag = new TagEvent(txtTag.getText());
                events.addElement(tag.toString());
                executedEvents.ensureIndexIsVisible(events.getSize() - 1);
                listEvents.add(tag);
                txtTag.setText(EMPTY);
            }
        }
    });

    executedEvents.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (executedEvents.getSelectedIndex() >= 0) {
                Object obj = listEvents.get(executedEvents.getSelectedIndex());
                if (obj instanceof ResponseReceivedEvent) {
                    ResponseReceivedEvent event = (ResponseReceivedEvent) obj;
                    stringRequest.txt.setText(event.getRequest().toString());
                    stringResponse.txt.setText(event.getResponse().toString());
                    stringRequestBody.txt.setText(new String(event.getRequest().getContent().array()));
                } else {
                    stringRequest.txt.setText(EMPTY);
                    stringResponse.txt.setText(EMPTY);
                    stringRequestBody.txt.setText(EMPTY);
                }
            }
        }
    });

    btnClear.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            clearOldRunning();
        }
    });

    btnStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            saveScenario();
            proxy.shutdown();
            proxy = null;
            if (!Configuration.getInstance().isConfigurationSkipped())
                getEventBus().post(new ShowConfigurationFrameEvent());
            else
                System.exit(0);
        }
    });
}