Search in sources :

Example 21 with Component

use of java.awt.Component in project pcgen by PCGen.

the class SplashScreen method initComponents.

private void initComponents() {
    JComponent pane = new JPanel(new BorderLayout());
    pane.setBorder(BorderFactory.createLineBorder(Color.BLACK, 3));
    Component splashLabel = new JLabel(Icons.SplashPcgen_Ennie.getImageIcon());
    pane.add(splashLabel, BorderLayout.NORTH);
    loadingLabel.setBorder(BorderFactory.createEmptyBorder(10, 7, 10, 10));
    pane.add(loadingLabel, BorderLayout.CENTER);
    loadProgress.setStringPainted(true);
    pane.add(loadProgress, BorderLayout.SOUTH);
    Container cont = getContentPane();
    cont.setLayout(new GridLayout(1, 1));
    cont.add(pane);
    pack();
    setLocationRelativeTo(null);
}
Also used : JPanel(javax.swing.JPanel) Container(java.awt.Container) GridLayout(java.awt.GridLayout) BorderLayout(java.awt.BorderLayout) JComponent(javax.swing.JComponent) JLabel(javax.swing.JLabel) JComponent(javax.swing.JComponent) Component(java.awt.Component)

Example 22 with Component

use of java.awt.Component in project pcgen by PCGen.

the class StatTableModel method install.

public void install() {
    table.setModel(this);
    table.setDefaultRenderer(Object.class, renderer);
    TableColumn abilityColumn = table.getColumn(ABILITY_COLUMN_ID);
    int columnIndex = abilityColumn.getModelIndex();
    int maxWidth = 0;
    for (StatFacade aStat : stats) {
        Component cell = renderer.getTableCellRendererComponent(table, aStat, false, false, -1, columnIndex);
        maxWidth = Math.max(maxWidth, cell.getPreferredSize().width);
    }
    //we add some extra spacing to prevent ellipses from showing
    abilityColumn.setPreferredWidth(maxWidth + 4);
    TableColumn column = table.getColumn(EDITABLE_COLUMN_ID);
    column.setCellRenderer(new TableCellUtilities.SpinnerRenderer());
    column.setCellEditor(editor);
    Dimension size = table.getPreferredSize();
    size.width = table.getTableHeader().getPreferredSize().width;
    JScrollPane scrollPane = (JScrollPane) table.getParent().getParent();
    //we want to add room for the vertical scroll bar so it doesn't
    //overlap with the table when it shows
    int vbarWidth = scrollPane.getVerticalScrollBar().getPreferredSize().width;
    size.width += vbarWidth;
    table.setPreferredScrollableViewportSize(size);
    //because of the extra viewport size in the table it will
    //always look a bit off center, adding a row header to
    //the scroll pane fixes this
    scrollPane.setRowHeaderView(Box.createHorizontalStrut(vbarWidth));
    for (StatFacade aStat : stats) {
        character.getScoreBaseRef(aStat).addReferenceListener(this);
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) StatFacade(pcgen.facade.core.StatFacade) Dimension(java.awt.Dimension) JComponent(javax.swing.JComponent) Component(java.awt.Component) TableColumn(javax.swing.table.TableColumn) TableCellUtilities(pcgen.gui2.util.table.TableCellUtilities)

Example 23 with Component

use of java.awt.Component in project pcgen by PCGen.

the class SpinningTabbedPane method getSpinTabCount.

private int getSpinTabCount() {
    int n = getTabCount();
    for (int i = 0, x = n; i < x; ++i) {
        Component c = getComponentAt(i);
        if (!(c instanceof SpinningTabbedPane)) {
            continue;
        }
        // don't count the spun tab itself
        n -= 1;
        n += ((SpinningTabbedPane) c).getSpinTabCount();
    }
    return n;
}
Also used : Component(java.awt.Component) Point(java.awt.Point)

Example 24 with Component

use of java.awt.Component in project pcgen by PCGen.

the class SpinningTabbedPane method spinTabsAt.

/**
     * Spin tabs starting at index to the end, stopping when we find
     * another spun tab.  If the first tab is itself spun, spin it as
     * well; this permits spinning of spun tabs as a special case.
     *
     * @param index start spinning tabs here
     * @param placement direction to place spun tabs
     */
private void spinTabsAt(int index, int placement) {
    SpinningTabbedPane pane = SpinningTabbedPane.createPane();
    moveTabAtTo(index, -1, pane);
    for (int i = index, x = getTabCount(); i < x; ++i) {
        Component c = getComponentAt(index);
        if (c instanceof SpinningTabbedPane) {
            break;
        }
        moveTabAtTo(index, -1, pane);
    }
    add(pane, index);
    // get count added
    setTitleAt(index, "");
    pane.parent = this;
    pane.setTabPlacement(placement);
    updateTabUIAt(index);
}
Also used : Component(java.awt.Component) Point(java.awt.Point)

Example 25 with Component

use of java.awt.Component in project pcgen by PCGen.

the class PrintPreviewDialog method initComponents.

private void initComponents() {
    setTitle("Print Preview");
    sheetBox.setRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (value != null) {
                setToolTipText(value.toString());
            }
            return this;
        }
    });
    sheetBox.setActionCommand(SHEET_COMMAND);
    sheetBox.addActionListener(this);
    pageBox.addItem("0 of 0");
    pageBox.setActionCommand(PAGE_COMMAND);
    pageBox.addActionListener(this);
    zoomBox.addItem(0.25);
    zoomBox.addItem(0.50);
    zoomBox.addItem(0.75);
    zoomBox.addItem(1.00);
    zoomBox.setSelectedItem(0.75);
    zoomBox.setRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            NumberFormat format = NumberFormat.getPercentInstance();
            value = format.format(value);
            return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        }
    });
    zoomBox.setEditable(true);
    zoomBox.setEditor(new PercentEditor(zoomBox));
    zoomBox.setActionCommand(ZOOM_COMMAND);
    zoomBox.addActionListener(this);
    zoomInButton.setIcon(Icons.ZoomIn16.getImageIcon());
    zoomInButton.setActionCommand(ZOOM_IN_COMMAND);
    zoomInButton.addActionListener(this);
    zoomOutButton.setIcon(Icons.ZoomOut16.getImageIcon());
    zoomOutButton.setActionCommand(ZOOM_OUT_COMMAND);
    zoomOutButton.addActionListener(this);
    printButton.setText("Print");
    printButton.setActionCommand(PRINT_COMMAND);
    printButton.addActionListener(this);
    cancelButton.setText("Cancel");
    cancelButton.setActionCommand(CANCEL_COMMAND);
    cancelButton.addActionListener(this);
    enableEditGroup(false);
    Utility.installEscapeCloseOperation(this);
}
Also used : DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) Component(java.awt.Component) JComponent(javax.swing.JComponent) JList(javax.swing.JList) NumberFormat(java.text.NumberFormat)

Aggregations

Component (java.awt.Component)645 JComponent (javax.swing.JComponent)163 Dimension (java.awt.Dimension)81 JLabel (javax.swing.JLabel)65 JPanel (javax.swing.JPanel)60 Insets (java.awt.Insets)55 Point (java.awt.Point)55 TableCellRenderer (javax.swing.table.TableCellRenderer)47 Container (java.awt.Container)46 JScrollPane (javax.swing.JScrollPane)42 JTable (javax.swing.JTable)36 JButton (javax.swing.JButton)35 BorderLayout (java.awt.BorderLayout)34 GridBagConstraints (java.awt.GridBagConstraints)34 JTextComponent (javax.swing.text.JTextComponent)34 GridBagLayout (java.awt.GridBagLayout)33 Color (java.awt.Color)32 JList (javax.swing.JList)31 TableColumn (javax.swing.table.TableColumn)31 MouseEvent (java.awt.event.MouseEvent)27