Example usage for java.awt GridBagConstraints BOTH

List of usage examples for java.awt GridBagConstraints BOTH

Introduction

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

Prototype

int BOTH

To view the source code for java.awt GridBagConstraints BOTH.

Click Source Link

Document

Resize the component both horizontally and vertically.

Usage

From source file:com.jaxzin.iraf.forecast.swing.JForecaster.java

@SuppressWarnings({ "FieldRepeatedlyAccessedInMethod" })
private void initialize() {
    //        final GridBagLayout gridbag = new GridBagLayout();
    setLayout(new GridBagLayout());//new BoxLayout(this, BoxLayout.PAGE_AXIS));

    controlPanel = new JForecasterControl(domain);

    final JFreeChart chart = createJFreeChart();
    final JPanel chartPanel = new ChartPanel(chart, true);
    final GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weighty = 1.0;//  w w  w .j  a  va2 s  . co m
    c.gridx = 0;
    c.gridy = 0;
    //        gridbag.setConstraints(chartPanel, c);
    add(chartPanel, c);

    // todo: change to changelistener of JControlPanel
    domain.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(final PropertyChangeEvent e) {
            chart.getXYPlot().setDataset(createDataset());
            //noinspection CallToStringEquals
            if ("adjustForInflation".equals(e.getPropertyName())) {
                final String label;
                if (domain.isAdjustForInflation()) {
                    label = "Account Value (Adjusted to Today's Value)";
                } else {
                    label = "Account Value";
                }
                logAxis.setLabel(label);
                linearAxis.setLabel(label);
            }
        }
    });
    controlPanel.addPropertyChangeListener("logScale", new PropertyChangeListener() {
        public void propertyChange(final PropertyChangeEvent e) {
            if (controlPanel.isLogScale()) {
                chart.getXYPlot().setRangeAxis(logAxis);
            } else {
                chart.getXYPlot().setRangeAxis(linearAxis);
            }
        }
    });

    c.weighty = 0.0;
    c.gridx = 0;
    c.gridy = 1;
    c.anchor = GridBagConstraints.SOUTH;
    //        gridbag.setConstraints(controlPanel, c1);
    add(controlPanel, c);
}

From source file:com.jostrobin.battleships.view.frames.GameFrame.java

private void addGamePanel(int gridX, int gridY, int gridWidth) {
    GridBagConstraints battlefieldConstraints = new GridBagConstraints();
    battlefieldConstraints.weightx = 1.0;
    battlefieldConstraints.weighty = 0.8;
    battlefieldConstraints.gridy = gridY;
    battlefieldConstraints.gridx = gridX;
    battlefieldConstraints.gridwidth = gridWidth;
    battlefieldConstraints.anchor = GridBagConstraints.ABOVE_BASELINE_LEADING;
    battlefieldConstraints.fill = GridBagConstraints.BOTH;
    add(gamePanel, battlefieldConstraints);
}

From source file:width.java

 public void init() {
     GridBagLayout gridBag = new GridBagLayout();
     GridBagConstraints c = new GridBagConstraints();

     setLayout(gridBag);//from  w ww  .j  a v a 2  s .c om

     Label receiverLabel = new Label("Receiver name:", 
                                     Label.RIGHT);
     gridBag.setConstraints(receiverLabel, c);
     add(receiverLabel);

     nameField = new TextField(getParameter("RECEIVERNAME"),
                                            10);
     c.fill = GridBagConstraints.HORIZONTAL;
     gridBag.setConstraints(nameField, c);
     add(nameField);
     nameField.addActionListener(this);

     Button button = new Button("Send message");
     c.gridwidth = GridBagConstraints.REMAINDER; //end row
     c.anchor = GridBagConstraints.WEST; //stick to the 
                                         //text field
     c.fill = GridBagConstraints.NONE; //keep the button 
                                       //small
     gridBag.setConstraints(button, c);
     add(button);
     button.addActionListener(this);

     status = new TextArea(5, 60);
     status.setEditable(false);
     c.anchor = GridBagConstraints.CENTER; //reset to the default
     c.fill = GridBagConstraints.BOTH; //make this big
     c.weightx = 1.0;
     c.weighty = 1.0;
     gridBag.setConstraints(status, c);
     add(status);

     myName = getParameter("NAME");
     Label senderLabel = new Label("(My name is " + myName + ".)",
                                   Label.CENTER);
     c.weightx = 0.0;
     c.weighty = 0.0;
     gridBag.setConstraints(senderLabel, c);
     add(senderLabel);

newline = System.getProperty("line.separator");
 }

From source file:org.bench4Q.console.ui.section.LW_ConfigLoadShowSection.java

/**
 * @param resources/*from   w ww  . j av  a 2s.c o m*/
 * @param processControl
 * @param dispatcherFactory
 * @param configModel
 * @param configLoadSection
 * @throws ConsoleException
 */
public LW_ConfigLoadShowSection(Resources resources, ProcessControl processControl,
        SwingDispatcherFactory dispatcherFactory, ConfigModel configModel,
        LW_ConfigLoadSection configLoadSection) throws ConsoleException {

    m_resources = resources;
    m_processControl = processControl;
    m_swingDispatcherFactory = dispatcherFactory;
    m_configModel = configModel;
    m_args = m_configModel.getArgs();

    this.setLayout(new GridBagLayout());
    this.setPreferredSize(new Dimension(683, 475));
    this.setMinimumSize(new Dimension(683, 475));

    picPanel = new PicPanel(m_args);
    // JPanel picPanel = new JPanel();
    this.add(picPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    m_configModel.addListener(new ConfigModel.AbstractListener() {
        public void isArgsChanged() {
            resetConfig();
        }
    });
    configLoadSection.addListener(new LW_ConfigLoadSection.AbstractListener() {
        public void isArgsChanged() {
            resetConfig();
        }
    });

}

From source file:org.executequery.gui.browser.FindAction.java

private void init() {

    searchPanel = new JPanel(new GridBagLayout());
    popup = new JPopupMenu();

    searchField = WidgetFactory.createTextField();
    searchField.setPreferredSize(new Dimension(270, 22));

    resultsList = initSearchResultsList();
    JScrollPane scrollPane = new JScrollPane(resultsList);
    scrollPane.setPreferredSize(new Dimension(300, 150));

    JLabel label = new JLabel(" Search: ");

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;//from   ww  w  . ja  v a 2s  .  c  o m
    gbc.gridy = 0;
    gbc.insets.left = 3;
    gbc.insets.top = 3;
    gbc.insets.bottom = 3;
    searchPanel.add(label, gbc);
    gbc.gridx = 1;
    gbc.insets.right = 3;
    gbc.insets.left = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    searchPanel.add(searchField, gbc);
    gbc.gridx = 0;
    gbc.gridy++;
    gbc.gridwidth = 2;
    gbc.insets.left = 3;
    gbc.insets.top = 0;
    gbc.fill = GridBagConstraints.BOTH;
    searchPanel.add(scrollPane, gbc);

    popup.setBorder(BorderFactory.createLineBorder(UIUtils.getDefaultBorderColour()));
    popup.add(searchPanel);

    // when the window containing the "comp" has registered Esc key
    // then on pressing Esc instead of search popup getting closed
    // the event is sent to the window. to overcome this we
    // register an action for Esc.
    searchField.registerKeyboardAction(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            popup.setVisible(false);
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_FOCUSED);
}

From source file:it.cnr.icar.eric.client.ui.swing.DiscoveryPanel.java

/**
 * Class Constructor.//from   w w w .j a v a2  s.c  o  m
 */
public DiscoveryPanel() throws JAXRException {
    GridBagLayout gbl = new GridBagLayout();
    setLayout(gbl);

    findParamsPanel = new FindParamsPanel(this);

    JPanel findResultsPanel = createFindResultsPanel();

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, findParamsPanel, findResultsPanel);
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(splitPane, c);
    add(splitPane);

    //add listener for 'locale' bound property
    RegistryBrowser.getInstance().addPropertyChangeListener(RegistryBrowser.PROPERTY_LOCALE, this);
}

From source file:com.digitalgeneralists.assurance.ui.components.ScanLaunchPanel.java

private void initializeComponent() {
    if (!this.initialized) {
        GridBagLayout gridbag = new GridBagLayout();
        this.setLayout(gridbag);

        GridBagConstraints existingScansPanelConstraints = new GridBagConstraints();
        existingScansPanelConstraints.anchor = GridBagConstraints.WEST;
        existingScansPanelConstraints.fill = GridBagConstraints.BOTH;
        existingScansPanelConstraints.gridx = 0;
        existingScansPanelConstraints.gridy = 0;
        existingScansPanelConstraints.weightx = 1.0;
        existingScansPanelConstraints.weighty = 1.0;
        existingScansPanelConstraints.gridheight = 2;
        existingScansPanelConstraints.gridwidth = 1;
        existingScansPanelConstraints.insets = new Insets(0, 0, 0, 0);

        JPanel existingScansPanel = new JPanel();
        GridBagLayout panelGridbag = new GridBagLayout();
        existingScansPanel.setLayout(panelGridbag);
        this.add(existingScansPanel, existingScansPanelConstraints);

        GridBagConstraints existingScansListConstraints = new GridBagConstraints();
        existingScansListConstraints.anchor = GridBagConstraints.WEST;
        existingScansListConstraints.fill = GridBagConstraints.BOTH;
        existingScansListConstraints.gridx = 0;
        existingScansListConstraints.gridy = 0;
        existingScansListConstraints.weightx = 1.0;
        existingScansListConstraints.weighty = 0.9;
        existingScansListConstraints.gridheight = 1;
        existingScansListConstraints.gridwidth = 2;
        existingScansListConstraints.insets = new Insets(5, 5, 5, 5);

        GridBagConstraints existingScanDefinitionsListConstraints = new GridBagConstraints();
        existingScanDefinitionsListConstraints.anchor = GridBagConstraints.WEST;
        existingScanDefinitionsListConstraints.fill = GridBagConstraints.BOTH;
        existingScanDefinitionsListConstraints.gridx = 0;
        existingScanDefinitionsListConstraints.gridy = 0;
        existingScanDefinitionsListConstraints.weightx = 1.0;
        existingScanDefinitionsListConstraints.weighty = 0.9;
        existingScanDefinitionsListConstraints.gridheight = 1;
        existingScanDefinitionsListConstraints.gridwidth = 2;
        existingScanDefinitionsListConstraints.insets = new Insets(5, 5, 5, 5);

        this.existingScanDefinitionsListPanel = new ListInputPanel<ScanDefinition>(this, this);
        existingScansPanel.add(this.existingScanDefinitionsListPanel, existingScanDefinitionsListConstraints);

        GridBagConstraints scanButtonConstraints = new GridBagConstraints();
        scanButtonConstraints.anchor = GridBagConstraints.NORTHEAST;
        scanButtonConstraints.fill = GridBagConstraints.BOTH;
        scanButtonConstraints.gridx = 1;
        scanButtonConstraints.gridy = 0;
        scanButtonConstraints.weightx = 1.0;
        scanButtonConstraints.weighty = 1.0;

        this.startScanButton.setActionCommand(AssuranceActions.scanAction);

        this.add(this.startScanButton, scanButtonConstraints);

        GridBagConstraints scanAndMergeButtonConstraints = new GridBagConstraints();
        scanAndMergeButtonConstraints.anchor = GridBagConstraints.SOUTHEAST;
        scanAndMergeButtonConstraints.fill = GridBagConstraints.BOTH;
        scanAndMergeButtonConstraints.gridx = 1;
        scanAndMergeButtonConstraints.gridy = 1;
        scanAndMergeButtonConstraints.weightx = 1.0;
        scanAndMergeButtonConstraints.weighty = 1.0;

        this.startScanAndMergeButton.setActionCommand(AssuranceActions.scanAndMergeAction);

        this.add(this.startScanAndMergeButton, scanAndMergeButtonConstraints);

        this.startScanAndMergeButton.addActionListener(this);
        this.startScanButton.addActionListener(this);

        this.startScanButton.setEnabled(false);
        this.startScanAndMergeButton.setEnabled(false);

        this.addAncestorListener(new AncestorListener() {
            public void ancestorAdded(AncestorEvent event) {
                applicationDelegate.addEventObserver(ScanStartedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.addEventObserver(ScanCompletedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.addEventObserver(ScanDefinitionDeletedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.addEventObserver(ScanDefinitionSavedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.addEventObserver(ScanDefinitionsLoadedEvent.class,
                        (IEventObserver) event.getSource());
            }/*from   w w  w. j a v  a  2 s .c  o  m*/

            public void ancestorRemoved(AncestorEvent event) {
                applicationDelegate.removeEventObserver(ScanStartedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.removeEventObserver(ScanCompletedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.removeEventObserver(ScanDefinitionDeletedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.removeEventObserver(ScanDefinitionSavedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.removeEventObserver(ScanDefinitionsLoadedEvent.class,
                        (IEventObserver) event.getSource());
            }

            public void ancestorMoved(AncestorEvent event) {
            }
        });

        this.initialized = true;
    }
}

From source file:br.org.acessobrasil.silvinha.vista.panels.PainelSenha.java

public PainelSenha() {

    lblNome = new JLabel(GERAL.USUARIO);
    lblPass = new JLabel(GERAL.SENHA);
    txtName = new JTextField(10);
    txtPass = new JPasswordField(10);

    GridBagLayout bag = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();
    this.setLayout(bag);

    lblNome.setHorizontalAlignment(JLabel.RIGHT);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 1.0;//  w  w  w.java2 s  .c  o  m
    gbc.insets = new Insets(2, 10, 2, 10);
    this.add(lblNome, gbc);

    txtName.setAlignmentX(SwingConstants.WEST);
    txtName.addActionListener(new ActivateNextTextFieldListener(txtPass));
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.insets = new Insets(2, 0, 2, 10);
    this.add(txtName, gbc);

    lblPass.setHorizontalAlignment(JLabel.RIGHT);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridwidth = 1;
    gbc.weightx = 1.0;
    gbc.insets = new Insets(2, 10, 2, 10);
    this.add(lblPass, gbc);

    txtPass.setAlignmentX(SwingConstants.WEST);
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.insets = new Insets(2, 0, 2, 10);
    this.add(txtPass, gbc);

    setSize(300, 130);
    setLocation(300, 300);
    //      this.setBackground(corDefault);

    op = new JOptionPane(this, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
    //      op.setBackground(corDefault);

}

From source file:com.lp.client.frame.component.PanelDiagramm.java

public void eventYouAreSelected(boolean bNeedNoYouAreSelectedI) throws Throwable {
    jpaWorkingOn.removeAll();//from   www.jav a  2 s . c  o m
    diagrammDto = buildDiagrammDto();
    if (diagrammDto.getJfcKapazitaetsvorschau() != null) {
        chartPanel = new ChartPanel(diagrammDto.getJfcKapazitaetsvorschau());
        jpaWorkingOn.add(chartPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
                GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
        chartPanel.addChartMouseListener(this);
    }
    // Refreshknopf reaktivieren
    //    updateButtons(new LockStateValue(null, null, PanelBasis.LOCK_IS_NOT_LOCKED));
    super.eventYouAreSelected(false);
}

From source file:ContainerEventDemo.java

public ContainerEventDemo() {
    super(new GridBagLayout());
    GridBagLayout gridbag = (GridBagLayout) getLayout();
    GridBagConstraints c = new GridBagConstraints();

    //Initialize an empty list of buttons.
    buttonList = new Vector(10, 10);

    //Create all the components.
    addButton = new JButton("Add a button");
    addButton.setActionCommand(ADD);/*  w w  w  .j  av a 2 s  .c o  m*/
    addButton.addActionListener(this);

    removeButton = new JButton("Remove a button");
    removeButton.setActionCommand(REMOVE);
    removeButton.addActionListener(this);

    buttonPanel = new JPanel(new GridLayout(1, 1));
    buttonPanel.setPreferredSize(new Dimension(200, 75));
    buttonPanel.addContainerListener(this);

    display = new JTextArea();
    display.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(display);
    scrollPane.setPreferredSize(new Dimension(200, 75));

    clearButton = new JButton("Clear text area");
    clearButton.setActionCommand(CLEAR);
    clearButton.addActionListener(this);

    c.fill = GridBagConstraints.BOTH; //Fill entire cell.
    c.weighty = 1.0; //Button area and message area have equal height.
    c.gridwidth = GridBagConstraints.REMAINDER; //end of row
    gridbag.setConstraints(scrollPane, c);
    add(scrollPane);

    c.weighty = 0.0;
    gridbag.setConstraints(clearButton, c);
    add(clearButton);

    c.weightx = 1.0; //Add/remove buttons have equal width.
    c.gridwidth = 1; //NOT end of row
    gridbag.setConstraints(addButton, c);
    add(addButton);

    c.gridwidth = GridBagConstraints.REMAINDER; //end of row
    gridbag.setConstraints(removeButton, c);
    add(removeButton);

    c.weighty = 1.0; //Button area and message area have equal height.
    gridbag.setConstraints(buttonPanel, c);
    add(buttonPanel);

    setPreferredSize(new Dimension(400, 400));
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}