Example usage for javax.swing Box createVerticalStrut

List of usage examples for javax.swing Box createVerticalStrut

Introduction

In this page you can find the example usage for javax.swing Box createVerticalStrut.

Prototype

public static Component createVerticalStrut(int height) 

Source Link

Document

Creates an invisible, fixed-height component.

Usage

From source file:org.openmicroscopy.shoola.util.ui.omeeditpane.OMEWikiComponent.java

/** Builds and lays out the UI. */
private void buildGUI() {
    //setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    if (toolBar != null) {
        JPanel p = new JPanel();
        p.setBackground(UIUtilities.BACKGROUND_COLOR);
        p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
        p.add(Box.createVerticalStrut(5));
        JPanel bar = UIUtilities.buildComponentPanel(toolBar, 0, 0);
        bar.setBackground(UIUtilities.BACKGROUND_COLOR);
        p.add(bar);//ww  w.j a  v a 2s  . c o m
        p.add(Box.createVerticalStrut(2));
        add(p, BorderLayout.NORTH);
    }
    setLayout(new BorderLayout());
    add(pane, BorderLayout.CENTER);
}

From source file:org.ecoinformatics.seek.ecogrid.EcogridPreferencesTab.java

/**
 * Description of the Method/*  w  w w  . ja  v a  2  s.co  m*/
 */
private void initTextPanel() {
    // text part of text panel
    JPanel textTopPanel = new JPanel();
    textTopPanel.setLayout(new BoxLayout(textTopPanel, BoxLayout.X_AXIS));
    textTopPanel.add(textLabel);
    textTopPanel.add(Box.createHorizontalGlue());
    // y box layout
    textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS));
    textPanel.add(textTopPanel);
    textPanel.add(Box.createVerticalStrut(GAP));
}

From source file:org.ut.biolab.medsavant.client.view.Menu.java

public void addSection(SectionView section) {

    final JPanel sectionPanel = ViewUtil.getClearPanel();
    sectionPanel.setLayout(new BoxLayout(sectionPanel, BoxLayout.Y_AXIS));
    sectionPanel.setVisible(false);/*from  w ww.j a  va 2s .  c  o  m*/

    //HoverButton sectionButton = new SectionButton(section, sectionPanel);
    //sectionButton.setSelectedColor(ViewUtil.getSecondaryMenuColor());

    final JToggleButton sectionButton = ViewUtil.getTogglableIconButton(section.getIcon());
    sectionButton.setName(section.getName());
    sectionButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
    sectionButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            primaryMenuButtons.setSelected(sectionButton.getModel(), true);
            if (previousSectionPanel != null) {
                previousSectionPanel.setVisible(false);
            }
            // Act as if we clicked the first sub-section button.
            ((SubSectionButton) sectionPanel.getComponent(0)).subSectionClicked();
            sectionPanel.setVisible(true);

            previousSectionPanel = sectionPanel;
            primaryMenu.invalidate();
        }
    });

    ButtonGroup subSectionsGroup = new ButtonGroup();

    for (SubSectionView v : section.getSubSections()) {
        subSectionViews.add(v);

        SubSectionButton subSectionButton = new SubSectionButton(v, subSectionsGroup);
        sectionPanel.add(subSectionButton);
        subSectionsGroup.add(subSectionButton);

        map.put(v, subSectionButton);
    }

    primaryMenuButtons.add(sectionButton);

    sectionPanel.add(Box.createVerticalStrut(50));

    secondaryMenu.add(sectionPanel);

    primaryMenuSectionButtonContainer.add(ViewUtil.subTextComponent(sectionButton, section.getName()));
    primaryMenuSectionButtonContainer.add(ViewUtil.getLargeSeparator());

}

From source file:diet.gridr.g5k.gui.GanttChart.java

/**
 * Method returning the TablePanel//from  ww  w .j av  a 2 s.  c  om
 *
 * @return the table panel
 */
private JPanel getTablePanel() {
    tablePanel = new JPanel();
    tablePanel.setLayout(new BoxLayout(tablePanel, BoxLayout.Y_AXIS));
    tablePanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10));
    jobsTable = new JTable();
    jobsModel = new ClusterJobsSummaryModel();
    jobsTable.setModel(jobsModel);
    ClusterJobsSummaryCellRenderer renderer = new ClusterJobsSummaryCellRenderer();
    jobsTable.setDefaultRenderer(String.class, renderer);
    JLabel jobsTableTitle = new JLabel("Jobs status");
    jobsTableTitle.setAlignmentX(JLabel.CENTER_ALIGNMENT);
    jobsTableTitle.setFont(new Font("Dialog", Font.BOLD, 14));
    tablePanel.add(Box.createVerticalStrut(5));
    tablePanel.add(jobsTableTitle);
    tablePanel.add(Box.createVerticalStrut(10));
    tablePanel.add(jobsTable.getTableHeader());
    tablePanel.add(jobsTable);
    LoggingManager.log(Level.FINE, LoggingManager.RESOURCESTOOL, this.getClass().getName(), "getTablePanel",
            "TablePanel constructed");
    return tablePanel;
}

From source file:org.ut.biolab.medsavant.client.view.genetics.TablePanel.java

private void updateSummary() {
    try {//from  w w  w. j  a v a2s.  c om
        int numPassingVariants = ResultController.getInstance().getFilteredVariantCount();

        System.out.println("Num passing " + numPassingVariants + " " + (new Date()).toLocaleString());

        final JPanel blockPanel = new JPanel();
        ViewUtil.applyVerticalBoxLayout(blockPanel);

        ringChart = new RingChart();
        int ringDiameter = 200;
        ringChart.setMinimumSize(new Dimension(ringDiameter, ringDiameter));
        ringChart.setMaximumSize(new Dimension(ringDiameter, ringDiameter));
        ringChart.setPreferredSize(new Dimension(ringDiameter, ringDiameter));
        Ring r1 = new Ring();
        r1.addItem("Pass all filters", numPassingVariants, new Color(72, 181, 249));
        r1.addItem("Don't pass filters",
                ResultController.getInstance().getTotalVariantCount() - numPassingVariants, Color.gray);
        r1.setRingWidth(4);

        ringChart.setRings(Arrays.asList(r1));

        JButton b = ViewUtil.getSoftButton("Load Spreadsheet");

        b.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {

                updateRequired = true;

                showWaitCard();
                setActivePanel(true);

                if (searchableTablePanel == null) {
                    new TableInitializer().execute();
                } else {
                    updateTableIfRequired();
                }
            }
        });

        FilterEffectivenessPanel fep = new FilterEffectivenessPanel();

        blockPanel.add(ViewUtil.centerHorizontally(ringChart));
        blockPanel.add(Box.createVerticalStrut(5));
        blockPanel.add(fep);
        blockPanel.add(Box.createVerticalStrut(5));
        blockPanel.add(ViewUtil.centerHorizontally(b));

        JPanel centered = ViewUtil.getClearPanel();
        ViewUtil.applyVerticalBoxLayout(centered);
        centered.add(Box.createVerticalGlue());
        centered.add(blockPanel);
        centered.add(Box.createVerticalGlue());

        summaryContainer.removeAll();
        summaryContainer.add(ViewUtil.centerHorizontally(centered), BorderLayout.CENTER);

    } catch (Exception ex) {
        LOG.error(TablePanel.class, ex);
    }

}

From source file:pcgen.gui2.tabs.EquipInfoTab.java

private void initComponents() {
    FontManipulation.small(newSetButton);
    newSetButton.setMargin(new Insets(0, 0, 0, 0));
    FontManipulation.small(removeSetButton);
    removeSetButton.setMargin(new Insets(0, 0, 0, 0));

    exportTemplateButton.setText(LanguageBundle.getString("in_equipExportTemplate")); //$NON-NLS-1$
    viewBrowserButton.setText(LanguageBundle.getString("in_equipViewBrowser")); //$NON-NLS-1$
    exportFileButton.setText(LanguageBundle.getString("in_equipExportFile")); //$NON-NLS-1$
    setNoteButton.setText(LanguageBundle.getString("in_equipSetNote")); //$NON-NLS-1$

    setOrientation(HORIZONTAL_SPLIT);//from  ww w . ja va 2s . c  o m
    FlippingSplitPane splitPane = new FlippingSplitPane(VERTICAL_SPLIT, "EquipMain");

    JPanel panel = new JPanel(new BorderLayout());

    Box bar = Box.createHorizontalBox();
    bar.add(Box.createHorizontalStrut(5));
    bar.add(new JLabel(LanguageBundle.getString("in_equipView"))); //$NON-NLS-1$
    bar.add(Box.createHorizontalStrut(5));
    bar.add(equipViewBox);
    bar.add(Box.createHorizontalStrut(5));
    tableFilter = new SearchFilterPanel();
    bar.add(tableFilter.getFilterComponent());
    bar.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
    panel.add(bar, BorderLayout.NORTH);

    equipmentTable.setAutoCreateColumnsFromModel(false);
    equipmentTable.setColumnModel(createEquipmentColumnModel());
    equipmentTable.setAutoCreateRowSorter(true);
    panel.add(new JScrollPane(equipmentTable), BorderLayout.CENTER);

    Box buttonsBox = Box.createHorizontalBox();
    buttonsBox.add(Box.createHorizontalGlue());
    equipButton.setHorizontalTextPosition(SwingConstants.LEADING);
    buttonsBox.add(equipButton);
    buttonsBox.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    panel.add(buttonsBox, BorderLayout.SOUTH);

    splitPane.setTopComponent(panel);
    splitPane.setBottomComponent(infoPane);

    setLeftComponent(splitPane);

    panel = new JPanel(new BorderLayout());

    Box equipPane = Box.createVerticalBox();
    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    box.add(new JLabel(LanguageBundle.getString("in_equipSetLabel"))); //$NON-NLS-1$
    box.add(Box.createHorizontalStrut(3));
    box.add(equipSetBox);
    box.add(Box.createHorizontalStrut(3));
    box.add(newSetButton);
    box.add(Box.createHorizontalStrut(3));
    box.add(removeSetButton);
    box.add(Box.createHorizontalGlue());
    box.add(new JLabel(LanguageBundle.getString("in_equipWeightLabel"))); //$NON-NLS-1$
    box.add(Box.createHorizontalStrut(5));
    box.add(weightLabel);
    box.add(Box.createHorizontalGlue());
    box.add(new JLabel(LanguageBundle.getString("in_equipLoadLabel"))); //$NON-NLS-1$
    box.add(Box.createHorizontalStrut(5));
    box.add(loadLabel);
    box.add(Box.createHorizontalStrut(5));
    box.add(limitLabel);
    box.add(Box.createHorizontalGlue());

    equipPane.add(Box.createVerticalStrut(3));
    equipPane.add(box);
    equipPane.add(Box.createVerticalStrut(3));

    box = Box.createHorizontalBox();
    box.add(exportTemplateButton);
    exportTemplateButton.setEnabled(false);
    box.add(Box.createHorizontalStrut(3));
    box.add(viewBrowserButton);
    viewBrowserButton.setEnabled(false);
    box.add(Box.createHorizontalStrut(3));
    box.add(exportFileButton);
    exportFileButton.setEnabled(false);
    box.add(Box.createHorizontalStrut(3));
    box.add(setNoteButton);
    setNoteButton.setEnabled(false);
    box.add(Box.createHorizontalStrut(3));
    box.add(expandAllButton);
    box.add(Box.createHorizontalStrut(3));
    box.add(collapseAllButton);
    equipPane.add(box);
    equipPane.add(Box.createVerticalStrut(3));

    panel.add(equipPane, BorderLayout.NORTH);

    EquipmentModel.initializeTreeTable(equipmentSetTable);
    panel.add(new JScrollPane(equipmentSetTable), BorderLayout.CENTER);

    Box selPanelbuttonsBox = Box.createHorizontalBox();
    selPanelbuttonsBox.add(Box.createHorizontalStrut(3));
    selPanelbuttonsBox.add(unequipButton);
    selPanelbuttonsBox.add(Box.createHorizontalStrut(3));
    selPanelbuttonsBox.add(unequipAllButton);
    selPanelbuttonsBox.add(Box.createHorizontalStrut(3));
    selPanelbuttonsBox.add(moveUpButton);
    selPanelbuttonsBox.add(Box.createHorizontalStrut(3));
    selPanelbuttonsBox.add(moveDownButton);
    selPanelbuttonsBox.add(Box.createHorizontalGlue());
    selPanelbuttonsBox.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    panel.add(selPanelbuttonsBox, BorderLayout.SOUTH);
    setRightComponent(panel);
}

From source file:org.eobjects.datacleaner.panels.WelcomePanel.java

@Inject
protected WelcomePanel(AnalyzerBeansConfiguration configuration,
        AnalysisJobBuilderWindow analysisJobBuilderWindow, DCGlassPane glassPane,
        Provider<OptionsDialog> optionsDialogProvider, InjectorBuilder injectorBuilder,
        OpenAnalysisJobActionListener openAnalysisJobActionListener,
        DatabaseDriverCatalog databaseDriverCatalog, UserPreferences userPreferences) {
    super();/*from  ww w  .  j a  va2 s  . c  om*/
    _openAnalysisJobActionListener = openAnalysisJobActionListener;
    _configuration = configuration;
    _datastorePanels = new ArrayList<DatastorePanel>();
    _datastoreCatalog = (MutableDatastoreCatalog) configuration.getDatastoreCatalog();
    _analysisJobBuilderWindow = analysisJobBuilderWindow;
    _glassPane = glassPane;
    _optionsDialogProvider = optionsDialogProvider;
    _injectorBuilder = injectorBuilder;
    _databaseDriverCatalog = databaseDriverCatalog;
    _userPreferences = userPreferences;

    _browseJobsButton = new JButton("Browse jobs",
            imageManager.getImageIcon(IconUtils.MENU_OPEN, IconUtils.ICON_SIZE_SMALL));
    _browseJobsButton.setMargin(new Insets(1, 1, 1, 4));
    _browseJobsButton.addActionListener(openAnalysisJobActionListener);

    // initialize "analyze" button
    _analyzeButton = new JButton("Build job",
            imageManager.getImageIcon(IconUtils.MODEL_JOB, IconUtils.ICON_SIZE_SMALL));
    _analyzeButton.setMargin(new Insets(1, 1, 1, 1));
    _analyzeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            for (DatastorePanel datastorePanel : _datastorePanels) {
                if (datastorePanel.isSelected()) {
                    Datastore datastore = datastorePanel.getDatastore();

                    // open the connection here, to make any connection
                    // issues apparent early
                    try (DatastoreConnection datastoreConnection = datastore.openConnection()) {
                        datastoreConnection.getDataContext().getSchemaNames();
                        _analysisJobBuilderWindow.setDatastore(datastore);
                    }
                    return;
                }
            }
        }
    });

    // initialize search text field
    _searchDatastoreTextField = WidgetFactory.createTextField("Search/filter datastores");
    _searchDatastoreTextField
            .setBorder(new CompoundBorder(new EmptyBorder(4, 0, 0, 0), WidgetUtils.BORDER_THIN));
    _searchDatastoreTextField.setOpaque(false);
    _searchDatastoreTextField.getDocument().addDocumentListener(new DCDocumentListener() {
        @Override
        protected void onChange(DocumentEvent event) {
            String text = _searchDatastoreTextField.getText();
            if (StringUtils.isNullOrEmpty(text)) {
                // when there is no search query, set all datastores
                // visible
                for (DatastorePanel datastorePanel : _datastorePanels) {
                    datastorePanel.setVisible(true);
                }
            } else {
                // do a case insensitive search
                text = text.trim().toLowerCase();
                for (DatastorePanel datastorePanel : _datastorePanels) {
                    String name = datastorePanel.getDatastore().getName().toLowerCase();
                    datastorePanel.setVisible(name.indexOf(text) != -1);
                }
                selectFirstVisibleDatastore();
            }
        }
    });
    _searchDatastoreTextField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                clickAnalyzeButton();
            } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
                selectNextVisibleDatastore();
            } else if (e.getKeyCode() == KeyEvent.VK_UP) {
                selectPreviousVisibleDatastore();
            }
        }
    });

    setLayout(new VerticalLayout(4));

    add(Box.createVerticalStrut(10));

    final DCLabel jobsHeaderLabel = DCLabel.dark("Jobs");
    jobsHeaderLabel.setFont(WidgetUtils.FONT_HEADER1);
    add(jobsHeaderLabel);

    _jobsListPanel = new DCPanel();
    final GridLayout jobsListLayout = new GridLayout(1, MAX_JOB_PANELS);
    jobsListLayout.setHgap(10);
    _jobsListPanel.setBorder(new EmptyBorder(10, 10, 4, 0));
    _jobsListPanel.setLayout(jobsListLayout);

    final List<FileObject> recentJobFiles = getRecentJobFiles();

    updateJobsListPanel(recentJobFiles);

    add(_jobsListPanel);

    _moreRecentJobsButton = new JButton("More",
            imageManager.getImageIcon(IconUtils.FILE_FOLDER, IconUtils.ICON_SIZE_SMALL));
    _moreRecentJobsButton.setMargin(new Insets(1, 1, 1, 4));
    if (recentJobFiles.size() <= MAX_JOB_PANELS) {
        _moreRecentJobsButton.setEnabled(false);
    } else {
        _moreRecentJobsButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                final JPopupMenu popup = new JPopupMenu();
                for (int i = 3; i < recentJobFiles.size(); i++) {
                    final FileObject jobFile = recentJobFiles.get(i);
                    final JMenuItem menuItem = new OpenAnalysisJobMenuItem(jobFile,
                            _openAnalysisJobActionListener);
                    popup.add(menuItem);
                }
                popup.show(_moreRecentJobsButton, 0, _moreRecentJobsButton.getHeight());
            }
        });
    }

    final DCPanel jobsButtonPanel = new DCPanel();
    jobsButtonPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 0));
    jobsButtonPanel.add(_moreRecentJobsButton);
    jobsButtonPanel.add(_browseJobsButton);
    add(jobsButtonPanel);

    add(Box.createVerticalStrut(40));

    final DCLabel datastoreHeaderLabel = DCLabel.dark("Datastores");
    datastoreHeaderLabel.setFont(WidgetUtils.FONT_HEADER1);
    add(datastoreHeaderLabel);

    final DCLabel registerNewDatastoreLabel = DCLabel.dark("Register new:");
    registerNewDatastoreLabel.setFont(WidgetUtils.FONT_HEADER2);

    final DCPanel newDatastorePanel = new DCPanel();
    newDatastorePanel.setLayout(new VerticalLayout(4));
    newDatastorePanel.setBorder(new EmptyBorder(10, 10, 10, 0));
    newDatastorePanel.add(registerNewDatastoreLabel);
    newDatastorePanel.add(createNewDatastorePanel());

    add(newDatastorePanel);

    _datastoreListPanel = new DCPanel();
    _datastoreListPanel.setLayout(new VerticalLayout(4));
    _datastoreListPanel.setBorder(new EmptyBorder(10, 10, 4, 0));
    add(_datastoreListPanel);
    updateDatastores();

    final DCPanel datastoresButtonPanel = new DCPanel();
    datastoresButtonPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    datastoresButtonPanel.setBorder(new EmptyBorder(0, 10, 0, 0));
    datastoresButtonPanel.add(_analyzeButton);
    add(datastoresButtonPanel);
}

From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java

@SuppressWarnings("unchecked")
private JPanel buildSimpleCentral(final String labelPie, final SaveOrUpdateAction guardar, final JFrame d) {
    JPanel central = new JPanel(new GridBagLayout());
    central.setOpaque(false);// w  w w  . j  ava 2  s  .  co m
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.insets = new Insets(2, 1, 2, 1);
    gbc.gridwidth = 1;
    central.add(Box.createVerticalStrut(10), gbc);

    gbc.gridy++;
    gbc.gridx = 0;
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel nombreLbl = new JLabel("Nombre:", SwingConstants.RIGHT);
    central.add(nombreLbl, gbc);
    gbc.gridx++;
    gbc.gridwidth = 3;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(nombre, gbc);
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.gridwidth = 1;
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel apellidosLbl = new JLabel("Apellidos: ", SwingConstants.RIGHT);
    central.add(apellidosLbl, gbc);
    gbc.gridx++;
    gbc.gridwidth = 3;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(apellidos, gbc);
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel rolLbl = new JLabel("Rol:", SwingConstants.RIGHT);
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.gridwidth = 1;
    central.add(rolLbl, gbc);
    gbc.gridx++;
    gbc.gridwidth = 3;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(rol, gbc);
    gbc.gridwidth = 1;
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel contrasenyaLbl = new JLabel("Contrasea:", SwingConstants.RIGHT);
    gbc.gridy++;
    gbc.gridx = 0;
    central.add(contrasenyaLbl, gbc);
    gbc.gridx++;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(contrasenya, gbc);
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel contrasenya2Lbl = new JLabel("Repetir Contrasea:", SwingConstants.RIGHT);
    gbc.gridx++;
    central.add(contrasenya2Lbl, gbc);
    gbc.gridx++;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(repetir, gbc);
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel administradorLbl = new JLabel("Administrador:", SwingConstants.RIGHT);
    gbc.gridy++;
    gbc.gridx = 0;
    central.add(administradorLbl, gbc);
    gbc.gridx++;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(administrador, gbc);
    administrador.setOpaque(false);
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel habilitadoLbl = new JLabel("Habilitado", SwingConstants.RIGHT);
    gbc.gridx++;
    central.add(habilitadoLbl, gbc);
    gbc.gridx++;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(habilitado, gbc);
    habilitado.setOpaque(false);

    gbc.gridx = 0;
    gbc.gridy++;
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel labl_pie = new JLabel(labelPie, JLabel.LEFT);
    central.add(labl_pie, gbc);
    textfieldPie.setColumns(textfieldSize);
    labl_pie.setLabelFor(textfieldPie);
    gbc.gridx++;
    gbc.gridwidth = 4;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(textfieldPie, gbc);

    gbc.gridy++;
    gbc.gridx = 0;
    central.add(Box.createVerticalStrut(10), gbc);

    gbc.gridwidth = 2;
    gbc.gridy++;
    gbc.gridx = 1;
    JPanel botones = getBotonesSalir(guardar, d, 250);
    central.add(botones, gbc);

    ((DefaultComboBoxModel) rol.getModel()).removeAllElements();
    for (String r : RolConsultas.getAllNames()) {
        ((DefaultComboBoxModel) rol.getModel()).addElement(r);
    }

    return central;
}

From source file:org.rimudb.editor.DescriptorEditor.java

/**
 * Build the panel//from  w w w  .j  a  va 2 s  . com
 */
private JPanel createColumnTablePanel() {
    JPanel columnPanel = new JPanel();
    columnPanel.setLayout(new BoxLayout(columnPanel, BoxLayout.Y_AXIS));

    // Create the property table panel
    propertyModel = new PropertyTableModel();

    // Add a listener to set the changed state
    propertyModel.addTableModelListener(new TableModelListener() {
        public void tableChanged(TableModelEvent e) {
            markChanged();

            if (e instanceof PropertyTableModelEvent) {
                PropertyTableModelEvent ptme = (PropertyTableModelEvent) e;

                // If the columnName column was changed then check it isn't
                // a PK
                if (ptme.getColumn() == 1) {

                    String beforeColumnName = (String) ptme.getBeforeValue();
                    String afterColumnName = (String) ptme.getAfterValue();

                    // Is the field entry in the list of primary keys?
                    for (int i = 0; i < pkListModel.getSize(); i++) {
                        String pkColumnName = (String) pkListModel.get(i);
                        // If it's found then remove it
                        if (beforeColumnName.equals(pkColumnName)) {
                            pkListModel.set(i, afterColumnName);
                            break;
                        }
                    }

                }

            }
        }
    });

    table = new ATable(getPropertyModel());
    table.setName("ColumnTable");
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            int selectedRowCount = table.getSelectedRowCount();
            removeColumnBtn.setEnabled(selectedRowCount > 0);
            moveUpBtn.setEnabled(selectedRowCount > 0);
            moveDownBtn.setEnabled(selectedRowCount > 0);
        }
    });
    table.setTransferHandler(new TransferHandler() {

        public int getSourceActions(JComponent c) {
            return COPY;
        }

        protected Transferable createTransferable(JComponent c) {
            ATable columnTable = (ATable) c;
            int row = columnTable.getSelectedRow();
            String columnName = getPropertyModel().getRow(row).getColumnName();
            return new StringSelection(columnName);
        }
    });
    table.setDragEnabled(true);

    JScrollPane sp = new JScrollPane(table);
    sp.setMaximumSize(new Dimension(Short.MAX_VALUE, 325));
    sp.setPreferredSize(new Dimension(Short.MAX_VALUE, 325));
    sp.setMinimumSize(new Dimension(Short.MAX_VALUE, 325));

    JComboBox typeCB = new JComboBox(DatabaseTypes.getAllTypes());
    typeCB.setEditable(false);

    javax.swing.table.TableColumn typeColumn = table.getColumnModel().getColumn(2);
    typeColumn.setCellEditor(new DefaultCellEditor(typeCB));

    // Create the popup menu and set it on the table
    propertyPopup = new TablePopupMenu(this, table);
    table.addMouseListener(propertyPopup);
    sp.addMouseListener(propertyPopup);
    sp.setAlignmentX(LEFT_ALIGNMENT);

    columnPanel.add(sp);

    columnPanel.add(Box.createVerticalStrut(10));

    JLabel pkLabel = new JLabel("Primary Key Columns", SwingConstants.LEFT);
    pkLabel.setAlignmentX(LEFT_ALIGNMENT);
    columnPanel.add(pkLabel);

    pkListModel = new DefaultListModel();
    pkListModel.addListDataListener(new ListDataListener() {
        public void intervalRemoved(ListDataEvent e) {
            markChanged();
        }

        public void intervalAdded(ListDataEvent e) {
            markChanged();
        }

        public void contentsChanged(ListDataEvent e) {
            markChanged();
        }
    });

    pkList = new JList(pkListModel);
    pkList.setName("pkList");
    pkList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    pkList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            int selectedRowCount = pkList.getSelectedIndex();
            removePkBtn.setEnabled(selectedRowCount > -1);
        }
    });
    pkList.setTransferHandler(new TransferHandler() {

        public boolean canImport(TransferHandler.TransferSupport info) {
            // we only import Strings
            if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                return false;
            }

            JList.DropLocation dl = (JList.DropLocation) info.getDropLocation();
            if (dl.getIndex() == -1) {
                return false;
            }
            return true;
        }

        public boolean importData(TransferHandler.TransferSupport info) {
            if (!info.isDrop()) {
                return false;
            }

            // Check for String flavor
            if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                displayDropLocation("List doesn't accept a drop of this type.");
                return false;
            }

            JList.DropLocation dl = (JList.DropLocation) info.getDropLocation();
            DefaultListModel listModel = (DefaultListModel) pkList.getModel();
            int index = dl.getIndex();

            // Get the string that is being dropped.
            Transferable t = info.getTransferable();
            String data;
            try {
                data = (String) t.getTransferData(DataFlavor.stringFlavor);
            } catch (Exception e) {
                return false;
            }

            // If this is a copy action then check we don't already have that String
            if (info.getDropAction() == COPY && listModel.indexOf(data) > -1) {
                displayDropLocation("The column " + data + " is already a primary key");
                return false;
            }

            // Perform the actual import. 
            if (dl.isInsert()) {
                int oldIndex = listModel.indexOf(data);
                if (oldIndex < index) {
                    listModel.add(index, data);
                    listModel.remove(oldIndex);
                } else {
                    listModel.remove(oldIndex);
                    listModel.add(index, data);
                }
            } else {
                // Don't handle replacements
            }
            return true;
        }

        public int getSourceActions(JComponent c) {
            return MOVE;
        }

        protected Transferable createTransferable(JComponent c) {
            JList list = (JList) c;
            Object[] values = list.getSelectedValues();

            StringBuffer buff = new StringBuffer();

            for (int i = 0; i < values.length; i++) {
                Object val = values[i];
                buff.append(val == null ? "" : val.toString());
                if (i != values.length - 1) {
                    buff.append("\n");
                }
            }
            return new StringSelection(buff.toString());
        }
    });
    pkList.setDropMode(DropMode.INSERT);
    pkList.setDragEnabled(true);

    JScrollPane pkScrollPanel = new JScrollPane(pkList);
    pkScrollPanel.setMaximumSize(new Dimension(Short.MAX_VALUE, 100));
    pkScrollPanel.setAlignmentX(LEFT_ALIGNMENT);

    columnPanel.add(pkScrollPanel);

    return columnPanel;
}

From source file:org.apache.cayenne.modeler.CayenneModelerFrame.java

protected void initStatusBar() {
    status = new JLabel();
    status.setFont(status.getFont().deriveFont(Font.PLAIN, 10));

    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.getInsets().left = 5;/*from w ww. j av a  2 s  . co  m*/
    splitPane.getInsets().right = 5;

    splitPane.setResizeWeight(0.7);

    /**
     * Moving this to try-catch block per CAY-940. Exception will be stack-traced
     */
    try {
        ComponentGeometry geometry = new ComponentGeometry(this.getClass(), "splitPane/divider");
        geometry.bindIntProperty(splitPane, JSplitPane.DIVIDER_LOCATION_PROPERTY, 400);
    } catch (Exception ex) {
        LogFactory.getLog(getClass()).error("Cannot bind divider property", ex);
    }

    JPanel statusBar = new JPanel(new FlowLayout(FlowLayout.LEFT, 3, 1));
    // add placeholder
    statusBar.add(Box.createVerticalStrut(16));
    statusBar.add(status);

    getContentPane().add(splitPane, BorderLayout.CENTER);
    getContentPane().add(statusBar, BorderLayout.SOUTH);
}