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);
}
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);
}
}
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;
}
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);
}
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);
}
Aggregations