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:net.sourceforge.pmd.util.designer.CreateXMLRulePanel.java

public CreateXMLRulePanel(JTextArea xpathQueryArea, CodeEditorTextPane codeEditorPane) {
    super();//from   w ww . j a  v a 2  s  .c  om
    this.xpathQueryArea = xpathQueryArea;
    this.codeEditorPane = codeEditorPane;
    GridBagConstraints gbc = new GridBagConstraints();
    // We use a gridbaglayout for a nice and sturdy look and feel
    GridBagLayout gbl = new GridBagLayout();
    setLayout(gbl);

    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    gbc.weightx = 0.5;
    JLabel rulenameLabel = new JLabel("Rule name : ");
    gbl.setConstraints(rulenameLabel, gbc);
    add(rulenameLabel);
    gbc.weightx = 0.5;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.gridx = 1;
    gbl.setConstraints(rulenameField, gbc);
    add(rulenameField);

    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.anchor = GridBagConstraints.EAST;
    gbc.weightx = 0.5;
    JLabel rulemsgLabel = new JLabel("Rule msg : ");
    gbl.setConstraints(rulemsgLabel, gbc);
    add(rulemsgLabel);
    gbc.gridx = 1;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.weightx = 0.5;
    gbl.setConstraints(rulemsgField, gbc);
    add(rulemsgField);

    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.anchor = GridBagConstraints.EAST;
    gbc.weightx = 0.5;
    JLabel ruledescLabel = new JLabel("Rule desc : ");
    gbl.setConstraints(ruledescLabel, gbc);
    add(ruledescLabel);
    gbc.gridx = 1;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.weightx = 0.5;
    ruledescField.setLineWrap(true);
    gbl.setConstraints(ruledescField, gbc);
    add(ruledescField);

    gbc.gridx = 0;
    gbc.gridy = 3;
    gbc.gridwidth = 2;
    gbc.anchor = GridBagConstraints.NORTH;
    JButton createRuleBtn = new JButton("Create rule XML");
    createRuleBtn.addActionListener(this);
    gbl.setConstraints(createRuleBtn, gbc);
    add(createRuleBtn);

    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    JScrollPane ruleXMLPane = new JScrollPane(ruleXMLArea);
    gbl.setConstraints(ruleXMLPane, gbc);
    add(ruleXMLPane);

    repaint();
}

From source file:org.mbs3.juniuploader.gui.pnlUploadSites.java

private void initGUI() {
    try {//w  ww .j a va  2 s.  co m
        GridBagLayout thisLayout = new GridBagLayout();
        this.setLayout(thisLayout);
        {
            btnAddSite = new JButton();
            this.add(btnAddSite, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            btnAddSite.setText("Add Site to List");
            btnAddSite.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    btnAddSiteActionPerformed(evt);
                }
            });
        }
        {
            btnRemoveSite = new JButton();
            this.add(btnRemoveSite, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            btnRemoveSite.setText("Remove Selected Site");
            btnRemoveSite.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    btnRemoveSiteActionPerformed(evt);
                }
            });
        }
        {
            jScrollPane1 = new JScrollPane();
            this.add(jScrollPane1, new GridBagConstraints(1, 1, 1, 4, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
            jScrollPane1.setPreferredSize(new java.awt.Dimension(367, 362));
            {
                lstUploadSites = new JList();
                jScrollPane1.setViewportView(lstUploadSites);
                lstUploadSites.setModel(frmMain.uploadLocations);
                lstUploadSites.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            }
        }
        thisLayout.rowWeights = new double[] { 0.0, 0.1, 0.1, 0.0, 0.1, 0.0 };
        thisLayout.rowHeights = new int[] { 9, 20, 7, 8, 7, 9 };
        thisLayout.columnWeights = new double[] { 0.0, 0.1, 0.0, 0.0, 0.0 };
        thisLayout.columnWidths = new int[] { 11, 20, 9, 217, 11 };
        this.setPreferredSize(new java.awt.Dimension(614, 382));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

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

private void jbInit() throws Throwable {
    this.setLayout(new GridBagLayout());
    jpaWorkingOn = new JPanel(new GridBagLayout());
    chartPanel = new ChartPanel(null);
    JPanel panelButtonAction = getToolsPanel();
    getInternalFrame().addItemChangedListener(this);
    this.add(panelButtonAction, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    this.add(jpaWorkingOn, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
}

From source file:org.intermine.install.swing.source.SourcePanel.java

/**
 * Common initialisation: lays out the child components and wires up the necessary
 * event listeners. /* w  w w .j  a va2 s. c  om*/
 */
private void init() {
    typeField.setEditable(false);
    nameField.setEnabled(false);
    typeField.setEnabled(false);
    dumpCheck.setEnabled(false);

    GridBagConstraints cons = GridBagHelper.setup(this);

    add(new JLabel(Messages.getMessage("source.name")), cons);

    cons.gridy++;
    add(new JLabel(Messages.getMessage("source.type")), cons);

    cons.gridy++;
    add(new JLabel(Messages.getMessage("source.dump")), cons);

    cons.gridx++;
    cons.gridy = 0;
    cons.gridwidth = GridBagConstraints.REMAINDER;
    cons.weightx = 1.0;
    add(nameField, cons);

    cons.gridy++;
    add(typeField, cons);

    cons.gridy++;
    add(dumpCheck, cons);

    cons.gridy++;
    cons.gridx = 0;
    cons.weighty = 1.0;
    cons.fill = GridBagConstraints.BOTH;
    add(new JScrollPane(propertiesPanel), cons);

    nameField.setEnabled(false);
    typeField.setEnabled(false);
    dumpCheck.setEnabled(false);
}

From source file:org.openconcerto.erp.core.finance.accounting.ui.EtatJournauxPanel.java

public EtatJournauxPanel() {
    super();/*from  w  ww  . ja  va2s  .  co m*/

    this.tabbedJournaux = new JTabbedPane();

    this.setLayout(new GridBagLayout());

    final GridBagConstraints c = new DefaultGridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 1;
    c.weighty = 1;

    this.add(this.tabbedJournaux, c);

    JButton buttonImpression = new JButton("Impression");
    JButton buttonClose = new JButton("Fermer");
    c.gridx = 0;
    c.gridy++;
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.EAST;
    this.add(buttonImpression, c);
    c.gridx++;
    c.weightx = 0;
    this.add(buttonClose, c);

    buttonClose.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ((JFrame) SwingUtilities.getRoot(EtatJournauxPanel.this)).dispose();
        };
    });
    buttonImpression.addActionListener(new ImpressionJournauxAction());
}

From source file:MessageViewer.java

/**
 * sets the current message to be displayed in the viewer
 *///w ww.  j  av a 2 s. co  m
public void setMessage(Message what) {
    displayed = what;

    if (mainbody != null)
        remove(mainbody);

    if (what != null) {
        loadHeaders();
        mainbody = getBodyComponent();
    } else {
        headers.setText("");
        TextArea dummy = new TextArea("", 24, 80, TextArea.SCROLLBARS_NONE);
        dummy.setEditable(false);
        mainbody = dummy;
    }

    // add the main body
    GridBagConstraints gb = new GridBagConstraints();
    gb.gridwidth = GridBagConstraints.REMAINDER;
    gb.fill = GridBagConstraints.BOTH;
    gb.weightx = 1.0;
    gb.weighty = 1.0;
    add(mainbody, gb);

    invalidate();
    validate();
}

From source file:Demo.ScatterGraph.java

public ScatterGraph(int sampleNb, List<String> paraType_list) {
    this.sampleNb = sampleNb;
    this.paraType_list = paraType_list;

    // widgets: charts(JFreeChart), parameter selectors (JList)
    DefaultListModel xModel = new DefaultListModel();
    xSelector = new JList(xModel);
    JScrollPane xSelPane = new JScrollPane();
    xSelPane.setViewportView(xSelector);

    DefaultListModel yModel = new DefaultListModel();
    ySelector = new JList(yModel);
    JScrollPane ySelPane = new JScrollPane();
    ySelPane.setViewportView(ySelector);

    charts = new JFreeChart[paraType_list.size()][paraType_list.size()];
    for (int i = 0; i < paraType_list.size(); i++) {
        String para = paraType_list.get(i);
        xModel.addElement(para);// w  ww.j a v  a  2s. co  m
        yModel.addElement(para);

        for (int j = 0; j < paraType_list.size(); j++) {
            charts[i][j] = null;
        }
    }

    charts[0][0] = CreateChart(0, 0);
    chartPane = new ChartPanel(charts[0][0]);

    xSelector.setSelectedIndex(0);
    ySelector.setSelectedIndex(0);

    xSelector.addMouseListener(this);
    ySelector.addMouseListener(this);

    // layout
    GridBagLayout layout = new GridBagLayout();
    setLayout(layout);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.BOTH;

    gbc.insets = new Insets(5, 20, 5, 5);
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 20;
    gbc.weighty = 12;
    gbc.gridheight = 4;
    add(chartPane, gbc);

    gbc.insets = new Insets(5, 5, 5, 20);
    gbc.gridx = 1;
    gbc.weightx = 1;
    gbc.gridheight = 1;

    gbc.gridy = 0;
    gbc.weighty = 1;
    add(new JLabel("X :"), gbc);
    gbc.gridy = 2;
    add(new JLabel("Y :"), gbc);

    gbc.gridy = 1;
    gbc.weighty = 5;
    add(xSelPane, gbc);
    gbc.gridy = 3;
    add(ySelPane, gbc);
}

From source file:events.ContainerEventDemo.java

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

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

    //Create all the components.
    addButton = new JButton("Add a button");
    addButton.setActionCommand(ADD);/* ww  w.jav a 2  s .  c  om*/
    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));
}

From source file:events.FocusEventDemo.java

public void addComponentsToPane(final Container pane) {
    GridBagLayout gridbag = new GridBagLayout();
    pane.setLayout(gridbag);//from  ww  w.  j a va 2  s. co  m

    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:org.openconcerto.erp.core.finance.accounting.ui.GrandLivrePanel.java

public GrandLivrePanel() {
    this.setLayout(new GridBagLayout());
    final GridBagConstraints c = new DefaultGridBagConstraints();
    c.weightx = 1;/*from  w w w  .  ja va2s .  co m*/
    this.tabbedClasse = new JTabbedPane();

    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.weighty = 1;
    c.gridx = 0;

    c.gridy = 0;
    c.gridwidth = 2;
    this.add(this.tabbedClasse, c);

    JButton buttonImpression = new JButton("Impression");
    JButton buttonClose = new JButton("Fermer");
    c.gridx = 0;
    c.gridy++;
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.EAST;
    this.add(buttonImpression, c);
    c.gridx++;
    c.weightx = 0;
    this.add(buttonClose, c);

    buttonClose.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ((JFrame) SwingUtilities.getRoot(GrandLivrePanel.this)).dispose();
        };
    });
    buttonImpression.addActionListener(new ImpressionGrandLivreAction());
}