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:FocusEventDemo.java

public FocusEventDemo() {
    super(new GridBagLayout());
    GridBagLayout gridbag = (GridBagLayout) getLayout();
    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);//from  w w  w . j a  va2  s . c om

    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 vector = new Vector(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 listVector = new Vector(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);
    //We want to prevent the list's scroll bars
    //from getting the focus - even with the keyboard.
    //Note that in general we prefer setRequestFocusable
    //over setFocusable for reasons of accessibility,
    //but this is to work around bug #4866958.
    listScrollPane.getVerticalScrollBar().setFocusable(false);
    listScrollPane.getHorizontalScrollBar().setFocusable(false);
    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 method setRequestFocusEnabled 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);

    //Work around for bug #4866958.
    displayScrollPane.getHorizontalScrollBar().setFocusable(false);
    displayScrollPane.getVerticalScrollBar().setFocusable(false);
    gridbag.setConstraints(displayScrollPane, c);
    add(displayScrollPane);

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

From source file:com.moss.greenshell.state.StateTray.java

public void reset() {
    widgets.clear();/*from  w w  w . java2  s  . c o  m*/
    removeAll();
    setLayout(new GridBagLayout());
    c = new GridBagConstraints();
    c.insets.left = 15;
    c.insets.top = 5;
    c.insets.bottom = 5;
    c.fill = GridBagConstraints.BOTH;
    repaint();
}

From source file:EditorPaneExample11.java

public EditorPaneExample11() {
    super("JEditorPane Example 11");

    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;//from  ww  w .jav a  2s  .  co  m
    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");

    // Allocate the empty tree model
    DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty");
    emptyModel = new DefaultTreeModel(emptyRootNode);

    // Create and place the heading tree
    tree = new JTree(emptyModel);
    tree.setPreferredSize(new Dimension(200, 200));
    getContentPane().add(new JScrollPane(tree), "East");

    // 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);

                // Display an empty tree while loading
                tree.setModel(emptyModel);
                tree.paintImmediately(0, 0, tree.getSize().width, tree.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));
                    TreeNode node = buildHeadingTree(doc);
                    tree.setModel(new DefaultTreeModel(node));
                    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));
                TreeNode node = buildHeadingTree(pane.getDocument());
                tree.setModel(new DefaultTreeModel(node));
                enableInput();
            }
        }
    });

    // Listener for tree selection
    tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent evt) {
            TreePath path = evt.getNewLeadSelectionPath();
            if (path != null) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
                Object userObject = node.getUserObject();
                if (userObject instanceof Heading) {
                    Heading heading = (Heading) userObject;
                    try {
                        Rectangle textRect = pane.modelToView(heading.getOffset());
                        textRect.y += 3 * textRect.height;
                        pane.scrollRectToVisible(textRect);
                    } catch (BadLocationException e) {
                    }
                }
            }
        }
    });
}

From source file:fi.elfcloud.client.dialog.ModifyDataItemDialog.java

public ModifyDataItemDialog(JFrame parent, HashMap<String, String> metaMap, String diName) {
    super(parent, true);
    setTitle(Messages.getString("ModifyDataItemDialog.window_title") + diName); //$NON-NLS-1$
    this.metamap = metaMap;
    tagVector = new Vector<String>();
    setLocationRelativeTo(parent);// www  .ja v a2 s. c om
    panel.setLayout(new GridBagLayout());
    GridBagConstraints cs = new GridBagConstraints();
    cs.insets = new Insets(0, 0, 5, 0);

    lblName = new JLabel(Messages.getString("ModifyDataItemDialog.label_name")); //$NON-NLS-1$
    cs.gridx = 0;
    cs.gridy = 0;
    cs.fill = GridBagConstraints.HORIZONTAL;
    cs.gridwidth = 1;
    cs.weightx = 0;
    panel.add(lblName, cs);

    name = new JTextField(getWidth());
    cs.gridx = GridBagConstraints.RELATIVE;
    cs.gridy = 0;
    cs.fill = GridBagConstraints.HORIZONTAL;
    cs.gridwidth = 2;
    cs.weightx = 1.0;
    name.setText(diName);
    panel.add(name, cs);

    lblDescription = new JLabel(Messages.getString("ModifyDataItemDialog.label_description")); //$NON-NLS-1$
    cs.gridx = 0;
    cs.gridy = 1;
    cs.gridwidth = 1;
    cs.fill = GridBagConstraints.HORIZONTAL;
    cs.weightx = 0;
    panel.add(lblDescription, cs);

    description = new JTextField(getWidth());
    cs.gridx = GridBagConstraints.RELATIVE;
    cs.gridy = 1;
    cs.gridwidth = 2;
    cs.fill = GridBagConstraints.HORIZONTAL;
    cs.weightx = 1.0;
    description.setText(metaMap.get("DSC")); //$NON-NLS-1$
    panel.add(description, cs);

    lblTags = new JLabel(Messages.getString("ModifyDataItemDialog.label_tags")); //$NON-NLS-1$
    cs.gridx = 0;
    cs.gridy = 2;
    cs.gridwidth = 1;
    cs.fill = GridBagConstraints.HORIZONTAL;
    cs.weightx = 0;
    panel.add(lblTags, cs);

    tags = new JTextField(getWidth());
    cs.gridx = GridBagConstraints.RELATIVE;
    cs.gridy = 2;
    cs.fill = GridBagConstraints.HORIZONTAL;
    cs.weightx = 1.0;
    panel.add(tags, cs);

    JButton addButton = new JButton(Messages.getString("ModifyDataItemDialog.button_add_tag")); //$NON-NLS-1$
    cs.gridx = GridBagConstraints.RELATIVE;
    cs.gridy = 2;
    cs.gridwidth = 1;
    cs.weightx = 0;
    addButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String tagText = tags.getText().trim();
            if (!tagText.equals("")) { //$NON-NLS-1$
                addTags(tagText);
            }
            tags.setText(""); //$NON-NLS-1$

            checkboxPanel.revalidate();
            checkboxPanel.repaint();
        }
    });
    panel.add(addButton, cs);

    checkboxPanel = new JPanel(new WrapLayout(FlowLayout.LEFT));
    checkboxPanel.setSize(new Dimension(320, 1));
    try {
        addTags(metamap.get("TGS")); //$NON-NLS-1$
    } catch (NullPointerException e) {
        // No existing tags
    }
    panel.setBorder(new EmptyBorder(5, 5, 0, 5));
    getContentPane().add(panel, BorderLayout.NORTH);
    scrollPane = new JScrollPane(checkboxPanel);
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setBorder(null);
    getContentPane().add(scrollPane, BorderLayout.CENTER);

    JButton generateButton = new JButton(Messages.getString("ModifyDataItemDialog.button_save")); //$NON-NLS-1$
    generateButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (tags.getText().length() > 0) {
                addTags(tags.getText());
            }
            answer = true;
            setVisible(false);
        }
    });
    JButton cancelButton = new JButton(Messages.getString("ModifyDataItemDialog.button_cancel")); //$NON-NLS-1$
    cancelButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            answer = false;
            setVisible(false);
        }
    });
    JPanel bp = new JPanel();
    bp.add(generateButton);
    bp.add(cancelButton);
    getContentPane().add(bp, BorderLayout.PAGE_END);

    setMinimumSize(new Dimension(320, 350));
    pack();
}

From source file:Composite.java

public void init() {
    GridBagLayout layOut = new GridBagLayout();
    getContentPane().setLayout(layOut);//  w w w. ja v a 2 s.c  o m

    GridBagConstraints l = new GridBagConstraints();
    l.weightx = 1.0;
    l.fill = GridBagConstraints.BOTH;
    l.gridwidth = GridBagConstraints.RELATIVE;
    alphaLabel = new JLabel();
    alphaLabel.setText("Alphas");
    Font newFont = getFont().deriveFont(1);
    alphaLabel.setFont(newFont);
    alphaLabel.setHorizontalAlignment(JLabel.CENTER);
    layOut.setConstraints(alphaLabel, l);
    getContentPane().add(alphaLabel);
    GridBagConstraints c = new GridBagConstraints();
    getContentPane().setLayout(layOut);

    l.gridwidth = GridBagConstraints.REMAINDER;
    rulesLabel = new JLabel();
    rulesLabel.setText("Rules");
    newFont = getFont().deriveFont(1);
    rulesLabel.setFont(newFont);
    rulesLabel.setHorizontalAlignment(JLabel.CENTER);
    layOut.setConstraints(rulesLabel, l);
    getContentPane().add(rulesLabel);

    GridBagConstraints a = new GridBagConstraints();
    a.gridwidth = GridBagConstraints.RELATIVE;
    a.weightx = 1.0;
    a.fill = GridBagConstraints.BOTH;
    alphas = new JComboBox();
    layOut.setConstraints(alphas, a);
    alphas.addItem("1.0");
    alphas.addItem("0.75");
    alphas.addItem("0.50");
    alphas.addItem("0.25");
    alphas.addItem("0.0");
    alphas.addItemListener(this);
    getContentPane().add(alphas);

    a.gridwidth = GridBagConstraints.REMAINDER;
    rules = new JComboBox();
    layOut.setConstraints(rules, a);
    rules.addItem("SRC");
    rules.addItem("DST_IN");
    rules.addItem("DST_OUT");
    rules.addItem("DST_OVER");
    rules.addItem("SRC_IN");
    rules.addItem("SRC_OVER");
    rules.addItem("SRC_OUT");
    rules.addItem("CLEAR");
    rules.addItemListener(this);
    getContentPane().add(rules);

    GridBagConstraints fC = new GridBagConstraints();
    fC.fill = GridBagConstraints.BOTH;
    fC.weightx = 1.0;
    fC.weighty = 1.0;
    fC.gridwidth = GridBagConstraints.REMAINDER;
    comp = new CompPanel();
    layOut.setConstraints(comp, fC);
    getContentPane().add(comp);

    validate();
}

From source file:net.sf.jabref.gui.preftabs.PreviewPrefsTab.java

public PreviewPrefsTab(JabRefPreferences prefs) {
    this.prefs = prefs;

    GridBagLayout layout = new GridBagLayout();
    firstPanel.setLayout(layout);//from  ww  w . j a  v  a 2  s.  c o  m
    secondPanel.setLayout(layout);

    setLayout(layout);
    JLabel lab = new JLabel(Localization.lang("Preview") + " 1");
    GridBagConstraints layoutConstraints = new GridBagConstraints();
    layoutConstraints.anchor = GridBagConstraints.WEST;
    layoutConstraints.gridwidth = GridBagConstraints.REMAINDER;
    layoutConstraints.fill = GridBagConstraints.BOTH;
    layoutConstraints.weightx = 1;
    layoutConstraints.weighty = 0;
    layoutConstraints.insets = new Insets(2, 2, 2, 2);
    layout.setConstraints(lab, layoutConstraints);
    layoutConstraints.weighty = 1;
    layout.setConstraints(firstScrollPane, layoutConstraints);
    firstPanel.add(firstScrollPane);
    layoutConstraints.weighty = 0;
    layoutConstraints.gridwidth = 1;
    layoutConstraints.weightx = 0;
    layoutConstraints.fill = GridBagConstraints.NONE;
    layoutConstraints.anchor = GridBagConstraints.WEST;
    layout.setConstraints(testButton, layoutConstraints);
    firstPanel.add(testButton);
    layout.setConstraints(defaultButton, layoutConstraints);
    firstPanel.add(defaultButton);
    layoutConstraints.gridwidth = GridBagConstraints.REMAINDER;
    JPanel newPan = new JPanel();
    layoutConstraints.weightx = 1;
    layout.setConstraints(newPan, layoutConstraints);
    firstPanel.add(newPan);
    lab = new JLabel(Localization.lang("Preview") + " 2");
    layout.setConstraints(lab, layoutConstraints);
    // p2.add(lab);
    layoutConstraints.weighty = 1;
    layoutConstraints.fill = GridBagConstraints.BOTH;
    layout.setConstraints(secondScrollPane, layoutConstraints);
    secondPanel.add(secondScrollPane);
    layoutConstraints.weighty = 0;
    layoutConstraints.weightx = 0;
    layoutConstraints.fill = GridBagConstraints.NONE;
    layoutConstraints.gridwidth = 1;
    layout.setConstraints(testButton2, layoutConstraints);
    secondPanel.add(testButton2);
    layout.setConstraints(defaultButton2, layoutConstraints);
    secondPanel.add(defaultButton2);
    layoutConstraints.gridwidth = 1;
    newPan = new JPanel();
    layoutConstraints.weightx = 1;
    layout.setConstraints(newPan, layoutConstraints);
    secondPanel.add(newPan);

    layoutConstraints.weightx = 1;
    layoutConstraints.weighty = 0;
    layoutConstraints.fill = GridBagConstraints.BOTH;
    layoutConstraints.gridwidth = GridBagConstraints.REMAINDER;
    lab = new JLabel(Localization.lang("Preview") + " 1");
    layout.setConstraints(lab, layoutConstraints);
    add(lab);
    layoutConstraints.weighty = 1;
    layout.setConstraints(firstPanel, layoutConstraints);
    add(firstPanel);
    lab = new JLabel(Localization.lang("Preview") + " 2");
    layoutConstraints.weighty = 0;
    JSeparator sep = new JSeparator(SwingConstants.HORIZONTAL);
    layout.setConstraints(sep, layoutConstraints);
    add(sep);
    layout.setConstraints(lab, layoutConstraints);
    add(lab);
    layoutConstraints.weighty = 1;
    layout.setConstraints(secondPanel, layoutConstraints);
    add(secondPanel);
    layoutConstraints.weighty = 0;

    defaultButton.addActionListener(e -> {
        String tmp = layout1.getText().replace("\n", "__NEWLINE__");
        PreviewPrefsTab.this.prefs.remove(JabRefPreferences.PREVIEW_0);
        layout1.setText(
                PreviewPrefsTab.this.prefs.get(JabRefPreferences.PREVIEW_0).replace("__NEWLINE__", "\n"));
        PreviewPrefsTab.this.prefs.put(JabRefPreferences.PREVIEW_0, tmp);
    });

    defaultButton2.addActionListener(e -> {
        String tmp = layout2.getText().replace("\n", "__NEWLINE__");
        PreviewPrefsTab.this.prefs.remove(JabRefPreferences.PREVIEW_1);
        layout2.setText(
                PreviewPrefsTab.this.prefs.get(JabRefPreferences.PREVIEW_1).replace("__NEWLINE__", "\n"));
        PreviewPrefsTab.this.prefs.put(JabRefPreferences.PREVIEW_1, tmp);
    });

    testButton.addActionListener(e -> {
        PreviewPrefsTab.getTestEntry();
        try {
            PreviewPanel testPanel = new PreviewPanel(null, PreviewPrefsTab.entry, null, layout1.getText());
            testPanel.setPreferredSize(new Dimension(800, 350));
            JOptionPane.showMessageDialog(null, testPanel, Localization.lang("Preview"),
                    JOptionPane.PLAIN_MESSAGE);
        } catch (StringIndexOutOfBoundsException ex) {
            LOGGER.warn("Parsing error.", ex);
            JOptionPane.showMessageDialog(null,
                    Localization.lang("Parsing error") + ": "
                            + Localization.lang("illegal backslash expression") + ".\n" + ex.getMessage(),
                    Localization.lang("Parsing error"), JOptionPane.ERROR_MESSAGE);
        }
    });

    testButton2.addActionListener(e -> {
        PreviewPrefsTab.getTestEntry();
        try {
            PreviewPanel testPanel = new PreviewPanel(null, PreviewPrefsTab.entry, null, layout2.getText());
            testPanel.setPreferredSize(new Dimension(800, 350));
            JOptionPane.showMessageDialog(null, new JScrollPane(testPanel), Localization.lang("Preview"),
                    JOptionPane.PLAIN_MESSAGE);
        } catch (StringIndexOutOfBoundsException ex) {
            LOGGER.warn("Parsing error.", ex);
            JOptionPane.showMessageDialog(null,
                    Localization.lang("Parsing error") + ": "
                            + Localization.lang("illegal backslash expression") + ".\n" + ex.getMessage(),
                    Localization.lang("Parsing error"), JOptionPane.ERROR_MESSAGE);
        }
    });
}

From source file:ProgressDialog.java

private void setupComponent() {

    JPanel contentPane = (JPanel) getContentPane();
    contentPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new GridBagLayout());
    GridBagConstraints gc = new GridBagConstraints();
    gc.gridx = 0;//from  www  . j a  v a  2s. c  o  m
    gc.gridy = GridBagConstraints.RELATIVE;
    gc.anchor = GridBagConstraints.NORTHWEST;
    contentPane.add(lblMessage, gc);
    gc.weightx = 1;
    gc.fill = GridBagConstraints.HORIZONTAL;
    contentPane.add(progressBar, gc);

    setTitle("");
    setModal(true);
    pack();

}

From source file:gate.creole.kea.CorpusImporter.java

protected void initGUIComponents() {
    setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridy = 0;//from w  ww.  j a v a2s.  com
    constraints.gridx = GridBagConstraints.RELATIVE;
    constraints.weightx = 0;
    constraints.weighty = 0;
    constraints.fill = GridBagConstraints.BOTH;

    JPanel inputPanel = new JPanel(new GridBagLayout());
    inputPanel.setBorder(BorderFactory.createTitledBorder("Input"));
    GridBagConstraints constraints2 = new GridBagConstraints();
    constraints2.gridy = 0;
    constraints2.gridx = GridBagConstraints.RELATIVE;
    constraints2.weighty = 0;
    constraints2.weightx = 0;
    constraints2.fill = GridBagConstraints.BOTH;
    constraints2.insets = new Insets(2, 2, 2, 2);

    JLabel label = new JLabel("Source directory:");
    inputPanel.add(label, constraints2);
    sourceDirTField = new JTextField(30);
    inputPanel.add(sourceDirTField, constraints2);
    JButton openButton = new JButton(new SelectDirectoryAction());
    inputPanel.add(openButton, constraints2);

    constraints2.gridy = 1;
    label = new JLabel("Extension for text files:");
    inputPanel.add(label, constraints2);
    constraints2.gridwidth = 2;
    textExtensionTField = new JTextField(".txt");
    inputPanel.add(textExtensionTField, constraints2);
    constraints2.gridwidth = 1;

    constraints2.gridy = 2;
    label = new JLabel("Extension for keyphrase files:");
    inputPanel.add(label, constraints2);
    constraints2.gridwidth = 2;
    keyExtensionTField = new JTextField(".key");
    inputPanel.add(keyExtensionTField, constraints2);
    constraints2.gridwidth = 1;

    constraints2.gridy = 3;
    label = new JLabel("Encoding for input files:");
    inputPanel.add(label, constraints2);
    constraints2.gridwidth = 2;
    encodingTField = new JTextField("");
    inputPanel.add(encodingTField, constraints2);
    constraints2.gridwidth = 1;

    add(inputPanel, constraints);
    constraints.weightx = 1;
    add(Box.createHorizontalGlue(), constraints);
    constraints.weightx = 0;

    JPanel outputPanel = new JPanel();
    outputPanel.setLayout(new GridBagLayout());
    outputPanel.setBorder(BorderFactory.createTitledBorder("Output"));

    constraints2.gridy = 0;
    label = new JLabel("Corpus name:");
    outputPanel.add(label, constraints2);
    constraints2.weightx = 1;
    corpusNameTField = new JTextField("KEA Corpus");
    constraints2.weightx = 0;
    outputPanel.add(corpusNameTField, constraints2);

    constraints2.gridy = 1;
    label = new JLabel("Output annotation set:");
    outputPanel.add(label, constraints2);
    constraints2.weightx = 1;
    annotationSetTField = new JTextField("Key");
    constraints2.weightx = 0;
    outputPanel.add(annotationSetTField, constraints2);

    constraints2.gridy = 2;
    label = new JLabel("Keyphrase annotation type:");
    outputPanel.add(label, constraints2);
    constraints2.weightx = 1;
    annotationTypeTField = new JTextField("Keyphrase");
    constraints2.weightx = 0;
    outputPanel.add(annotationTypeTField, constraints2);

    constraints.gridy = 1;
    add(outputPanel, constraints);

    constraints.gridy = 2;
    constraints.fill = GridBagConstraints.NONE;
    constraints.anchor = GridBagConstraints.CENTER;
    add(new JButton(new ImportCorpusAction()), constraints);

    constraints.gridy = 3;
    constraints.weighty = 1;
    add(Box.createVerticalGlue(), constraints);
}

From source file:com.github.pemapmodder.pocketminegui.gui.server.ServerMainActivity.java

@Override
protected void onStart() {
    lifetime = new ServerLifetime(this);

    //      setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
    setLayout(new GridBagLayout());
    JMenuBar bar = new JMenuBar();
    JMenu serverMenu = new JMenu("Server");
    serverMenu.setMnemonic(KeyEvent.VK_S);
    JMenu playerMenu = new JMenu("Players");
    playerMenu.setMnemonic(KeyEvent.VK_P);
    bar.add(serverMenu);//  w ww .  j  a  va 2 s .c  o m
    bar.add(playerMenu);
    setJMenuBar(bar);

    startStopButton = new JButton("Start");
    startStopButton.addActionListener(lifetime::listen);
    GridBagConstraints constr = new GridBagConstraints();
    constr.gridx = 0;
    constr.gridy = 0;
    constr.fill = GridBagConstraints.VERTICAL;
    constr.weighty = 0.02;
    constr.weightx = 0.1;
    add(startStopButton, constr);
    constr.gridx = 1;
    constr.gridy = 1;
    constr.fill = GridBagConstraints.BOTH;
    constr.weightx = 0.8;
    constr.weighty = 0.9;
    add(consolePanel = new ConsolePanel(this), constr);
}

From source file:org.kepler.plotting.Plot.java

public Plot(TableauFrame frame) {
    GridBagLayout layout = new GridBagLayout();
    this.setLayout(layout);
    GridBagConstraints c = new GridBagConstraints();
    JPanel testGraph = getGraph();
    this.add(testGraph, c);

    _plots.add(this);

    // When the window is closed the plot needs to be
    // removed from the static list so it can be garbage
    // collected/* w  ww.jav a 2 s. c  o  m*/
    WindowClosedAdapter adapter = new WindowClosedAdapter();
    frame.addWindowListener(adapter);
}