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:org.ut.biolab.medsavant.client.view.component.SearchableTablePanel.java

private void strut(JPanel p) {
    p.add(Box.createHorizontalStrut(5));
}

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

private void initUI() {

    JPanel p = new JPanel();
    ViewUtil.applyVerticalBoxLayout(p);// ww  w. j  a va 2 s  . c o  m
    this.add(p);

    topPanel = ViewUtil.getClearPanel();
    middlePanel = ViewUtil.getClearPanel();
    bottomPanel = ViewUtil.getClearPanel();

    p.add(topPanel);
    p.add(middlePanel);
    p.add(bottomPanel);

    // middle
    middlePanel.setLayout(new BorderLayout());

    retriever = new FamilyReceiver();

    stp = new SearchableTablePanel("Individuals", COLUMN_NAMES, COLUMN_CLASSES, HIDDEN_COLUMNS, true, true,
            Integer.MAX_VALUE, false, SearchableTablePanel.TableSelectionType.ROW, Integer.MAX_VALUE,
            retriever);
    stp.setExportButtonVisible(false);

    middlePanel.add(stp, BorderLayout.CENTER);

    // bottom
    ViewUtil.applyVerticalBoxLayout(bottomPanel);

    numselections = ViewUtil.getTitleLabel("0 families selected");

    JPanel text = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(text);

    JButton clearIndividuals = ViewUtil
            .getIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.CLOSE));
    clearIndividuals.setToolTipText("Clear selections");
    clearIndividuals.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            clearSelections();
        }
    });

    text.add(numselections);
    text.add(Box.createHorizontalStrut(5));
    text.add(clearIndividuals);
    bottomPanel.add(ViewUtil.centerHorizontally(text));

    final JButton addAllIndividuals = ViewUtil.getSoftButton("Add All");
    bottomPanel.add(addAllIndividuals);

    final JButton addIndividuals = ViewUtil.getSoftButton("Add Selected");
    bottomPanel.add(addIndividuals);

    final JButton removeIndividuals = ViewUtil.getSoftButton("Remove Selected");
    bottomPanel.add(removeIndividuals);

    final JButton removeAllIndividuals = ViewUtil.getSoftButton("Remove All");
    bottomPanel.add(removeAllIndividuals);

    JPanel buttons = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(buttons);

    buttons.add(addAllIndividuals);
    buttons.add(addIndividuals);
    buttons.add(removeIndividuals);
    buttons.add(removeAllIndividuals);

    JPanel windowControlPanel = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(windowControlPanel);
    windowControlPanel.add(Box.createHorizontalGlue());

    JButton cancel = new JButton("Cancel");
    bottomPanel.add(ViewUtil.centerHorizontally(buttons));

    ok = new JButton("OK");
    bottomPanel.add(ViewUtil.alignRight(ok));
    ok.setEnabled(false);

    windowControlPanel.add(cancel);
    windowControlPanel.add(ok);

    bottomPanel.add(windowControlPanel);

    final JDialog instance = this;

    ok.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            instance.setVisible(false);
            setIndividualsChosen(true);
        }
    });

    cancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            instance.setVisible(false);
            setIndividualsChosen(false || hasMadeSelections);
        }
    });

    addIndividuals.setEnabled(false);
    removeIndividuals.setEnabled(false);

    stp.getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent lse) {
            if (!lse.getValueIsAdjusting()) {

                int rows[] = stp.getTable().getSelectedRows();

                boolean someSelection = rows.length > 0;

                addIndividuals.setEnabled(someSelection);
                removeIndividuals.setEnabled(someSelection);

                if (someSelection) {
                    addIndividuals.setText("Add Selected (" + rows.length + ")");
                    removeIndividuals.setText("Remove Selected (" + rows.length + ")");
                } else {
                    addIndividuals.setText("Add Selected");
                    removeIndividuals.setText("Remove Selected");
                }
            }
        }
    });

    stp.getTable().getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent tme) {
            //addAllIndividuals.setText("Add All (" + stp.getTable().getModel().getRowCount() + ")");
            //removeAllIndividuals.setText("Remove All (" + stp.getTable().getModel().getRowCount() + ")");
        }
    });

    ActionListener addAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            addSelections(false);
        }
    };

    ActionListener addAllAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            addSelections(true);
        }
    };

    ActionListener removeAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            removeSelections(false);
        }
    };

    ActionListener removeAllAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            removeSelections(true);
        }
    };

    addIndividuals.addActionListener(addAction);
    addAllIndividuals.addActionListener(addAllAction);
    removeIndividuals.addActionListener(removeAction);
    removeAllIndividuals.addActionListener(removeAllAction);

    this.pack();
    this.setLocationRelativeTo(MedSavantFrame.getInstance());
}

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

private void initUI() {

    JPanel p = new JPanel();
    ViewUtil.applyVerticalBoxLayout(p);/*from  w ww  .  j av a  2 s  .c om*/
    this.add(p);

    topPanel = ViewUtil.getClearPanel();
    middlePanel = ViewUtil.getClearPanel();
    bottomPanel = ViewUtil.getClearPanel();

    p.add(topPanel);
    p.add(middlePanel);
    p.add(bottomPanel);

    // Only display the bottom panel for multiple patient selection
    if (onlyOnePatient) {
        bottomPanel.setVisible(false);
    }

    // middle
    middlePanel.setLayout(new BorderLayout());

    individualsRetriever = new IndividualsReceiver();
    individualsSTP = new SearchableTablePanel("Individuals", COLUMN_NAMES, COLUMN_CLASSES, HIDDEN_COLUMNS, true,
            true, Integer.MAX_VALUE, false, SearchableTablePanel.TableSelectionType.ROW, Integer.MAX_VALUE,
            individualsRetriever);
    individualsSTP.setExportButtonVisible(false);

    //If patients or cohorts are edited, update the searchabletable.
    CacheController.getInstance().addListener(new Listener<ModificationType>() {
        @Override
        public void handleEvent(ModificationType event) {
            if (event == ModificationType.PATIENT || event == ModificationType.COHORT) {
                if (!individualsSTP.isUpdating()) {
                    forceRefresh = true;
                    individualsSTP.forceRefreshData();
                }
            }
        }

    });

    middlePanel.add(individualsSTP, BorderLayout.CENTER);

    // bottom
    ViewUtil.applyVerticalBoxLayout(bottomPanel);

    numselections = ViewUtil.getTitleLabel("0 individual(s) selected");

    JPanel text = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(text);

    JButton clearIndividuals = ViewUtil
            .getIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.CLOSE));
    clearIndividuals.setToolTipText("Clear selections");
    clearIndividuals.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            clearSelections();
        }
    });

    text.add(numselections);
    text.add(Box.createHorizontalStrut(5));
    text.add(clearIndividuals);
    bottomPanel.add(ViewUtil.centerHorizontally(text));

    final JButton addAllIndividuals = ViewUtil.getSoftButton("Add All");
    bottomPanel.add(addAllIndividuals);

    final JButton addIndividuals = ViewUtil.getSoftButton("Add Selected");
    bottomPanel.add(addIndividuals);

    final JButton removeIndividuals = ViewUtil.getSoftButton("Remove Selected");
    bottomPanel.add(removeIndividuals);

    final JButton removeAllIndividuals = ViewUtil.getSoftButton("Remove All");
    bottomPanel.add(removeAllIndividuals);

    JPanel buttons = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(buttons);

    buttons.add(addAllIndividuals);
    buttons.add(addIndividuals);
    buttons.add(removeIndividuals);
    buttons.add(removeAllIndividuals);

    JPanel windowControlPanel = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(windowControlPanel);
    windowControlPanel.add(Box.createHorizontalGlue());

    JButton cancel = new JButton("Cancel");
    bottomPanel.add(ViewUtil.centerHorizontally(buttons));

    ok = new JButton("OK");
    bottomPanel.add(ViewUtil.alignRight(ok));
    ok.setEnabled(false);

    windowControlPanel.add(cancel);
    windowControlPanel.add(ok);

    bottomPanel.add(windowControlPanel);

    final JDialog instance = this;

    ok.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            instance.setVisible(false);
            setIndividualsChosen(true);
        }
    });

    cancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            instance.setVisible(false);
            setIndividualsChosen(false || hasMadeSelections);
        }
    });

    addIndividuals.setEnabled(false);
    removeIndividuals.setEnabled(false);

    individualsSTP.getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent lse) {
            if (!lse.getValueIsAdjusting()) {

                int rows[] = individualsSTP.getTable().getSelectedRows();

                boolean someSelection = rows.length > 0;

                addIndividuals.setEnabled(someSelection);
                removeIndividuals.setEnabled(someSelection);

                if (someSelection) {
                    addIndividuals.setText("Add Selected (" + rows.length + ")");
                    removeIndividuals.setText("Remove Selected (" + rows.length + ")");
                } else {
                    addIndividuals.setText("Add Selected");
                    removeIndividuals.setText("Remove Selected");
                }

                /* Close the dialog if only a single individual is requested. */
                if (onlyOnePatient && rows.length == 1) {
                    selectedRows.clear();
                    selectedHospitalIDs.clear();

                    int realRow = individualsSTP.getActualRowAt(rows[0]);
                    selectedRows.add(realRow);
                    Object[] o = individualsRetriever.getIndividuals().get(realRow);
                    selectedHospitalIDs.add(o[INDEX_OF_HOSPITAL_ID].toString());

                    instance.setVisible(false);
                    setIndividualsChosen(true);

                    individualsSTP.getTable().clearSelection(); // if errors crop up, this line may be causing ListSelectionEvents - can be removed
                }
            }
        }
    });

    individualsSTP.getTable().getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent tme) {
            //addAllIndividuals.setText("Add All (" + stp.getTable().getModel().getRowCount() + ")");
            //removeAllIndividuals.setText("Remove All (" + stp.getTable().getModel().getRowCount() + ")");
        }
    });

    ActionListener addAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            addSelections(false);
        }
    };

    ActionListener addAllAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            addSelections(true);
        }
    };

    ActionListener removeAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            removeSelections(false);
        }
    };

    ActionListener removeAllAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            removeSelections(true);
        }
    };

    addIndividuals.addActionListener(addAction);
    addAllIndividuals.addActionListener(addAllAction);
    removeIndividuals.addActionListener(removeAction);
    removeAllIndividuals.addActionListener(removeAllAction);

    this.pack();
    this.setLocationRelativeTo(MedSavantFrame.getInstance());
}

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

public Menu(JPanel panel) {

    resetMap();/*from w  w w.j  a va 2  s . com*/

    setLayout(new BorderLayout());

    primaryMenuButtons = new ButtonGroup();

    primaryMenu = ViewUtil.getPrimaryBannerPanel();

    secondaryMenu = new JPanel();
    secondaryMenu.setBackground(ViewUtil.getSecondaryMenuColor());

    tertiaryMenu = new JPanel();
    tertiaryMenu.setBorder(ViewUtil.getBottomLineBorder());
    tertiaryMenu.setBackground(Color.white);
    // tertiaryMenu.setBorder(ViewUtil.getMediumBorder());
    ViewUtil.applyHorizontalBoxLayout(tertiaryMenu);
    //tertiaryMenu.setMinimumSize(new Dimension(9999, 30));
    ViewUtil.applyHorizontalBoxLayout(tertiaryMenu);

    int padding = 5;

    primaryMenu.setLayout(new BoxLayout(primaryMenu, BoxLayout.X_AXIS));
    primaryMenu.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(150, 150, 150)),
            BorderFactory.createEmptyBorder(padding, padding, padding, padding)));

    primaryMenuSectionButtonContainer = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(primaryMenuSectionButtonContainer);

    NotificationsPanel n = NotificationsPanel.getNotifyPanel(NotificationsPanel.JOBS_PANEL_NAME);

    JPanel appStorePanel = ViewUtil.getClearPanel();
    JButton appStoreButton = ViewUtil
            .getIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.MENU_STORE));
    ViewUtil.applyHorizontalBoxLayout(appStorePanel);
    appStorePanel.add(ViewUtil.subTextComponent(appStoreButton, "App Store"));

    appStoreButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            MedSavantFrame.getInstance().showAppStore();
        }

    });

    int componentpadding = 10;
    primaryMenu.add(Box.createHorizontalStrut(componentpadding));
    primaryMenu.add(primaryMenuSectionButtonContainer);
    primaryMenu.add(Box.createHorizontalGlue());

    FlowLayout fl = new FlowLayout(FlowLayout.RIGHT, componentpadding, 1);
    JPanel rightSidePanel = ViewUtil.getClearPanel();
    rightSidePanel.setLayout(fl);
    rightSidePanel.add(updatesPanel);
    rightSidePanel.add(n);
    rightSidePanel.add(appStorePanel);
    rightSidePanel.add(getLoginMenuItem());
    primaryMenu.add(rightSidePanel);
    /*
    primaryMenu.add(updatesPanel);
    primaryMenu.add(ViewUtil.getMediumSeparator());
            
    primaryMenu.add(n);
    primaryMenu.add(ViewUtil.getMediumSeparator());
            
    primaryMenu.add(appStorePanel);
    primaryMenu.add(ViewUtil.getMediumSeparator());
    primaryMenu.add(getLoginMenuItem());
    */
    add(primaryMenu, BorderLayout.NORTH);

    secondaryMenu.setLayout(new BoxLayout(secondaryMenu, BoxLayout.Y_AXIS));
    //secondaryMenu.setBorder(ViewUtil.getRightLineBorder());

    secondaryMenu.setPreferredSize(new Dimension(150, 100));

    contentContainer = panel;

    ReferenceController.getInstance().addListener(new Listener<ReferenceEvent>() {
        @Override
        public void handleEvent(ReferenceEvent event) {
            if (event.getType() == ReferenceEvent.Type.CHANGED) {
                updateSections();
            }
        }
    });

    ProjectController.getInstance().addListener(new Listener<ProjectEvent>() {
        @Override
        public void handleEvent(ProjectEvent evt) {
            if (!GeneticsSection.isInitialized && evt.getType() == ProjectEvent.Type.CHANGED) {
                //once this section is initialized, referencecombobox fires
                //referencechanged event on every project change
                updateSections();
            }
        }
    });

    LoginController.getInstance().addListener(new Listener<LoginEvent>() {
        @Override
        public void handleEvent(LoginEvent evt) {
            if (evt.getType() == LoginEvent.Type.LOGGED_OUT) {
                contentContainer.removeAll();
                ViewController.getInstance().changeSubSectionTo(null);
                currentView = null;
                resetMap();
            }
        }
    });

    tertiaryMenuPanelVisibilityContainer = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(tertiaryMenuPanelVisibilityContainer);

    tertiaryMenuPanelAccessoryContainer = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(tertiaryMenuPanelAccessoryContainer);

    clearMenu();
}

From source file:org.zaproxy.zap.extension.fuzz.httpfuzzer.ui.HttpFuzzResultsContentPanel.java

public HttpFuzzResultsContentPanel() {
    super(new BorderLayout());

    tabbedPane = new JTabbedPane();

    toolbar = new JToolBar();
    toolbar.setFloatable(false);//from  w  w w  .  j  a  v  a2 s. c o  m
    toolbar.setRollover(true);

    messageCountLabel = new JLabel(Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.messagesSent"));
    messageCountValueLabel = new JLabel("0");

    errorCountLabel = new JLabel(Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.errors"));
    errorCountValueLabel = new JLabel("0");

    showErrorsToggleButton = new ZapToggleButton(
            Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.showErrors.label"));
    showErrorsToggleButton.setEnabled(false);
    showErrorsToggleButton.setToolTipText(
            Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.showErrors.tooltip"));
    showErrorsToggleButton.setSelectedToolTipText(
            Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.showErrors.tooltip.selected"));
    showErrorsToggleButton.setDisabledToolTipText(
            Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.showErrors.tooltip.disabled"));
    showErrorsToggleButton
            .setIcon(new ImageIcon(HttpFuzzResultsContentPanel.class.getResource("/resource/icon/16/050.png")));
    showErrorsToggleButton.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (ItemEvent.SELECTED == e.getStateChange()) {
                showTabs();
            } else {
                hideErrorsTab();
            }
        }
    });

    toolbar.add(Box.createHorizontalStrut(4));
    toolbar.add(messageCountLabel);
    toolbar.add(Box.createHorizontalStrut(4));
    toolbar.add(messageCountValueLabel);
    toolbar.add(Box.createHorizontalStrut(32));

    toolbar.add(errorCountLabel);
    toolbar.add(Box.createHorizontalStrut(4));
    toolbar.add(errorCountValueLabel);

    toolbar.add(Box.createHorizontalStrut(16));
    toolbar.add(showErrorsToggleButton);

    JButton button = new JButton(Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.export"));
    button.setIcon(new ImageIcon(HttpFuzzResultsContentPanel.class.getResource("/resource/icon/16/115.png")));
    button.addActionListener((new AbstractAction() {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            WritableFileChooser chooser = new WritableFileChooser(
                    Model.getSingleton().getOptionsParam().getUserDirectory()) {

                private static final long serialVersionUID = -1660943014924270012L;

                @Override
                public void approveSelection() {
                    File file = getSelectedFile();
                    if (file != null) {
                        String filePath = file.getAbsolutePath();
                        if (!filePath.toLowerCase(Locale.ROOT).endsWith(CSV_EXTENSION)) {
                            setSelectedFile(new File(filePath + CSV_EXTENSION));
                        }
                    }

                    super.approveSelection();
                }
            };
            chooser.setSelectedFile(new File(
                    Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.export.defaultName")));
            if (chooser
                    .showSaveDialog(View.getSingleton().getMainFrame()) == WritableFileChooser.APPROVE_OPTION) {

                boolean success = true;
                try (CSVPrinter pw = new CSVPrinter(
                        Files.newBufferedWriter(chooser.getSelectedFile().toPath(), StandardCharsets.UTF_8),
                        CSVFormat.DEFAULT)) {
                    pw.printRecord(currentFuzzer.getMessagesModel().getHeaders());
                    int count = currentFuzzer.getMessagesModel().getRowCount();
                    for (int i = 0; i < count; i++) {
                        List<Object> valueOfRow = currentFuzzer.getMessagesModel().getEntry(i)
                                .getValuesOfHeaders();
                        String customStateValue = fuzzResultTable.getCustomStateValue(
                                currentFuzzer.getMessagesModel().getEntry(i).getCustomStates());
                        valueOfRow.add(13, customStateValue);
                        pw.printRecord(valueOfRow);
                    }
                } catch (Exception ex) {
                    success = false;
                    JOptionPane.showMessageDialog(View.getSingleton().getMainFrame(),
                            Constant.messages
                                    .getString("fuzz.httpfuzzer.results.toolbar.button.export.showMessageError")
                                    + "\n" + ex.getLocalizedMessage());
                    logger.error("Export Failed: " + ex);
                }
                // Delay the presentation of success message, to ensure all the data was
                // already flushed.
                if (success) {
                    JOptionPane.showMessageDialog(View.getSingleton().getMainFrame(), Constant.messages
                            .getString("fuzz.httpfuzzer.results.toolbar.button.export.showMessageSuccessful"));
                }
            }
        }
    }));
    toolbar.add(Box.createHorizontalGlue());
    toolbar.add(button);
    mainPanel = new JPanel(new BorderLayout());

    fuzzResultTable = new HttpFuzzerResultsTable(RESULTS_PANEL_NAME, EMPTY_RESULTS_MODEL);
    errorsTable = new HttpFuzzerErrorsTable(ERRORS_PANEL_NAME, EMPTY_ERRORS_MODEL);

    fuzzResultTableScrollPane = new JScrollPane();
    fuzzResultTableScrollPane.setViewportView(fuzzResultTable);

    errorsTableScrollPane = new JScrollPane();
    errorsTableScrollPane.setViewportView(errorsTable);

    mainPanel.add(fuzzResultTableScrollPane);

    add(toolbar, BorderLayout.PAGE_START);
    add(mainPanel, BorderLayout.CENTER);
}

From source file:pcgen.gui2.dialog.CharacterHPDialog.java

private void initComponents() {
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());
    JTable table = new JTable(tableModel) {

        @Override/*from   w ww. java  2 s  . c  om*/
        public TableCellEditor getCellEditor(int row, int column) {
            if (column == 5) {//TODO: the max roll should be calculated in a different manner
                String hd = levels.getClassTaken(levels.getElementAt(row)).getHD();
                int max = NumberUtils.toInt(hd);
                return new IntegerEditor(1, max);
            } else {
                return super.getCellEditor(row, column);
            }
        }

    };
    table.setDefaultRenderer(JButton.class, new Renderer());
    table.setDefaultEditor(JButton.class, new Editor());
    table.setCellSelectionEnabled(false);
    table.setRowHeight(new IntegerEditor(1, 10).getPreferredSize().height);
    JTableHeader header = table.getTableHeader();
    header.setReorderingAllowed(false);

    JScrollPane scrollPane = new JScrollPane(table);
    pane.add(scrollPane, BorderLayout.CENTER);

    Box box = Box.createHorizontalBox();
    box.add(new JLabel("Total Hp:"));
    box.add(Box.createHorizontalStrut(3));

    final ReferenceListener<Integer> hpListener = new ReferenceListener<Integer>() {

        @Override
        public void referenceChanged(ReferenceEvent<Integer> e) {
            totalHp.setText(e.getNewReference().toString());
        }

    };
    ReferenceFacade<Integer> hpRef = character.getTotalHPRef();
    totalHp.setText(hpRef.get().toString());
    hpRef.addReferenceListener(hpListener);
    box.add(totalHp);
    box.add(Box.createHorizontalStrut(5));

    JButton button = new JButton("Reroll All");
    button.setActionCommand("Reroll");
    button.addActionListener(this);
    box.add(button);

    box.add(Box.createHorizontalGlue());
    button = new JButton("Close");
    button.setActionCommand("Close");
    button.addActionListener(this);
    box.add(button);
    pane.add(box, BorderLayout.SOUTH);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(WindowEvent e) {
            //Make sure to remove the listeners so that the garbage collector can
            //dispose of this dialog and prevent a memory leak
            levels.removeHitPointListener(tableModel);
            character.getTotalHPRef().removeReferenceListener(hpListener);
        }

    });

    Utility.installEscapeCloseOperation(this);
}

From source file:pcgen.gui2.dialog.ExportDialog.java

private void initLayout() {
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    Box topPanel = Box.createHorizontalBox();
    topPanel.add(new JLabel("Select Character:"));
    topPanel.add(Box.createHorizontalStrut(5));
    topPanel.add(characterBox);//from  w w  w  . ja  va 2  s .  c  om
    topPanel.add(Box.createHorizontalStrut(5));
    topPanel.add(partyBox);
    topPanel.add(Box.createHorizontalGlue());
    topPanel.add(Box.createHorizontalStrut(50));
    topPanel.add(new JLabel("Export to:"));
    topPanel.add(Box.createHorizontalStrut(5));
    topPanel.add(exportBox);
    contentPane.add(topPanel, BorderLayout.NORTH);

    JScrollPane scrollPane = new JScrollPane(fileList);
    scrollPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Templates"),
            scrollPane.getBorder()));
    contentPane.add(scrollPane, BorderLayout.CENTER);

    Box bottomPanel = Box.createHorizontalBox();
    bottomPanel.add(progressBar);
    bottomPanel.add(Box.createHorizontalGlue());
    bottomPanel.add(Box.createHorizontalStrut(5));
    bottomPanel.add(exportButton);
    bottomPanel.add(Box.createHorizontalStrut(5));
    bottomPanel.add(closeButton);
    contentPane.add(bottomPanel, BorderLayout.SOUTH);

    topPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    bottomPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    pack();
}

From source file:pcgen.gui2.dialog.PrintPreviewDialog.java

private void initLayout() {
    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());
    {//layout top bar
        JPanel bar = new JPanel(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.anchor = GridBagConstraints.BASELINE;
        gbc.insets = new Insets(8, 6, 8, 2);
        bar.add(new JLabel("Select Template:"), gbc);
        gbc.insets = new Insets(8, 2, 8, 6);
        gbc.weightx = 1;//from  w  w  w . j  a v  a 2s.  co m
        bar.add(sheetBox, gbc);
        pane.add(bar, BorderLayout.NORTH);
    }
    {
        Box vbox = Box.createVerticalBox();
        previewPanelParent.setPreferredSize(new Dimension(600, 800));
        vbox.add(previewPanelParent);
        vbox.add(progressBar);
        pane.add(vbox, BorderLayout.CENTER);
    }
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(new JLabel("Page:"));
        hbox.add(Box.createHorizontalStrut(4));
        hbox.add(pageBox);
        hbox.add(Box.createHorizontalStrut(10));
        hbox.add(new JLabel("Zoom:"));
        hbox.add(Box.createHorizontalStrut(4));
        hbox.add(zoomBox);
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(zoomInButton);
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(zoomOutButton);
        hbox.add(Box.createHorizontalGlue());
        hbox.add(printButton);
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(cancelButton);
        hbox.setBorder(BorderFactory.createEmptyBorder(8, 5, 8, 5));
        pane.add(hbox, BorderLayout.SOUTH);
    }
}

From source file:pcgen.gui2.sources.AdvancedSourceSelectionPanel.java

private void initComponents() {
    FlippingSplitPane mainPane = new FlippingSplitPane(JSplitPane.VERTICAL_SPLIT, "advSrcMain");
    FlippingSplitPane topPane = new FlippingSplitPane("advSrcTop");
    topPane.setResizeWeight(0.6);//from   w  w w .  j a  va 2s .com
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(new JLabel(LanguageBundle.getString("in_src_gameLabel")), BorderLayout.WEST); //$NON-NLS-1$

    FacadeComboBoxModel<GameModeDisplayFacade> gameModes = new FacadeComboBoxModel<>();
    gameModes.setListFacade(FacadeFactory.getGameModeDisplays());
    gameModeList.setModel(gameModes);
    gameModeList.addActionListener(this);
    panel.add(gameModeList, BorderLayout.CENTER);

    FilterBar<Object, CampaignFacade> bar = new FilterBar<>(false);
    bar.add(panel, BorderLayout.WEST);
    bar.addDisplayableFilter(new SearchFilterPanel());
    panel = new JPanel(new BorderLayout());
    panel.add(bar, BorderLayout.NORTH);

    availableTable.setDisplayableFilter(bar);
    availableTable.setTreeViewModel(availTreeViewModel);
    availableTable.getSelectionModel().addListSelectionListener(this);
    availableTable.setTreeCellRenderer(new CampaignRenderer());
    ((DynamicTableColumnModel) availableTable.getColumnModel()).getAvailableColumns().get(2)
            .setCellRenderer(new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));

    JScrollPane pane = new JScrollPane(availableTable);
    pane.setPreferredSize(new Dimension(600, 310));
    panel.add(pane, BorderLayout.CENTER);

    Box box = Box.createHorizontalBox();
    unloadAllButton.setAction(new UnloadAllAction());
    box.add(unloadAllButton);
    box.add(Box.createHorizontalGlue());
    addButton.setHorizontalTextPosition(SwingConstants.LEADING);
    addButton.setAction(new AddAction());
    box.add(addButton);
    box.add(Box.createHorizontalStrut(5));
    box.setBorder(new EmptyBorder(0, 0, 5, 0));
    panel.add(box, BorderLayout.SOUTH);

    topPane.setLeftComponent(panel);

    JPanel selPanel = new JPanel(new BorderLayout());
    FilterBar<Object, CampaignFacade> filterBar = new FilterBar<>();
    filterBar.addDisplayableFilter(new SearchFilterPanel());
    selectedTable.setDisplayableFilter(filterBar);

    selectedTable.setTreeViewModel(selTreeViewModel);
    selectedTable.getSelectionModel().addListSelectionListener(this);
    selectedTable.setTreeCellRenderer(new CampaignRenderer());
    ((DynamicTableColumnModel) selectedTable.getColumnModel()).getAvailableColumns().get(2)
            .setCellRenderer(new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));
    JScrollPane scrollPane = new JScrollPane(selectedTable);
    scrollPane.setPreferredSize(new Dimension(300, 350));
    selPanel.add(scrollPane, BorderLayout.CENTER);
    box = Box.createHorizontalBox();
    box.add(Box.createHorizontalStrut(5));
    removeButton.setAction(new RemoveAction());
    box.add(removeButton);
    box.add(Box.createHorizontalGlue());
    box.setBorder(new EmptyBorder(0, 0, 5, 0));
    selPanel.add(box, BorderLayout.SOUTH);

    topPane.setRightComponent(selPanel);
    mainPane.setTopComponent(topPane);

    linkAction.install();
    infoPane.setPreferredSize(new Dimension(800, 150));
    mainPane.setBottomComponent(infoPane);
    mainPane.setResizeWeight(0.7);
    setLayout(new BorderLayout());
    add(mainPane, BorderLayout.CENTER);
}

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

private void initComponents() {
    setOrientation(VERTICAL_SPLIT);//from w  w  w. j a  va 2 s.co m

    JPanel panel = new JPanel(new BorderLayout());
    FilterBar bar = new FilterBar();
    bar.addDisplayableFilter(new SearchFilterPanel());
    deityTable.setDisplayableFilter(bar);
    panel.add(bar, BorderLayout.NORTH);

    deityTable.setSortingPriority(Collections.singletonList(new SortingPriority(0, SortMode.ASCENDING)));
    deityTable.sortModel();
    ListSelectionModel selectionModel = deityTable.getSelectionModel();
    selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    panel.add(new JScrollPane(deityTable), BorderLayout.CENTER);

    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    box.add(new JLabel("Deity:"));
    box.add(Box.createHorizontalStrut(5));
    box.add(selectedDeity);
    box.add(Box.createHorizontalStrut(5));
    box.add(selectDeity);
    box.add(Box.createHorizontalGlue());
    panel.add(box, BorderLayout.SOUTH);

    FlippingSplitPane splitPane = new FlippingSplitPane();
    splitPane.setLeftComponent(panel);

    panel = new JPanel(new BorderLayout());
    bar = new FilterBar();
    bar.addDisplayableFilter(new SearchFilterPanel());
    domainFilter = bar;
    panel.add(bar, BorderLayout.NORTH);
    selectionModel = domainTable.getSelectionModel();
    selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane scrollPane = TableUtils.createCheckBoxSelectionPane(domainTable, domainRowHeaderTable);
    panel.add(scrollPane, BorderLayout.CENTER);

    box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    box.add(new JLabel("Domains Remaining to be Selected:"));
    box.add(Box.createHorizontalStrut(5));
    box.add(selectedDomain);
    box.add(Box.createHorizontalGlue());

    panel.add(box, BorderLayout.SOUTH);

    splitPane.setRightComponent(panel);
    setTopComponent(splitPane);
    splitPane = new FlippingSplitPane();
    splitPane.setLeftComponent(deityInfo);
    splitPane.setRightComponent(domainInfo);
    setBottomComponent(splitPane);
    setResizeWeight(.65);
}