Example usage for javax.swing Box createHorizontalStrut

List of usage examples for javax.swing Box createHorizontalStrut

Introduction

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

Prototype

public static Component createHorizontalStrut(int width) 

Source Link

Document

Creates an invisible, fixed-width component.

Usage

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  w ww. ja va 2 s. 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:pcgen.gui2.tabs.spells.SpellBooksTab.java

private void initComponents() {
    availableTable.setTreeCellRenderer(spellRenderer);
    selectedTable.setTreeCellRenderer(spellRenderer);
    selectedTable.setRowSorter(new SortableTableRowSorter() {

        @Override//ww w. ja  v a2 s  . c o  m
        public SortableTableModel getModel() {
            return (SortableTableModel) selectedTable.getModel();
        }

    });
    selectedTable.getRowSorter().toggleSortOrder(0);
    FilterBar<CharacterFacade, SuperNode> filterBar = new FilterBar<>();
    filterBar.addDisplayableFilter(new SearchFilterPanel());
    qFilterButton.setText(LanguageBundle.getString("in_igQualFilter")); //$NON-NLS-1$
    filterBar.addDisplayableFilter(qFilterButton);

    FlippingSplitPane upperPane = new FlippingSplitPane("SpellBooksTop");
    JPanel availPanel = FilterUtilities.configureFilteredTreeViewPane(availableTable, filterBar);
    Box box = Box.createVerticalBox();
    box.add(Box.createVerticalStrut(5));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(new JLabel(LanguageBundle.getString("InfoSpells.set.auto.book")));
        hbox.add(Box.createHorizontalGlue());
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(defaultBookCombo);
        hbox.add(Box.createHorizontalGlue());
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(addButton);
        hbox.add(Box.createHorizontalStrut(5));
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    availPanel.add(box, BorderLayout.SOUTH);
    upperPane.setLeftComponent(availPanel);

    box = Box.createVerticalBox();
    box.add(new JScrollPane(selectedTable));
    box.add(Box.createVerticalStrut(5));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(removeButton);
        hbox.add(Box.createHorizontalGlue());
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    upperPane.setRightComponent(box);
    upperPane.setResizeWeight(0);
    setTopComponent(upperPane);

    FlippingSplitPane bottomPane = new FlippingSplitPane("SpellBooksBottom");
    bottomPane.setLeftComponent(spellsPane);
    bottomPane.setRightComponent(classPane);
    setBottomComponent(bottomPane);
    setOrientation(VERTICAL_SPLIT);
}

From source file:pcgen.gui2.tabs.spells.SpellsPreparedTab.java

private void initComponents() {
    availableTable.setTreeCellRenderer(spellRenderer);
    selectedTable.setTreeCellRenderer(spellRenderer);
    selectedTable.setRowSorter(new SortableTableRowSorter() {

        @Override/* w w w  .  j a v  a 2s. co m*/
        public SortableTableModel getModel() {
            return (SortableTableModel) selectedTable.getModel();
        }

    });
    selectedTable.getRowSorter().toggleSortOrder(0);
    FilterBar<CharacterFacade, SuperNode> filterBar = new FilterBar<>();
    filterBar.addDisplayableFilter(new SearchFilterPanel());
    qFilterButton.setText(LanguageBundle.getString("in_igQualFilter")); //$NON-NLS-1$
    filterBar.addDisplayableFilter(qFilterButton);

    FlippingSplitPane upperPane = new FlippingSplitPane("SpellsPreparedTop");
    JPanel availPanel = FilterUtilities.configureFilteredTreeViewPane(availableTable, filterBar);
    Box box = Box.createVerticalBox();
    box.add(Box.createVerticalStrut(5));
    {
        Box hbox = Box.createHorizontalBox();
        addMMSpellButton.setHorizontalTextPosition(SwingConstants.LEADING);
        hbox.add(addMMSpellButton);
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(2));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(slotsBox);
        hbox.add(Box.createHorizontalGlue());
        hbox.add(Box.createHorizontalStrut(10));
        hbox.add(addSpellButton);
        hbox.add(Box.createHorizontalStrut(5));
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    availPanel.add(box, BorderLayout.SOUTH);
    upperPane.setLeftComponent(availPanel);

    box = Box.createVerticalBox();
    box.add(new JScrollPane(selectedTable));
    box.add(Box.createVerticalStrut(4));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(removeSpellButton);
        hbox.add(Box.createHorizontalStrut(10));
        hbox.add(new JLabel(LanguageBundle.getString("InfoPreparedSpells.preparedList")));
        hbox.add(Box.createHorizontalStrut(3));
        hbox.add(spellListField);
        hbox.add(Box.createHorizontalStrut(3));
        hbox.add(addSpellListButton);
        hbox.add(Box.createHorizontalStrut(3));
        hbox.add(removeSpellListButton);
        hbox.add(Box.createHorizontalStrut(5));
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    upperPane.setRightComponent(box);
    upperPane.setResizeWeight(0);
    setTopComponent(upperPane);

    FlippingSplitPane bottomPane = new FlippingSplitPane("SpellsPreparedBottom");
    bottomPane.setLeftComponent(spellsPane);
    bottomPane.setRightComponent(classPane);
    setBottomComponent(bottomPane);
    setOrientation(VERTICAL_SPLIT);
}

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

private void initRightPanel(JPanel rightPanel) {
    rightPanel.setLayout(new GridBagLayout());
    /*/*from w  ww .  java2 s. c  o m*/
     * initialize Components
     */
    racePanel.setOpaque(false);
    classPanel.setOpaque(false);
    ageField.setHorizontalAlignment(SwingConstants.RIGHT);
    expField.setHorizontalAlignment(SwingConstants.RIGHT);
    nextlevelField.setHorizontalAlignment(SwingConstants.RIGHT);
    nextlevelField.setEnabled(false);
    expmodField.setHorizontalAlignment(SwingConstants.RIGHT);

    raceComboBox.setPrototypeDisplayValue("PrototypeDisplayValue"); //$NON-NLS-1$
    classComboBox.setPrototypeDisplayValue("PrototypeDisplayValue"); //$NON-NLS-1$

    expaddButton.setMargin(new Insets(0, 8, 0, 8));
    expsubtractButton.setMargin(new Insets(0, 8, 0, 8));
    hpButton.setMargin(new Insets(0, 0, 0, 0));

    JPanel expmodPanel = new JPanel(new GridBagLayout());
    JPanel levelPanel = new JPanel();
    JLabel raceLabel = createLabel("in_sumRace"); //$NON-NLS-1$
    JLabel ageLabel = createLabel("in_sumAge"); //$NON-NLS-1$
    JLabel classLabel = createLabel("in_sumClass"); //$NON-NLS-1$
    JLabel hpLabel = createLabel("in_sumTotalHP"); //$NON-NLS-1$
    JLabel expLabel = createLabel("in_sumCurrentXp"); //$NON-NLS-1$
    JLabel nextlevelLabel = createLabel("in_sumNextlevel"); //$NON-NLS-1$
    JLabel xpTableLabel = createLabel("in_sumXpTable"); //$NON-NLS-1$
    JLabel expmodLabel = createLabel("in_sumExpMod"); //$NON-NLS-1$
    expmodLabel.setHorizontalAlignment(SwingConstants.CENTER);
    initLevelPanel(levelPanel);
    /*
     * initialize constant variables
     */
    Insets racePanelInsets = racePanel.getInsets();
    Insets classPanelInsets = classPanel.getInsets();
    /*
     * racePanel
     */
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets = new Insets(racePanelInsets.top, racePanelInsets.left, 0, 0);
    gbc.gridwidth = 2;
    rightPanel.add(raceLabel, gbc);
    gbc.insets = new Insets(racePanelInsets.top, 1, 1, racePanelInsets.right);
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    rightPanel.add(raceComboBox, gbc);
    gbc.insets = new Insets(0, racePanelInsets.left, 0, 1);
    gbc.gridwidth = 1;
    rightPanel.add(ageLabel, gbc);
    gbc.insets = new Insets(1, 1, 1, 1);
    rightPanel.add(ageField, gbc);
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.insets = new Insets(1, 1, 1, racePanelInsets.right);
    rightPanel.add(ageComboBox, gbc);
    gbc.insets = new Insets(1, racePanelInsets.left, racePanelInsets.bottom, racePanelInsets.right);
    rightPanel.add(createMonsterButton, gbc);
    /*
     * classPanel
     */
    gbc.gridwidth = 2;
    gbc.insets = new Insets(classPanelInsets.top, classPanelInsets.left, 0, 0);
    rightPanel.add(classLabel, gbc);
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.insets = new Insets(classPanelInsets.top, 0, 0, classPanelInsets.right);
    rightPanel.add(classComboBox, gbc);

    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets = new Insets(7, classPanelInsets.left, 0, classPanelInsets.right);
    rightPanel.add(levelPanel, gbc);
    gbc.insets.top = 0;
    gbc.insets.bottom = 10;
    gbc.weighty = 0;
    {
        JPanel hpPanel = new JPanel(new FlowLayout());
        hpPanel.add(hpLabel);
        hpPanel.add(Box.createHorizontalStrut(3));
        hpPanel.add(totalHPLabel);
        hpPanel.add(hpButton);
        rightPanel.add(hpPanel, gbc);
    }
    gbc.insets.bottom = 0;
    GridBagConstraints leftgbc = new GridBagConstraints();
    leftgbc.insets = new Insets(0, classPanelInsets.left, 0, 0);
    leftgbc.gridwidth = 2;
    leftgbc.fill = GridBagConstraints.BOTH;

    GridBagConstraints rightgbc = new GridBagConstraints();
    rightgbc.insets = new Insets(0, 0, 0, classPanelInsets.right);
    rightgbc.gridwidth = GridBagConstraints.REMAINDER;
    rightgbc.fill = GridBagConstraints.BOTH;

    rightPanel.add(expLabel, leftgbc);
    rightPanel.add(expField, rightgbc);
    rightPanel.add(nextlevelLabel, leftgbc);
    rightPanel.add(nextlevelField, rightgbc);
    rightPanel.add(xpTableLabel, leftgbc);
    rightPanel.add(xpTableComboBox, rightgbc);

    gbc.insets.top = 10;
    rightPanel.add(expmodLabel, gbc);
    {
        GridBagConstraints gbc2 = new GridBagConstraints();
        gbc2.fill = GridBagConstraints.HORIZONTAL;
        gbc2.weightx = 1.0;
        gbc2.insets = new Insets(0, 1, 0, 1);
        expmodPanel.add(expaddButton, gbc2);
        expmodPanel.add(expsubtractButton, gbc2);
    }
    leftgbc.insets.bottom = classPanelInsets.bottom;
    leftgbc.weightx = 0.3;
    rightPanel.add(expmodPanel, leftgbc);
    rightgbc.insets.bottom = classPanelInsets.bottom;
    rightgbc.weightx = 0.7;
    rightPanel.add(expmodField, rightgbc);

    gbc = new GridBagConstraints();
    gbc.gridx = gbc.gridy = 0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.gridheight = 3;
    gbc.fill = GridBagConstraints.BOTH;
    rightPanel.add(racePanel, gbc);

    gbc.gridy = 3;
    gbc.gridheight = GridBagConstraints.REMAINDER;
    rightPanel.add(classPanel, gbc);
}

From source file:plugins.ImageRectificationPanel.java

public final void createGui() {
    this.removeAll();

    if (imageGCPsXCoords == null) {
        return;/*from   www.j  a  va  2s.  c  om*/
    }
    int i;
    int newN = 0;
    for (i = 0; i < imageGCPsXCoords.length; i++) {
        if (useGCP[i]) {
            newN++;
        }
    }
    double[] X1 = new double[newN];
    double[] Y1 = new double[newN];
    double[] X2 = new double[newN];
    double[] Y2 = new double[newN];

    int j = 0;
    for (i = 0; i < imageGCPsXCoords.length; i++) {
        if (useGCP[i]) {
            X1[j] = imageGCPsXCoords[i];
            Y1[j] = imageGCPsYCoords[i];
            X2[j] = mapGCPsXCoords[i];
            Y2[j] = mapGCPsYCoords[i];
            j++;
        }
    }

    calculateEquations(X1, Y1, X2, Y2);

    // gui stuff
    this.setLayout(new BorderLayout());

    DecimalFormat df = new DecimalFormat("###,###,##0.000");

    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS));
    JButton btnOK = createButton(bundle.getString("OK"), bundle.getString("OK"), "ok");
    JButton btnExit = createButton(bundle.getString("Close"), bundle.getString("Close"), "close");
    //JButton btnRefresh = createButton("Cancel", "Cancel");

    buttonPane.add(Box.createHorizontalStrut(10));
    buttonPane.add(btnOK);
    buttonPane.add(Box.createHorizontalStrut(5));
    //buttonPane.add(btnRefresh);
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.add(btnExit);
    buttonPane.add(Box.createHorizontalGlue());

    progressBar = new JProgressBar(0, 100);
    buttonPane.add(progressBar);
    buttonPane.add(Box.createHorizontalStrut(5));
    cancel = new JLabel(bundle.getString("Cancel"));
    cancel.setForeground(Color.BLUE.darker());
    cancel.addMouseListener(this);
    buttonPane.add(cancel);
    buttonPane.add(Box.createHorizontalStrut(10));

    this.add(buttonPane, BorderLayout.SOUTH);

    Box mainBox = Box.createVerticalBox();
    mainBox.add(Box.createVerticalStrut(10));

    Box box1 = Box.createHorizontalBox();
    box1.add(Box.createHorizontalStrut(10));
    box1.add(new JLabel(bundle.getString("PolynomialOrder") + ": "));
    SpinnerModel model = new SpinnerNumberModel(polyOrder, //initial value
            1, //min
            5, //max
            1); //step

    polyOrderSpinner = new JSpinner(model);
    polyOrderSpinner.setPreferredSize(new Dimension(15, polyOrderSpinner.getPreferredSize().height));
    polyOrderSpinner.addChangeListener(this);

    JSpinner.DefaultEditor editor = (JSpinner.DefaultEditor) polyOrderSpinner.getEditor();
    editor.getTextField().setEnabled(true);
    editor.getTextField().setEditable(false);

    box1.add(polyOrderSpinner);
    box1.add(Box.createHorizontalGlue());
    JLabel label = new JLabel("RMSE: " + df.format(overallRMSE));
    box1.add(label);
    box1.add(Box.createHorizontalStrut(10));
    mainBox.add(box1);

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

    // Create columns names
    int numPoints = imageGCPsXCoords.length;
    Object dataValues[][] = new Object[numPoints][7];
    j = 0;
    for (i = 0; i < numPoints; i++) {
        dataValues[i][0] = i + 1;
        dataValues[i][1] = df.format(imageGCPsXCoords[i]);
        dataValues[i][2] = df.format(imageGCPsYCoords[i]);
        dataValues[i][3] = df.format(mapGCPsXCoords[i]);
        dataValues[i][4] = df.format(mapGCPsYCoords[i]);
        if (useGCP[i]) {
            dataValues[i][5] = df.format(residualsXY[j]);
            j++;
        } else {
            dataValues[i][5] = null;
        }
        dataValues[i][6] = useGCP[i];
    }

    String columnNames[] = { "GCP", bundle.getString("Image") + " X", bundle.getString("Image") + " Y",
            bundle.getString("Map") + " X", bundle.getString("Map") + " Y", messages.getString("Error"),
            "Use" };

    DefaultTableModel tableModel = new DefaultTableModel(dataValues, columnNames);

    dataTable = new JTable(tableModel) {
        private static final long serialVersionUID = 1L;

        @Override
        public Class getColumnClass(int column) {
            switch (column) {
            case 0:
                return Integer.class;
            case 1:
                return String.class; //Double.class;
            case 2:
                return String.class; //Double.class;
            case 3:
                return String.class; //Double.class;
            case 4:
                return String.class; //Double.class;
            case 5:
                return String.class; //Double.class;
            case 6:
                return Boolean.class;
            default:
                return String.class; //Double.class;
            }
        }

        @Override
        public Component prepareRenderer(TableCellRenderer renderer, int index_row, int index_col) {
            Component comp = super.prepareRenderer(renderer, index_row, index_col);
            //even index, selected or not selected

            if (index_row % 2 == 0) {
                comp.setBackground(Color.WHITE);
                comp.setForeground(Color.BLACK);
            } else {
                comp.setBackground(new Color(225, 245, 255)); //new Color(210, 230, 255));
                comp.setForeground(Color.BLACK);
            }
            if (isCellSelected(index_row, index_col)) {
                comp.setForeground(Color.RED);
            }
            return comp;
        }
    };

    tableModel.addTableModelListener(this);

    TableCellRenderer rend = dataTable.getTableHeader().getDefaultRenderer();
    TableColumnModel tcm = dataTable.getColumnModel();
    //for (int j = 0; j < tcm.getColumnCount(); j += 1) {
    TableColumn tc = tcm.getColumn(0);
    TableCellRenderer rendCol = tc.getHeaderRenderer(); // likely null  
    if (rendCol == null) {
        rendCol = rend;
    }
    Component c = rendCol.getTableCellRendererComponent(dataTable, tc.getHeaderValue(), false, false, 0, 0);
    tc.setPreferredWidth(35);

    tc = tcm.getColumn(6);
    rendCol = tc.getHeaderRenderer(); // likely null  
    if (rendCol == null) {
        rendCol = rend;
    }
    c = rendCol.getTableCellRendererComponent(dataTable, tc.getHeaderValue(), false, false, 0, 6);
    tc.setPreferredWidth(35);

    JScrollPane scroll = new JScrollPane(dataTable);
    mainBox.add(scroll);

    this.add(mainBox, BorderLayout.CENTER);

    this.validate();
}

From source file:ro.nextreports.designer.querybuilder.SelectionColumnPanel.java

private void buildUI() {

    setLayout(new GridBagLayout());

    final DBViewer viewer = Globals.getDBViewer();

    schemaCombo = new JComboBox();
    schemaCombo.setPreferredSize(comboDim);

    schemaCombo.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            String schema = (String) e.getItem();
            shownColumnModel.clear();//from www .  j a v a  2  s. co  m
            columnModel.clear();
            tableModel.clear();
            try {
                DBInfo dbInfo = viewer.getDBInfo(schema, DBInfo.TABLES | DBInfo.VIEWS);
                List<DBTable> tables = dbInfo.getTables();
                Collections.sort(tables);
                for (DBTable table : tables) {
                    tableModel.addElement(table);
                }
            } catch (NextSqlException ex) {
                LOG.error(ex.getMessage(), ex);
                ex.printStackTrace();
            }
        }
    });

    try {
        List<String> schemas = viewer.getSchemas();
        String schemaName = viewer.getUserSchema();
        Collections.sort(schemas);
        boolean added = false;
        for (String schema : schemas) {
            if (DefaultSchemaManager.getInstance().isVisible(
                    DefaultDataSourceManager.getInstance().getConnectedDataSource().getName(), schema)) {
                added = true;
                schemaCombo.addItem(schema);
            }
        }

        if ((schema == null) || schema.equals(DefaultDBViewer.NO_SCHEMA_NAME)) {
            schema = DefaultDBViewer.NO_SCHEMA_NAME;//viewer.getUserSchema();
        }
        if (!added) {
            schemaCombo.addItem(schema);
        }
        schemaCombo.setSelectedItem(schema);
    } catch (NextSqlException e) {
        LOG.error(e.getMessage(), e);
        e.printStackTrace();
    }

    // create table list
    tableList = new JXList(tableModel);
    tableList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tableList.setCellRenderer(new DBTableCellRenderer());

    // create column list
    columnList = new JXList(columnModel);
    if (singleSelection) {
        columnList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    } else {
        columnList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    }
    columnList.setCellRenderer(new DBColumnCellRenderer());

    shownColumnList = new JXList(shownColumnModel);
    if (singleSelection) {
        shownColumnList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    } else {
        columnList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    }
    addDoubleClick();

    shownColumnList.setCellRenderer(new DBColumnCellRenderer());
    shownColumnList.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent mouseEvent) {
            if ((mouseEvent.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) {
                JPopupMenu popupMenu = new JPopupMenu();
                JMenuItem menuItem = new JMenuItem(new DeselectListAction(shownColumnList));
                popupMenu.add(menuItem);
                popupMenu.show((Component) mouseEvent.getSource(), mouseEvent.getX(), mouseEvent.getY());
            }
        }
    });

    tableList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting() == false) {
                int index = tableList.getSelectedIndex();
                if (index == -1) {
                    return;
                }
                DBTable table = (DBTable) tableModel.getElementAt(index);
                try {
                    List<DBColumn> columns = null;
                    try {
                        columns = viewer.getColumns(table.getSchema(), table.getName());
                    } catch (MalformedTableNameException e1) {
                        Show.error("Malformed table name : " + table.getName());
                        return;
                    }
                    Collections.sort(columns);
                    columnModel.clear();
                    shownColumnModel.clear();
                    for (DBColumn column : columns) {
                        columnModel.addElement(column);
                        shownColumnModel.addElement(column);
                    }
                } catch (NextSqlException e1) {
                    LOG.error(e1.getMessage(), e1);
                    e1.printStackTrace();
                    Show.error(e1);
                }
            }
        }
    });

    columnList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            shownColumnList.clearSelection();
        }
    });

    scrTable = new JScrollPane(tableList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrTable.setPreferredSize(scrDim);
    scrTable.setMinimumSize(scrDim);
    scrTable.setBorder(new TitledBorder(I18NSupport.getString("parameter.source.tables")));
    scrColumn = new JScrollPane(columnList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrColumn.setPreferredSize(scrDim);
    scrColumn.setMinimumSize(scrDim);
    scrColumn.setBorder(new TitledBorder(I18NSupport.getString("parameter.source.columns")));
    scrShownColumn = new JScrollPane(shownColumnList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrShownColumn.setPreferredSize(scrDim);
    scrShownColumn.setMinimumSize(scrDim);
    scrShownColumn.setBorder(new TitledBorder(I18NSupport.getString("parameter.source.shown.columns")));

    JPanel schemaPanel = new JPanel();
    schemaPanel.setLayout(new BoxLayout(schemaPanel, BoxLayout.X_AXIS));
    schemaPanel.add(new JLabel("Schema"));
    schemaPanel.add(Box.createHorizontalStrut(5));
    schemaPanel.add(schemaCombo);

    add(schemaPanel, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    add(scrTable, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 5), 0, 0));
    add(scrColumn, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0));
    if (show) {
        add(scrShownColumn, new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
                GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    }
}

From source file:ro.nextreports.designer.wizrep.QueryWizardPanel.java

private void init() {
    setLayout(new BorderLayout());

    ButtonGroup bg = new ButtonGroup();
    bg.add(selectionRB);/*  w  ww  . j a  va 2  s. c  o  m*/
    bg.add(queryRB);
    bg.add(editRB);
    selectionRB.setSelected(true);

    selectionRB.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            selection();
        }
    });
    queryRB.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            selection();
        }
    });
    editRB.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            selection();
        }
    });

    editor = new EditorPanel();
    parametersPanel = new ParametersPanel();
    parametersPanel.setPreferredSize(new Dimension(120, 200));

    queryPanel = new QueryBrowserPanel() {
        protected void selection() {
            String name = queryPanel.getSelectedFilePath();
            if (queryPanel.querySelected()) {
                ReportPersistence repPersist = ReportPersistenceFactory
                        .createReportPersistence(Globals.getReportPersistenceType());
                Report report = repPersist.loadReport(name);
                context.setAttribute(WizardConstants.LOAD_REPORT, report);
                String sql = report.getSql();
                if (sql == null) {
                    sql = report.getQuery().toString();
                }
                editor.setText(sql);
                parametersPanel.set(report.getParameters());
            } else {
                context.setAttribute(WizardConstants.LOAD_REPORT, null);
                editor.setText("");
                parametersPanel.set(new ArrayList<QueryParameter>());
            }
        }
    };

    sqlLabel = new JLabel("<html><b>Sql</b></html>");

    easyPanel = new EasySelectColumnsPanel();

    JPanel qPanel = new JPanel(new GridBagLayout());

    JPanel radioPanel = new JPanel();
    radioPanel.setLayout(new BoxLayout(radioPanel, BoxLayout.X_AXIS));
    radioPanel.add(selectionRB);
    radioPanel.add(Box.createHorizontalStrut(5));
    radioPanel.add(queryRB);
    radioPanel.add(Box.createHorizontalStrut(5));
    radioPanel.add(editRB);

    qPanel.add(radioPanel, new GridBagConstraints(0, 0, 4, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));

    queryLabel = new JLabel(I18NSupport.getString("query.name"));
    qPanel.add(queryLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0));
    qPanel.add(queryPanel, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
            GridBagConstraints.BOTH, new Insets(5, 5, 0, 0), 0, 0));

    qPanel.add(sqlLabel, new GridBagConstraints(0, 2, 3, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0));
    qPanel.add(editor, new GridBagConstraints(0, 3, 3, 1, 1.0, 1.0, GridBagConstraints.WEST,
            GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
    qPanel.add(parametersPanel, new GridBagConstraints(3, 2, 1, 2, 0.0, 1.0, GridBagConstraints.WEST,
            GridBagConstraints.VERTICAL, new Insets(0, 5, 5, 5), 0, 0));
    qPanel.add(emptyLabel, new GridBagConstraints(0, 4, 4, 1, 1.0, 1.0, GridBagConstraints.WEST,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    qPanel.add(easyPanel, new GridBagConstraints(0, 2, 4, 1, 1.0, 1.0, GridBagConstraints.WEST,
            GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));

    selection();

    add(qPanel, BorderLayout.CENTER);
}

From source file:uk.ac.ebi.demo.picr.swing.PICRBLASTDemo.java

public PICRBLASTDemo() {

    //set general layout
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

    add(Box.createVerticalStrut(5));

    //create components
    JPanel row1 = new JPanel();
    row1.setLayout(new BoxLayout(row1, BoxLayout.X_AXIS));
    row1.add(Box.createHorizontalStrut(5));
    row1.setBorder(BorderFactory.createTitledBorder(""));
    row1.add(new JLabel("Fragment:"));
    row1.add(Box.createHorizontalStrut(10));
    final JTextArea sequenceArea = new JTextArea(5, 40);
    sequenceArea.setMaximumSize(sequenceArea.getPreferredSize());
    row1.add(Box.createHorizontalStrut(10));

    row1.add(sequenceArea);//from   ww  w . j  a va2 s.c om
    row1.add(Box.createHorizontalGlue());

    JPanel row2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    row2.setBorder(BorderFactory.createTitledBorder("Target Databases"));
    final JList databaseList = new JList();
    JScrollPane listScroller = new JScrollPane(databaseList);
    listScroller.setMaximumSize(new Dimension(100, 10));
    JButton loadDBButton = new JButton("Load Databases");
    row2.add(listScroller);
    row2.add(loadDBButton);

    JPanel row3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    JCheckBox onlyActiveCheckBox = new JCheckBox("Only Active");
    onlyActiveCheckBox.setSelected(true);
    row3.add(new JLabel("Options:  "));
    row3.add(onlyActiveCheckBox);

    add(row1);
    add(row2);
    add(row3);

    final String[] columns = new String[] { "Database", "Accession", "Version", "Taxon ID" };
    final JTable dataTable = new JTable(new Object[0][0], columns);
    dataTable.setShowGrid(true);
    add(new JScrollPane(dataTable));

    JPanel buttonPanel = new JPanel();
    JButton mapAccessionButton = new JButton("Generate Mapping!");
    buttonPanel.add(mapAccessionButton);
    add(buttonPanel);

    //create listeners!

    //update boolean flag in communication class
    onlyActiveCheckBox.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            client.setOnlyActive(((JCheckBox) e.getSource()).isSelected());
        }
    });

    //performs mapping call and updates interface with results
    mapAccessionButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            try {

                if (!"".equals(sequenceArea.getText())) {
                    //TODO filters and database are hardcoded here.  They should be added to the input panel at a later revision.
                    java.util.List<UPEntry> entries = client.performBlastMapping(sequenceArea.getText(),
                            databaseList.getSelectedValues(), "90", "", "IDENTITY", "UniprotKB", "", false,
                            new BlastParameter());

                    //compute size of array
                    if (entries != null) {
                        int size = 0;
                        for (UPEntry entry : entries) {
                            for (CrossReference xref : entry.getIdenticalCrossReferences()) {
                                size++;
                            }
                            for (CrossReference xref : entry.getLogicalCrossReferences()) {
                                size++;
                            }
                        }

                        if (size > 0) {

                            final Object[][] data = new Object[size][4];
                            int i = 0;
                            for (UPEntry entry : entries) {
                                for (CrossReference xref : entry.getIdenticalCrossReferences()) {
                                    data[i][0] = xref.getDatabaseName();
                                    data[i][1] = xref.getAccession();
                                    data[i][2] = xref.getAccessionVersion();
                                    data[i][3] = xref.getTaxonId();
                                    i++;
                                }
                                for (CrossReference xref : entry.getLogicalCrossReferences()) {
                                    data[i][0] = xref.getDatabaseName();
                                    data[i][1] = xref.getAccession();
                                    data[i][2] = xref.getAccessionVersion();
                                    data[i][3] = xref.getTaxonId();
                                    i++;
                                }
                            }

                            //refresh
                            DefaultTableModel dataModel = new DefaultTableModel();
                            dataModel.setDataVector(data, columns);
                            dataTable.setModel(dataModel);

                            System.out.println("update done");

                        } else {
                            JOptionPane.showMessageDialog(null, "No Mappind data found.");
                        }
                    } else {
                        JOptionPane.showMessageDialog(null, "No Mappind data found.");
                    }
                } else {
                    JOptionPane.showMessageDialog(null, "You must enter a valid FASTA sequence to map.");
                }
            } catch (SOAPFaultException soapEx) {
                JOptionPane.showMessageDialog(null, "A SOAP Error occurred.");
                soapEx.printStackTrace();
            }
        }
    });

    //loads list of mapping databases from communication class
    loadDBButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            try {

                java.util.List<String> databases = client.loadDatabases();
                if (databases != null && databases.size() > 0) {

                    databaseList.setListData(databases.toArray());
                    System.out.println("database refresh done");

                } else {
                    JOptionPane.showMessageDialog(null, "No Databases Loaded!.");
                }

            } catch (SOAPFaultException soapEx) {
                JOptionPane.showMessageDialog(null, "A SOAP Error occurred.");
                soapEx.printStackTrace();
            }
        }
    });

}

From source file:uk.nhs.cfh.dsp.srth.desktop.modules.querycreationtreepanel.ConstraintPanel.java

/**
 * Inits the components./*from w w w.  j  a va2s  .c  o m*/
 */
private void initComponents() {

    String[] fields = new String[] { "has_dose", "has_value" };
    fieldBox = new JComboBox(fields);
    fieldBox.addActionListener(new AbstractAction() {

        public void actionPerformed(ActionEvent arg0) {
            // get selected item
            selectedField = fieldBox.getSelectedItem().toString();
        }
    });
    // select has_value by default
    fieldBox.setSelectedItem(fields[1]);
    JPanel p1 = new JPanel();
    p1.setLayout(new BoxLayout(p1, BoxLayout.LINE_AXIS));
    p1.add(new JLabel("Field Name"));
    p1.add(Box.createHorizontalStrut(10));
    p1.add(fieldBox);

    Operator[] ops = { Operator.EQUAL_TO, Operator.BETWEEN, Operator.LESS_THAN, Operator.GREATER_THAN };
    operatorsBox = new JComboBox(ops);
    // select operator 'equal to' by default
    operatorsBox.setSelectedItem(Operator.EQUAL_TO);
    selectedOperator = Operator.EQUAL_TO;
    operatorsBox.addActionListener(new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            // get selected operator
            selectedOperator = Operator.valueOf(operatorsBox.getSelectedItem().toString());

            if (selectedOperator == Operator.BETWEEN) {
                // enable second value spinner
                valueSpinner2.setEnabled(true);
                valueSpinnerCheckBox2.setEnabled(true);
            } else if (selectedOperator == Operator.EQUAL_TO) {
                // disable value 1 checkbox
                valueSpinnerCheckBox1.setEnabled(false);

                // disable value spinner 2
                valueSpinner2.setEnabled(false);
                valueSpinnerCheckBox2.setEnabled(false);
            } else {
                // disable value 1 checkbox
                valueSpinnerCheckBox1.setEnabled(true);

                // disable value spinner 2
                valueSpinner2.setEnabled(false);
                valueSpinnerCheckBox2.setEnabled(false);
            }
        }
    });
    JPanel p2 = new JPanel();
    p2.setLayout(new BoxLayout(p2, BoxLayout.LINE_AXIS));
    p2.add(new JLabel("Operator"));
    p2.add(Box.createHorizontalStrut(20));
    p2.add(operatorsBox);

    // create spinners
    SpinnerNumberModel model1 = new SpinnerNumberModel(0, 0, 10000, 0.1);
    SpinnerNumberModel model2 = new SpinnerNumberModel(0, 0, 10000, 0.1);
    valueSpinner1 = new JSpinner(model1);
    valueSpinner1.setName("valueSpinner1");
    valueSpinner2 = new JSpinner(model2);
    valueSpinner2.setName("valueSpinner2");
    // disable spinner 2 by default
    valueSpinner2.setEnabled(false);
    // create check boxes for inclusive ranges...
    valueSpinnerCheckBox1 = new JCheckBox(new AbstractAction("Inclusive") {

        public void actionPerformed(ActionEvent e) {
            value1Inclusive = valueSpinnerCheckBox1.isSelected();
        }
    });
    valueSpinnerCheckBox2 = new JCheckBox(new AbstractAction("Inclusive") {

        public void actionPerformed(ActionEvent e) {
            value2Inclusive = valueSpinnerCheckBox2.isSelected();
        }
    });
    JPanel p3 = new JPanel();
    p3.setLayout(new BoxLayout(p3, BoxLayout.LINE_AXIS));
    p3.add(new JLabel("Lower Bound"));
    p3.add(Box.createHorizontalStrut(10));
    p3.add(valueSpinner1);
    JPanel lowerBoundPanel = new JPanel(new GridLayout(0, 1));
    lowerBoundPanel.add(p3);
    lowerBoundPanel.add(valueSpinnerCheckBox1);
    JPanel p4 = new JPanel();
    p4.setLayout(new BoxLayout(p4, BoxLayout.LINE_AXIS));
    p4.add(new JLabel("Upper Bound"));
    p4.add(Box.createHorizontalStrut(10));
    p4.add(valueSpinner2);
    JPanel upperBoundPanel = new JPanel(new GridLayout(0, 1));
    upperBoundPanel.add(p4);
    upperBoundPanel.add(valueSpinnerCheckBox2);

    // set grid layout
    this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    add(p1);
    add(p2);
    add(lowerBoundPanel);
    add(upperBoundPanel);
}

From source file:uk.nhs.cfh.dsp.srth.desktop.modules.resultexplanationpanel.QueryStatisticsCollectionPanel.java

/**
 * Creates the statements panel./*from w  w w .j a  va 2  s.c o m*/
 * 
 * @param textArea the text area
 * @param title the title
 * 
 * @return the j panel
 */
private synchronized JPanel createStatementsPanel(final JTextArea textArea, String title) {

    JPanel panel = new JPanel(new BorderLayout());
    panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(),
            BorderFactory.createTitledBorder(title)));

    // create buttons for copy and export
    JButton copyButton = new JButton(new AbstractAction("Copy") {

        public void actionPerformed(ActionEvent event) {
            StringSelection selection = new StringSelection(textArea.getSelectedText());
            // get contents of text area and copy to system clipboard
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            clipboard.setContents(selection, QueryStatisticsCollectionPanel.this);
        }
    });

    JButton exportButton = new JButton(new AbstractAction("Export") {

        public void actionPerformed(ActionEvent event) {
            // open a file dialog and export the contents
            FileDialog fd = new FileDialog(applicationService.getFrameView().getActiveFrame(),
                    "Select file to export to", FileDialog.SAVE);
            fd.setVisible(true);

            String fileName = fd.getFile();
            String fileDirectory = fd.getDirectory();

            if (fileDirectory != null && fileName != null) {
                File file = new File(fileDirectory, fileName);
                try {
                    String contents = textArea.getText();
                    FileWriter fw = new FileWriter(file);
                    fw.flush();
                    fw.write(contents);
                    fw.close();
                    // inform user
                    //                  manager.getStatusMessageLabel().setText("Successfully saved contents to file "+fileName);
                    logger.info("Successfully saved contents to file " + fileName);

                } catch (IOException e) {
                    logger.warn(e.fillInStackTrace());
                    //                  manager.getStatusMessageLabel().setText("Errors saving contents to file "+fileName);
                }
            }
        }
    });
    // create buttons panel
    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.LINE_AXIS));
    buttonsPanel.add(Box.createHorizontalStrut(200));
    buttonsPanel.add(copyButton);
    buttonsPanel.add(exportButton);

    panel.add(buttonsPanel, BorderLayout.SOUTH);
    panel.add(new JScrollPane(textArea), BorderLayout.CENTER);

    return panel;
}