Example usage for java.awt GridBagConstraints WEST

List of usage examples for java.awt GridBagConstraints WEST

Introduction

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

Prototype

int WEST

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

Click Source Link

Document

Put the component on the left side of its display area, centered vertically.

Usage

From source file:com.vgi.mafscaling.LogView.java

private void createToolBar(JPanel panel) {
    toolBar = new JToolBar();
    panel.add(toolBar, BorderLayout.NORTH);

    loadButton = addToolbarButton("Load Log File", "/open.png");
    toolBar.addSeparator();//  ww w. j a v a  2  s.  c  om
    printButton = addToolbarButton("Print", "/print.png");
    previewButton = addToolbarButton("Print Preview", "/print_preview.png");
    findButton = addToolbarButton("Find", "/find.png");
    replaceButton = addToolbarButton("Replace", "/replace.png");
    toolBar.addSeparator();

    viewButton = new JButton("Headers View");
    viewButton.setMargin(new Insets(2, 7, 2, 7));
    viewButton.addActionListener(this);
    toolBar.add(viewButton);
    toolBar.addSeparator();

    logPlayButton = new JButton("Log Play");
    logPlayButton.setMargin(new Insets(2, 7, 2, 7));
    logPlayButton.addActionListener(this);
    toolBar.add(logPlayButton);
    toolBar.addSeparator();

    toolBar.add(new JLabel("Filter "));

    JPanel filterPanel = new JPanel();
    GridBagLayout gbl_filterPanel = new GridBagLayout();
    gbl_filterPanel.columnWidths = new int[] { 0, 0, 0, 0 };
    gbl_filterPanel.rowHeights = new int[] { 0 };
    gbl_filterPanel.columnWeights = new double[] { 0.0, 0.0, 0.0, 1.0 };
    gbl_filterPanel.rowWeights = new double[] { 0.0 };
    filterPanel.setLayout(gbl_filterPanel);

    GridBagConstraints gbc_filter = new GridBagConstraints();
    gbc_filter.insets = insets3;
    gbc_filter.anchor = GridBagConstraints.WEST;
    gbc_filter.gridx = 0;
    gbc_filter.gridy = 0;

    selectionCombo = new JComboBox<String>();
    selectionCombo.setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXXXXXXXXXXX");
    selectionCombo.addActionListener(this);
    filterPanel.add(selectionCombo, gbc_filter);

    gbc_filter.gridx++;
    compareCombo = new JComboBox<String>(new String[] { "", "<", "<=", "=", ">=", ">" });
    compareCombo.addActionListener(this);
    filterPanel.add(compareCombo, gbc_filter);

    gbc_filter.gridx++;
    filterText = new JTextField();
    filterText.setColumns(5);
    filterPanel.add(filterText, gbc_filter);

    gbc_filter.gridx++;
    filterButton = new JButton("Set");
    filterButton.addActionListener(this);
    filterPanel.add(filterButton, gbc_filter);

    toolBar.add(filterPanel);
}

From source file:org.jets3t.apps.uploader.Uploader.java

/**
 * Initialises the application's GUI elements.
 */// w w  w .  j a va2s  . com
private void initGui() {
    // Initialise skins factory.
    skinsFactory = SkinsFactory.getInstance(uploaderProperties.getProperties());

    // Set Skinned Look and Feel.
    LookAndFeel lookAndFeel = skinsFactory.createSkinnedMetalTheme("SkinnedLookAndFeel");
    try {
        UIManager.setLookAndFeel(lookAndFeel);
    } catch (UnsupportedLookAndFeelException e) {
        log.error("Unable to set skinned LookAndFeel", e);
    }

    // Apply branding
    String applicationTitle = replaceMessageVariables(
            uploaderProperties.getStringProperty("gui.applicationTitle", null));
    if (applicationTitle != null) {
        ownerFrame.setTitle(applicationTitle);
    }
    String applicationIconPath = uploaderProperties.getStringProperty("gui.applicationIcon", null);
    if (!isRunningAsApplet && applicationIconPath != null) {
        guiUtils.applyIcon(ownerFrame, applicationIconPath);
    }
    String footerHtml = uploaderProperties.getStringProperty("gui.footerHtml", null);
    String footerIconPath = uploaderProperties.getStringProperty("gui.footerIcon", null);

    // Footer for branding
    boolean includeFooter = false;
    JHtmlLabel footerLabel = skinsFactory.createSkinnedJHtmlLabel("FooterLabel");
    footerLabel.setHyperlinkeActivatedListener(this);
    footerLabel.setHorizontalAlignment(JLabel.CENTER);
    if (footerHtml != null) {
        footerLabel.setText(replaceMessageVariables(footerHtml));
        includeFooter = true;
    }
    if (footerIconPath != null) {
        guiUtils.applyIcon(footerLabel, footerIconPath);
    }

    userInputFields = new UserInputFields(insetsDefault, this, skinsFactory);

    // Screeen 1 : User input fields.
    JPanel screen1Panel = skinsFactory.createSkinnedJPanel("Screen1Panel");
    screen1Panel.setLayout(GRID_BAG_LAYOUT);
    userInputFields.buildFieldsPanel(screen1Panel, uploaderProperties);

    // Screen 2 : Drag/drop panel.
    JPanel screen2Panel = skinsFactory.createSkinnedJPanel("Screen2Panel");
    screen2Panel.setLayout(GRID_BAG_LAYOUT);
    dragDropTargetLabel = skinsFactory.createSkinnedJHtmlLabel("DragDropTargetLabel");
    dragDropTargetLabel.setHyperlinkeActivatedListener(this);
    dragDropTargetLabel.setHorizontalAlignment(JLabel.CENTER);
    dragDropTargetLabel.setVerticalAlignment(JLabel.CENTER);

    JButton chooseFileButton = skinsFactory.createSkinnedJButton("ChooseFileButton");
    chooseFileButton.setActionCommand("ChooseFile");
    chooseFileButton.addActionListener(this);
    configureButton(chooseFileButton, "screen.2.browseButton");

    screen2Panel.add(dragDropTargetLabel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, insetsDefault, 0, 0));
    screen2Panel.add(chooseFileButton, new GridBagConstraints(0, 1, 1, 1, 1, 1, GridBagConstraints.NORTH,
            GridBagConstraints.NONE, insetsDefault, 0, 0));

    // Screen 3 : Information about the file to be uploaded.
    JPanel screen3Panel = skinsFactory.createSkinnedJPanel("Screen3Panel");
    screen3Panel.setLayout(GRID_BAG_LAYOUT);
    fileToUploadLabel = skinsFactory.createSkinnedJHtmlLabel("FileToUploadLabel");
    fileToUploadLabel.setHyperlinkeActivatedListener(this);
    fileToUploadLabel.setHorizontalAlignment(JLabel.CENTER);
    fileToUploadLabel.setVerticalAlignment(JLabel.CENTER);
    screen3Panel.add(fileToUploadLabel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, insetsDefault, 0, 0));

    // Screen 4 : Upload progress.
    JPanel screen4Panel = skinsFactory.createSkinnedJPanel("Screen4Panel");
    screen4Panel.setLayout(GRID_BAG_LAYOUT);
    fileInformationLabel = skinsFactory.createSkinnedJHtmlLabel("FileInformationLabel");
    fileInformationLabel.setHyperlinkeActivatedListener(this);
    fileInformationLabel.setHorizontalAlignment(JLabel.CENTER);
    progressBar = skinsFactory.createSkinnedJProgressBar("ProgressBar", 0, 100);
    progressBar.setStringPainted(true);
    progressStatusTextLabel = skinsFactory.createSkinnedJHtmlLabel("ProgressStatusTextLabel");
    progressStatusTextLabel.setHyperlinkeActivatedListener(this);
    progressStatusTextLabel.setText(" ");
    progressStatusTextLabel.setHorizontalAlignment(JLabel.CENTER);
    progressTransferDetailsLabel = skinsFactory.createSkinnedJHtmlLabel("ProgressTransferDetailsLabel");
    progressTransferDetailsLabel.setHyperlinkeActivatedListener(this);
    progressTransferDetailsLabel.setText(" ");
    progressTransferDetailsLabel.setHorizontalAlignment(JLabel.CENTER);
    cancelUploadButton = skinsFactory.createSkinnedJButton("CancelUploadButton");
    cancelUploadButton.setActionCommand("CancelUpload");
    cancelUploadButton.addActionListener(this);
    configureButton(cancelUploadButton, "screen.4.cancelButton");

    screen4Panel.add(fileInformationLabel, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    screen4Panel.add(progressBar, new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    screen4Panel.add(progressStatusTextLabel, new GridBagConstraints(0, 2, 1, 1, 1, 0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    screen4Panel.add(progressTransferDetailsLabel, new GridBagConstraints(0, 3, 1, 1, 1, 0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    screen4Panel.add(cancelUploadButton, new GridBagConstraints(0, 4, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.NONE, insetsDefault, 0, 0));

    // Screen 5 : Thankyou message.
    JPanel screen5Panel = skinsFactory.createSkinnedJPanel("Screen5Panel");
    screen5Panel.setLayout(GRID_BAG_LAYOUT);
    finalMessageLabel = skinsFactory.createSkinnedJHtmlLabel("FinalMessageLabel");
    finalMessageLabel.setHyperlinkeActivatedListener(this);
    finalMessageLabel.setHorizontalAlignment(JLabel.CENTER);
    screen5Panel.add(finalMessageLabel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, insetsDefault, 0, 0));

    // Wizard Button panel.
    backButton = skinsFactory.createSkinnedJButton("backButton");
    backButton.setActionCommand("Back");
    backButton.addActionListener(this);
    nextButton = skinsFactory.createSkinnedJButton("nextButton");
    nextButton.setActionCommand("Next");
    nextButton.addActionListener(this);

    buttonsPanel = skinsFactory.createSkinnedJPanel("ButtonsPanel");
    buttonsPanelCardLayout = new CardLayout();
    buttonsPanel.setLayout(buttonsPanelCardLayout);
    JPanel buttonsInvisiblePanel = skinsFactory.createSkinnedJPanel("ButtonsInvisiblePanel");
    JPanel buttonsVisiblePanel = skinsFactory.createSkinnedJPanel("ButtonsVisiblePanel");
    buttonsVisiblePanel.setLayout(GRID_BAG_LAYOUT);
    buttonsVisiblePanel.add(backButton, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, insetsDefault, 0, 0));
    buttonsVisiblePanel.add(nextButton, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.EAST,
            GridBagConstraints.NONE, insetsDefault, 0, 0));
    buttonsPanel.add(buttonsInvisiblePanel, "invisible");
    buttonsPanel.add(buttonsVisiblePanel, "visible");

    // Overall content panel.
    appContentPanel = skinsFactory.createSkinnedJPanel("ApplicationContentPanel");
    appContentPanel.setLayout(GRID_BAG_LAYOUT);
    JPanel userGuidancePanel = skinsFactory.createSkinnedJPanel("UserGuidancePanel");
    userGuidancePanel.setLayout(GRID_BAG_LAYOUT);
    primaryPanel = skinsFactory.createSkinnedJPanel("PrimaryPanel");
    primaryPanelCardLayout = new CardLayout();
    primaryPanel.setLayout(primaryPanelCardLayout);
    JPanel navigationPanel = skinsFactory.createSkinnedJPanel("NavigationPanel");
    navigationPanel.setLayout(GRID_BAG_LAYOUT);

    appContentPanel.add(userGuidancePanel, new GridBagConstraints(0, 0, 1, 1, 1, 0.2, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, insetsDefault, 0, 0));
    appContentPanel.add(primaryPanel, new GridBagConstraints(0, 1, 1, 1, 1, 0.6, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, insetsDefault, 0, 0));
    appContentPanel.add(navigationPanel, new GridBagConstraints(0, 2, 1, 1, 1, 0.2, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, insetsDefault, 0, 0));
    if (includeFooter) {
        log.debug("Adding footer for branding");
        appContentPanel.add(footerLabel, new GridBagConstraints(0, 3, 1, 1, 1, 0, GridBagConstraints.CENTER,
                GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    }
    this.getContentPane().add(appContentPanel);

    userGuidanceLabel = skinsFactory.createSkinnedJHtmlLabel("UserGuidanceLabel");
    userGuidanceLabel.setHyperlinkeActivatedListener(this);
    userGuidanceLabel.setHorizontalAlignment(JLabel.CENTER);

    userGuidancePanel.add(userGuidanceLabel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, insetsNone, 0, 0));
    navigationPanel.add(buttonsPanel, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insetsNone, 0, 0));

    primaryPanel.add(screen1Panel, "screen1");
    primaryPanel.add(screen2Panel, "screen2");
    primaryPanel.add(screen3Panel, "screen3");
    primaryPanel.add(screen4Panel, "screen4");
    primaryPanel.add(screen5Panel, "screen5");

    // Set preferred sizes
    int preferredWidth = uploaderProperties.getIntProperty("gui.minSizeWidth", 400);
    int preferredHeight = uploaderProperties.getIntProperty("gui.minSizeHeight", 500);
    this.setBounds(new Rectangle(new Dimension(preferredWidth, preferredHeight)));

    // Initialize drop target.
    initDropTarget(new Component[] { this });

    // Revert to default Look and Feel for all future GUI elements (eg Dialog boxes).
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        log.error("Unable to set default system LookAndFeel", e);
    }

    wizardStepForward();
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.PropertiesUI.java

/**
  * Builds the panel hosting the information
  * /*from  w  ww  .jav  a2s . co m*/
  * @param details The information to display.
  * @param image     The image of reference.
  * @return See above.
  */
private JPanel buildContentPanel(Map details, ImageData image) {
    JPanel content = new JPanel();
    content.setBackground(UIUtilities.BACKGROUND_COLOR);
    content.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    content.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(0, 2, 2, 0);
    c.gridy = 0;
    c.gridx = 0;
    JLabel l = new JLabel();
    Font font = l.getFont();
    int size = font.getSize() - 2;
    JLabel label = UIUtilities.setTextFont(EditorUtil.ARCHIVED, Font.BOLD, size);
    JCheckBox box = new JCheckBox();
    box.setEnabled(false);
    box.setBackground(UIUtilities.BACKGROUND);
    box.setSelected(model.isArchived());
    content.add(label, c);
    c.gridx = c.gridx + 2;
    content.add(box, c);
    c.gridy++;
    c.gridx = 0;
    label = UIUtilities.setTextFont(EditorUtil.ACQUISITION_DATE, Font.BOLD, size);
    JLabel value = UIUtilities.createComponent(null);
    String v = model.formatDate(image);
    value.setText(v);
    content.add(label, c);
    c.gridx = c.gridx + 2;
    content.add(value, c);
    c.gridy++;
    c.gridx = 0;
    try { //just to be on the save side
        label = UIUtilities.setTextFont(EditorUtil.IMPORTED_DATE, Font.BOLD, size);
        value = UIUtilities.createComponent(null);
        v = UIUtilities.formatShortDateTime(image.getInserted());
        value.setText(v);
        content.add(label, c);
        c.gridx = c.gridx + 2;
        content.add(value, c);
        c.gridy++;
    } catch (Exception e) {

    }
    label = UIUtilities.setTextFont(EditorUtil.XY_DIMENSION, Font.BOLD, size);
    value = UIUtilities.createComponent(null);
    v = (String) details.get(EditorUtil.SIZE_X);
    v += " x ";
    v += (String) details.get(EditorUtil.SIZE_Y);
    value.setText(v);
    c.gridx = 0;
    content.add(label, c);
    c.gridx = c.gridx + 2;
    content.add(value, c);
    c.gridy++;
    label = UIUtilities.setTextFont(EditorUtil.PIXEL_TYPE, Font.BOLD, size);
    value = UIUtilities.createComponent(null);
    value.setText((String) details.get(EditorUtil.PIXEL_TYPE));
    c.gridx = 0;
    content.add(label, c);
    c.gridx = c.gridx + 2;
    content.add(value, c);

    value = UIUtilities.createComponent(null);
    String s = formatPixelsSize(details, value);
    if (s != null) {
        c.gridy++;
        label = UIUtilities.setTextFont(s, Font.BOLD, size);
        c.gridx = 0;
        content.add(label, c);
        c.gridx = c.gridx + 2;
        content.add(value, c);
    }
    //parse modulo T.
    Map<Integer, ModuloInfo> modulo = model.getModulo();
    ModuloInfo moduloT = modulo.get(ModuloInfo.T);
    c.gridy++;
    label = UIUtilities.setTextFont(EditorUtil.Z_T_FIELDS, Font.BOLD, size);
    value = UIUtilities.createComponent(null);
    v = (String) details.get(EditorUtil.SECTIONS);
    v += " x ";
    if (moduloT != null) {
        String time = (String) details.get(EditorUtil.TIMEPOINTS);
        int t = Integer.parseInt(time);
        v += "" + (t / moduloT.getSize());
    } else {
        v += (String) details.get(EditorUtil.TIMEPOINTS);
    }
    value.setText(v);
    c.gridx = 0;
    content.add(label, c);
    c.gridx = c.gridx + 2;
    content.add(value, c);
    c.gridy++;
    if (moduloT != null) {
        label = UIUtilities.setTextFont(EditorUtil.SMALL_T_VARIABLE, Font.BOLD, size);
        value = UIUtilities.createComponent(null);
        value.setText("" + moduloT.getSize());
        c.gridx = 0;
        content.add(label, c);
        c.gridx = c.gridx + 2;
        content.add(value, c);
        c.gridy++;
    }
    if (!model.isNumerousChannel() && model.getRefObjectID() > 0) {
        label = UIUtilities.setTextFont(EditorUtil.CHANNELS, Font.BOLD, size);
        c.gridx = 0;
        c.anchor = GridBagConstraints.NORTHEAST;
        content.add(label, c);
        c.anchor = GridBagConstraints.CENTER;
        c.gridx++;
        content.add(editChannel, c);
        c.gridx++;
        content.add(channelsPane, c);
    }
    JPanel p = UIUtilities.buildComponentPanel(content);
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    return p;
}

From source file:org.pentaho.reporting.ui.datasources.kettle.KettleDataSourceDialog.java

protected Component createContentPane() {
    final JPanel previewAndParameterPanel = createTransformParameterPanel();
    final JPanel queryListPanel = createQueryListPanel();

    final JPanel mainPanel = new JPanel(new GridBagLayout());
    mainPanel.setBorder(new EmptyBorder(5, 5, 0, 5));
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;//from  w ww  . j  a v a 2  s.  c  o  m
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.WEST;
    mainPanel.add(new JLabel(Messages.getString("KettleDataSourceDialog.QueryName")), gbc);

    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.weightx = 1;
    mainPanel.add(nameTextField, gbc);

    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 3;
    gbc.gridwidth = 3;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 1;
    gbc.weighty = 1;
    gbc.anchor = GridBagConstraints.WEST;
    mainPanel.add(createDatasourcePanel(), gbc);

    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.gridwidth = 3;
    gbc.anchor = GridBagConstraints.WEST;
    mainPanel.add(previewAndParameterPanel, gbc);

    final JSplitPane panel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    panel.setLeftComponent(queryListPanel);
    panel.setRightComponent(mainPanel);
    panel.setDividerLocation(250);
    return panel;
}

From source file:com.rapidminer.gui.new_plotter.gui.ColorSchemeDialog.java

/**
 * @return//  www .  j a va2 s .com
 */
private JPanel createColorCategoriesPanel() {
    JPanel categoryColorsConfigurationPanel = new JPanel(new GridBagLayout());
    categoryColorsConfigurationPanel.setPreferredSize(new Dimension(180, 200));

    GridBagConstraints itemConstraint = new GridBagConstraints();

    JLabel categoryColorsLabel = new ResourceLabel(
            "plotter.configuration_dialog.color_scheme_dialog.category_colors");
    {

        itemConstraint.fill = GridBagConstraints.HORIZONTAL;
        itemConstraint.anchor = GridBagConstraints.WEST;
        itemConstraint.gridwidth = GridBagConstraints.RELATIVE;
        itemConstraint.insets = new Insets(0, 5, 5, 5);
        itemConstraint.weightx = 1.0;

        categoryColorsConfigurationPanel.add(categoryColorsLabel, itemConstraint);
    }

    // add button panel
    {
        JPanel buttonPanel = new JPanel(new GridBagLayout());

        // remove scheme button
        {
            removeCategoryColorButton = new JButton(new ResourceAction(true,
                    "plotter.configuration_dialog.color_scheme_dialog.remove_category_color_button") {

                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    removeSelectedColorAction();
                }

            });

            itemConstraint = new GridBagConstraints();
            itemConstraint.gridwidth = GridBagConstraints.RELATIVE;
            itemConstraint.fill = GridBagConstraints.NONE;

            buttonPanel.add(removeCategoryColorButton, itemConstraint);
        }

        {
            addCategoryButton = new JButton(new ResourceAction(true,
                    "plotter.configuration_dialog.color_scheme_dialog.add_category_color_button") {

                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    Color oldColor = Color.white;
                    Color newSchemeColor = createColorDialog(oldColor);
                    if (newSchemeColor != null && !newSchemeColor.equals(oldColor)) {
                        addColorAction(newSchemeColor);
                    }
                }

            });

            itemConstraint = new GridBagConstraints();
            itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
            itemConstraint.fill = GridBagConstraints.NONE;

            buttonPanel.add(addCategoryButton, itemConstraint);

        }

        itemConstraint = new GridBagConstraints();
        itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
        itemConstraint.fill = GridBagConstraints.NONE;
        itemConstraint.anchor = GridBagConstraints.EAST;
        itemConstraint.insets = new Insets(0, 5, 5, 5);

        categoryColorsConfigurationPanel.add(buttonPanel, itemConstraint);
    }

    {

        JPanel categoryListPanel = new JPanel(new GridBagLayout());

        // add list of categorie colors
        {

            colorList = new JList<Color>(nominalColorListModel);
            categoryColorsLabel.setLabelFor(colorList);
            colorList.setCellRenderer(new ColorListCellRenderer());
            colorList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

            MouseAdapter ma = new MouseAdapter() {

                private void myPopupEvent(MouseEvent e) {
                    int x = e.getX();
                    int y = e.getY();
                    JList<?> list = (JList<?>) e.getSource();
                    list.setSelectedIndex(list.locationToIndex(e.getPoint()));
                    Color selectedColor = (Color) list.getSelectedValue();
                    if (selectedColor == null) {
                        return;
                    }

                    removeMenuItem.setEnabled(nominalColorListModel.getSize() > 2);

                    popupMenu.show(list, x, y);
                }

                @Override
                public void mousePressed(MouseEvent e) {
                    if (e.isPopupTrigger()) {
                        myPopupEvent(e);
                    }
                }

                @Override
                public void mouseReleased(MouseEvent e) {
                    if (e.isPopupTrigger()) {
                        myPopupEvent(e);
                    }
                }
            };

            colorList.addMouseListener(ma);
            colorList.addKeyListener(new KeyListener() {

                @Override
                public void keyTyped(KeyEvent e) {
                    return; // Nothing to be done
                }

                @Override
                public void keyReleased(KeyEvent e) {
                    return; // Nothing to be done
                }

                @Override
                public void keyPressed(KeyEvent e) {
                    int key = e.getKeyCode();
                    if (key == KeyEvent.VK_DELETE) {
                        if (nominalColorListModel.getSize() > 2) {
                            removeSelectedColorAction();
                        }
                    }
                    if (key == KeyEvent.VK_F2) {
                        replaceSelectedColorAction();
                    }
                    if (key == KeyEvent.VK_UP && SwingTools.isControlOrMetaDown(e)) {
                        moveSelectedColorUpAction();
                    }
                    if (key == KeyEvent.VK_DOWN && SwingTools.isControlOrMetaDown(e)) {
                        moveSelectedColorDownAction();
                    }
                }
            });

            colorListScrollPane = new JScrollPane(colorList);
            colorListScrollPane.setPreferredSize(new Dimension(170, 200));
            colorListScrollPane.setMaximumSize(new Dimension(170, 200));
            colorListScrollPane.setMinimumSize(new Dimension(170, 180));
            colorListScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            colorListScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

            itemConstraint = new GridBagConstraints();
            itemConstraint.fill = GridBagConstraints.BOTH;
            itemConstraint.weightx = 0.0;
            itemConstraint.weighty = 0.5;
            itemConstraint.gridwidth = GridBagConstraints.RELATIVE;

            categoryListPanel.add(colorListScrollPane, itemConstraint);
        }

        // add up/down button panel
        {

            JPanel upAndDownButtonPanel = new JPanel(new GridBagLayout());

            // add up button
            {
                JButton upButton = new JButton(
                        new ResourceAction(true, "plotter.configuration_dialog.move_color_up") {

                            private static final long serialVersionUID = 1L;

                            @Override
                            public void actionPerformed(ActionEvent e) {
                                moveSelectedColorUpAction();
                            }
                        });

                itemConstraint = new GridBagConstraints();
                itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
                itemConstraint.weightx = 0;
                itemConstraint.weighty = 0;
                itemConstraint.fill = GridBagConstraints.NONE;
                itemConstraint.insets = new Insets(0, 2, 0, 12);

                upAndDownButtonPanel.add(upButton, itemConstraint);
            }

            // add down button
            {
                JButton downButton = new JButton(
                        new ResourceAction(true, "plotter.configuration_dialog.move_color_down") {

                            private static final long serialVersionUID = 1L;

                            @Override
                            public void actionPerformed(ActionEvent e) {
                                moveSelectedColorDownAction();
                            }
                        });

                itemConstraint = new GridBagConstraints();
                itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
                itemConstraint.weightx = 0;
                itemConstraint.weighty = 0;
                itemConstraint.fill = GridBagConstraints.NONE;
                itemConstraint.insets = new Insets(0, 2, 0, 12);

                upAndDownButtonPanel.add(downButton, itemConstraint);
            }

            // add spacer panel
            {
                JPanel spacer = new JPanel();

                itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
                itemConstraint.weightx = 0;
                itemConstraint.weighty = 1;
                itemConstraint.fill = GridBagConstraints.VERTICAL;

                upAndDownButtonPanel.add(spacer, itemConstraint);

            }

            itemConstraint = new GridBagConstraints();
            itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
            itemConstraint.weightx = 1;
            itemConstraint.weighty = 1;
            itemConstraint.fill = GridBagConstraints.VERTICAL;

            categoryListPanel.add(upAndDownButtonPanel, itemConstraint);

        }

        itemConstraint = new GridBagConstraints();
        itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
        itemConstraint.weightx = 1;
        itemConstraint.weighty = 1;
        itemConstraint.fill = GridBagConstraints.BOTH;

        categoryColorsConfigurationPanel.add(categoryListPanel, itemConstraint);
    }

    return categoryColorsConfigurationPanel;
}

From source file:de.tor.tribes.ui.views.DSWorkbenchTagFrame.java

/** This method is called from within the constructor to
 * initialize the form./*  ww  w. j a va2s .  c o  m*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;

    jTagsPanel = new javax.swing.JPanel();
    jTagTablePanel = new org.jdesktop.swingx.JXPanel();
    infoPanel = new org.jdesktop.swingx.JXCollapsiblePane();
    jXLabel1 = new org.jdesktop.swingx.JXLabel();
    jScrollPane4 = new javax.swing.JScrollPane();
    villageListPanel = new javax.swing.JPanel();
    jScrollPane5 = new javax.swing.JScrollPane();
    jVillageList = new javax.swing.JList();
    jAlwaysOnTopBox = new javax.swing.JCheckBox();
    jTagPanel = new org.jdesktop.swingx.JXPanel();
    capabilityInfoPanel1 = new de.tor.tribes.ui.components.CapabilityInfoPanel();

    jTagsPanel.setLayout(new java.awt.BorderLayout(10, 0));

    jTagTablePanel.setLayout(new java.awt.BorderLayout());

    infoPanel.setCollapsed(true);
    infoPanel.setInheritAlpha(false);

    jXLabel1.setText("Keine Meldung");
    jXLabel1.setOpaque(true);
    jXLabel1.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseReleased(java.awt.event.MouseEvent evt) {
            jXLabel1fireHideInfoEvent(evt);
        }
    });
    infoPanel.add(jXLabel1, java.awt.BorderLayout.CENTER);

    jTagTablePanel.add(infoPanel, java.awt.BorderLayout.SOUTH);

    jTagsTable
            .setModel(new javax.swing.table.DefaultTableModel(
                    new Object[][] { { null, null, null, null }, { null, null, null, null },
                            { null, null, null, null }, { null, null, null, null } },
                    new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
    jScrollPane4.setViewportView(jTagsTable);

    jTagTablePanel.add(jScrollPane4, java.awt.BorderLayout.CENTER);

    jTagsPanel.add(jTagTablePanel, java.awt.BorderLayout.CENTER);

    villageListPanel.setPreferredSize(new java.awt.Dimension(180, 80));
    villageListPanel.setLayout(new java.awt.BorderLayout());

    jScrollPane5.setBorder(javax.swing.BorderFactory.createTitledBorder("Zugeordnete Drfer"));

    jScrollPane5.setViewportView(jVillageList);

    villageListPanel.add(jScrollPane5, java.awt.BorderLayout.CENTER);

    jTagsPanel.add(villageListPanel, java.awt.BorderLayout.WEST);

    setTitle("Gruppen");
    getContentPane().setLayout(new java.awt.GridBagLayout());

    jAlwaysOnTopBox.setText("Immer im Vordergrund");
    jAlwaysOnTopBox.setOpaque(false);
    jAlwaysOnTopBox.addItemListener(new java.awt.event.ItemListener() {
        public void itemStateChanged(java.awt.event.ItemEvent evt) {
            fireAlwaysOnTopEvent(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    getContentPane().add(jAlwaysOnTopBox, gridBagConstraints);

    jTagPanel.setBackground(new java.awt.Color(239, 235, 223));
    jTagPanel.setPreferredSize(new java.awt.Dimension(500, 300));
    jTagPanel.setLayout(new java.awt.BorderLayout());
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    getContentPane().add(jTagPanel, gridBagConstraints);

    capabilityInfoPanel1.setCopyable(false);
    capabilityInfoPanel1.setSearchable(false);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    getContentPane().add(capabilityInfoPanel1, gridBagConstraints);

    pack();
}

From source file:org.photovault.swingui.PhotoInfoEditor.java

private void addLabelTextRows(JLabel[] labels, JComponent[] textFields, GridBagLayout gridbag,
        Container container) {/*from www .  j a v  a2  s  . c o  m*/
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.EAST;
    c.insets = new Insets(2, 2, 2, 2);
    int numLabels = labels.length;

    for (int i = 0; i < numLabels; i++) {
        c.anchor = GridBagConstraints.EAST;
        c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
        c.fill = GridBagConstraints.NONE; //reset to default
        c.weightx = 0.0; //reset to default
        gridbag.setConstraints(labels[i], c);
        container.add(labels[i]);

        c.anchor = GridBagConstraints.WEST;
        c.gridwidth = GridBagConstraints.REMAINDER; //end row
        c.weightx = 1.0;
        gridbag.setConstraints(textFields[i], c);
        container.add(textFields[i]);
    }
}

From source file:us.paulevans.basicxslt.BasicXSLTFrame.java

/**
 * Builds the auto-save panel//from   w  w w.  ja va 2s. c  om
 * @return
 */
private JPanel buildAutosavePanel() {

    int row;
    JPanel buttons;
    JPanel autosavePanel;

    row = 0;
    buttons = new JPanel(new FlowLayout(FlowLayout.LEFT));
    buttons.add(addXslBtn = new JButton(stringFactory.getString(LabelStringFactory.MAIN_FRAME_ADD_XSL_BTN)));
    buttons.add(removeCheckedBtn = new JButton(
            stringFactory.getString(LabelStringFactory.MAIN_FRAME_REMOVE_CHECKED_BTN)));
    addXslBtn.addActionListener(this);
    removeCheckedBtn.addActionListener(this);
    autosavePanel = new JPanel(xslPanelLayout);
    GUIUtils.add(autosavePanel, buttons, xslPanelLayout, xslPanelConstraints, row++, 0, 1, 3,
            GridBagConstraints.WEST, GridBagConstraints.NONE, GUIUtils.SMALL_INSETS);
    GUIUtils.add(autosavePanel,
            new JLabel(stringFactory.getString(LabelStringFactory.MAIN_FRAME_AUTOSAVERESULT)), xslPanelLayout,
            xslPanelConstraints, row, 0, 1, 1, GridBagConstraints.EAST, GridBagConstraints.NONE,
            GUIUtils.SMALL_INSETS);
    GUIUtils.add(autosavePanel, autosaveCb = new JCheckBox(), xslPanelLayout, xslPanelConstraints, row, 1, 1, 1,
            GridBagConstraints.WEST, GridBagConstraints.NONE, GUIUtils.SMALL_INSETS);
    autosaveCb.addActionListener(this);
    GUIUtils.add(autosavePanel, autosavePathTf = new JTextField(AppConstants.TF_LENGTH - 4), xslPanelLayout,
            xslPanelConstraints, row, 2, 1, 1, GridBagConstraints.EAST, GridBagConstraints.NONE,
            GUIUtils.SMALL_INSETS);
    GUIUtils.add(autosavePanel,
            browseAutosavePathBtn = new JButton(
                    stringFactory.getString(LabelStringFactory.MAIN_FRAME_BROWSE_BTN)),
            xslPanelLayout, xslPanelConstraints, row, 3, 1, 1, GridBagConstraints.EAST, GridBagConstraints.NONE,
            GUIUtils.SMALL_INSETS);
    GUIUtils.add(autosavePanel,
            validateAutosaveBtn = new JButton(
                    stringFactory.getString(LabelStringFactory.MAIN_FRAME_VALIDATE_BTN)),
            xslPanelLayout, xslPanelConstraints, row++, 4, 1, 1, GridBagConstraints.EAST,
            GridBagConstraints.NONE, GUIUtils.SMALL_INSETS);
    validateAutosaveBtn.addActionListener(this);
    GUIUtils.add(autosavePanel,
            new JLabel(stringFactory.getString(LabelStringFactory.MAIN_FRAME_SUPRESS_OUTPUT_WINDOW)),
            xslPanelLayout, xslPanelConstraints, row, 0, 1, 1, GridBagConstraints.EAST, GridBagConstraints.NONE,
            GUIUtils.SMALL_INSETS);
    GUIUtils.add(autosavePanel, suppressOutputWindowCb = new JCheckBox(), xslPanelLayout, xslPanelConstraints,
            row++, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.NONE, GUIUtils.SMALL_INSETS);
    GUIUtils.add(autosavePanel,
            outputAsTextIfXmlLabel = new JLabel(
                    stringFactory.getString(LabelStringFactory.MAIN_FRAME_DISPLAY_OUTPUT_AS_TEXT_IF_XML)),
            xslPanelLayout, xslPanelConstraints, row, 0, 1, 1, GridBagConstraints.EAST, GridBagConstraints.NONE,
            GUIUtils.SMALL_INSETS);
    GUIUtils.add(autosavePanel, outputAsTextIfXml = new JCheckBox(), xslPanelLayout, xslPanelConstraints, row++,
            1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.NONE, GUIUtils.SMALL_INSETS);
    suppressOutputWindowCb.addActionListener(this);
    return autosavePanel;
}

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

/**
 * This method initializes jPanel   /*from  w  ww .  ja v  a 2  s.  c o m*/
 *    
 * @return javax.swing.JPanel   
 */
public JPanel getJPanelFolder() {
    if (jPanelFolder == null) {
        GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
        gridBagConstraints8.anchor = GridBagConstraints.EAST;
        gridBagConstraints8.gridwidth = 1;
        gridBagConstraints8.gridx = 0;
        gridBagConstraints8.gridy = 0;
        gridBagConstraints8.weightx = 1.0;
        gridBagConstraints8.weighty = 0.0;
        gridBagConstraints8.insets = new Insets(0, 10, 0, 3);
        GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
        gridBagConstraints6.anchor = GridBagConstraints.WEST;
        gridBagConstraints6.insets = new Insets(5, 0, 5, 10);
        gridBagConstraints6.gridx = 1;
        gridBagConstraints6.gridy = 0;
        gridBagConstraints6.weightx = 1.0;
        gridBagConstraints6.fill = GridBagConstraints.VERTICAL;
        GridBagConstraints gridBagConstraints66 = new GridBagConstraints();
        gridBagConstraints66.anchor = GridBagConstraints.WEST;
        gridBagConstraints66.insets = new Insets(5, 0, 5, 10);
        gridBagConstraints66.gridx = 2;
        gridBagConstraints66.gridy = -1;
        gridBagConstraints66.weightx = 1.0;
        gridBagConstraints66.fill = GridBagConstraints.VERTICAL;

        GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
        gridBagConstraints10.anchor = GridBagConstraints.EAST;
        gridBagConstraints10.gridx = 0;
        gridBagConstraints10.gridy = 1;
        gridBagConstraints10.weightx = 0.0;
        gridBagConstraints10.insets = new Insets(0, 0, 0, 3);
        GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
        gridBagConstraints7.anchor = GridBagConstraints.WEST;
        gridBagConstraints7.insets = new Insets(0, 0, 5, 0);
        gridBagConstraints7.gridx = 1;
        gridBagConstraints7.gridy = 1;
        gridBagConstraints7.weightx = 1.0;
        gridBagConstraints7.fill = GridBagConstraints.VERTICAL;

        jPanelFolder = new JPanel();
        jPanelFolder.setLayout(new GridBagLayout());
        jPanelFolder.add(jLabelComponent, gridBagConstraints8);
        jPanelFolder.add(getJComboBoxComponent(), gridBagConstraints6);

        jPanelFolder.add(jLabelLicense, gridBagConstraints10);
        jPanelFolder.add(getJComboBoxLicense(), gridBagConstraints7);
    }
    return jPanelFolder;
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.AnnotationDataUI.java

/**
 * Lays out the other annotations.//ww  w . ja va 2  s .  c  om
 * 
 * @param list The collection of annotation to layout.
 */
private void layoutOthers(Collection list) {
    otherPane.removeAll();
    otherList.clear();
    DocComponent doc;

    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(1, 2, 1, 2);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;

    if (!CollectionUtils.isEmpty(list)) {

        Iterator i = list.iterator();
        while (i.hasNext()) {

            c.gridx = 0;
            c.weightx = 0;
            c.fill = GridBagConstraints.NONE;

            DataObject item = (DataObject) i.next();
            if (filter == SHOW_ALL || (filter == ADDED_BY_ME && model.isLinkOwner(item))
                    || (filter == ADDED_BY_OTHERS && model.isAnnotatedByOther(item))) {
                doc = new DocComponent(item, model);
                doc.addPropertyChangeListener(controller);

                otherList.add(doc);

                otherPane.add(new JLabel(getType((AnnotationData) item) + ":"), c);

                c.gridx = 1;
                c.weightx = 1;
                c.fill = GridBagConstraints.HORIZONTAL;
                otherPane.add(doc, c);

                c.gridy++;
            }

        }
    }

    otherPane.revalidate();
    otherPane.repaint();
}