use of javax.swing.DefaultListCellRenderer in project pcgen by PCGen.
the class SkillInfoTab method initComponents.
private void initComponents() {
setOrientation(VERTICAL_SPLIT);
setResizeWeight(0.70);
JSpinner spinner = new JSpinner();
//$NON-NLS-1$
spinner.setEditor(new JSpinner.NumberEditor(spinner, "#0.#"));
skillTable.setDefaultRenderer(Float.class, new SpinnerRenderer(spinner));
skillTable.setDefaultRenderer(Integer.class, new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));
skillTable.setDefaultRenderer(String.class, new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));
skillTable.setRowHeight(26);
FilterBar<CharacterFacade, SkillFacade> filterBar = new FilterBar<>();
filterBar.addDisplayableFilter(new SearchFilterPanel());
//$NON-NLS-1$
cFilterButton.setText(LanguageBundle.getString("in_classString"));
cFilterButton.setEnabled(false);
filterBar.addDisplayableFilter(cFilterButton);
//$NON-NLS-1$
trainedFilterButton.setText(LanguageBundle.getString("in_trained"));
trainedFilterButton.setEnabled(false);
filterBar.addDisplayableFilter(trainedFilterButton);
JPanel availPanel = FilterUtilities.configureFilteredTreeViewPane(skillTable, filterBar);
availPanel.setPreferredSize(new Dimension(650, 300));
JScrollPane tableScrollPane;
JPanel tablePanel = new JPanel(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
constraints.fill = java.awt.GridBagConstraints.BOTH;
constraints.weightx = 1.0;
constraints.ipady = 0;
constraints.weighty = 1.0;
SkillPointTableModel.initializeTable(skillpointTable);
tableScrollPane = new JScrollPane(skillpointTable);
tablePanel.add(tableScrollPane, constraints);
htmlPane.setOpaque(false);
htmlPane.setEditable(false);
htmlPane.setFocusable(false);
//$NON-NLS-1$
htmlPane.setContentType("text/html");
skillFilterBox.setRenderer(new DefaultListCellRenderer());
JScrollPane selScrollPane = new JScrollPane(htmlPane);
JPanel skillPanel = new JPanel(new BorderLayout());
skillPanel.add(skillFilterBox, BorderLayout.NORTH);
skillPanel.add(selScrollPane, BorderLayout.CENTER);
selScrollPane.setPreferredSize(new Dimension(530, 300));
FlippingSplitPane topPane = new FlippingSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, availPanel, skillPanel, "SkillTop");
setTopComponent(topPane);
FlippingSplitPane bottomPane = new FlippingSplitPane(JSplitPane.HORIZONTAL_SPLIT, "SkillBottom");
bottomPane.setLeftComponent(tablePanel);
tablePanel.setPreferredSize(new Dimension(650, 100));
bottomPane.setRightComponent(infoPane);
infoPane.setPreferredSize(new Dimension(530, 100));
setBottomComponent(bottomPane);
}
use of javax.swing.DefaultListCellRenderer 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);
}
use of javax.swing.DefaultListCellRenderer in project EnrichmentMapApp by BaderLab.
the class ControlPanel method getEmViewCombo.
JComboBox<CyNetworkView> getEmViewCombo() {
if (emViewCombo == null) {
emViewCombo = new JComboBox<>();
emViewCombo.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 instanceof CyNetworkView)
this.setText(NetworkUtil.getTitle((CyNetworkView) value));
else
this.setText("-- Select EnrichmentMap View --");
return this;
}
});
}
return emViewCombo;
}
use of javax.swing.DefaultListCellRenderer in project cayenne by apache.
the class PreferenceDialogView method init.
private void init() {
split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
split.setBorder(TopBorder.create());
list = new JList<>();
list.setCellRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
setBorder(BorderFactory.createEmptyBorder(5, 8, 5, 0));
return this;
}
});
list.setFont(new JLabel().getFont().deriveFont(Font.BOLD, 12));
detailLayout = new CardLayout();
detailPanel = new JPanel(detailLayout);
saveButton = new JButton("Save");
cancelButton = new JButton("Cancel");
// assemble
Container leftContainer = new JPanel(new BorderLayout());
JScrollPane scrollPane = new JScrollPane(list);
scrollPane.setBorder(BorderFactory.createEmptyBorder());
leftContainer.add(scrollPane);
leftContainer.setPreferredSize(new Dimension(180, 400));
split.setLeftComponent(leftContainer);
split.setRightComponent(detailPanel);
split.setDividerSize(3);
JPanel buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT));
buttons.add(cancelButton);
buttons.add(saveButton);
buttons.setBorder(TopBorder.create());
getContentPane().setLayout(new BorderLayout());
getContentPane().add(split, BorderLayout.CENTER);
getContentPane().add(buttons, BorderLayout.SOUTH);
setTitle("Edit Preferences");
}
use of javax.swing.DefaultListCellRenderer in project knime-core by knime.
the class MissingValuePanel method getFixTextField.
/*
* Helper in constructor, generates the text field to enter the replacement
* value.
*/
private static JComponent getFixTextField(final ColSetting setting, final DataColumnSpec spec) {
JComponent fixText;
// FIX text field
DataCell fixCell = setting.getFixCell();
switch(setting.getType()) {
case ColSetting.TYPE_DOUBLE:
fixText = new JFormattedTextField();
((JFormattedTextField) fixText).setColumns(8);
Double doubel;
if (fixCell == null) {
doubel = new Double(0.0);
} else {
double d = ((DoubleValue) fixCell).getDoubleValue();
doubel = new Double(d);
}
((JFormattedTextField) fixText).setValue(doubel);
break;
case ColSetting.TYPE_INT:
fixText = new JFormattedTextField();
((JFormattedTextField) fixText).setColumns(8);
Integer integer;
if (fixCell == null) {
integer = new Integer(0);
} else {
int i = ((IntValue) fixCell).getIntValue();
integer = new Integer(i);
}
((JFormattedTextField) fixText).setValue(integer);
break;
case ColSetting.TYPE_STRING:
DataCell[] vals;
if (spec != null && spec.getDomain().hasValues()) {
vals = spec.getDomain().getValues().toArray(new DataCell[0]);
} else {
vals = new DataCell[0];
}
DefaultComboBoxModel model = new DefaultComboBoxModel(vals);
fixText = new JComboBox(model);
((JComboBox) fixText).setPrototypeDisplayValue("#########");
((JComboBox) fixText).setEditable(true);
((JComboBox) fixText).setRenderer(new DefaultListCellRenderer() {
/**
* Overridden to set tooltip text properly.
* @see DefaultListCellRenderer#getListCellRendererComponent(
* JList, Object, int, boolean, boolean)
*/
@Override
public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) {
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (c instanceof JComponent) {
((JComponent) c).setToolTipText(value.toString());
}
return c;
}
});
String string;
if (fixCell == null) {
string = "";
} else {
string = ((StringValue) fixCell).getStringValue();
}
model.setSelectedItem(string);
break;
default:
throw new InternalError("No such type");
}
return fixText;
}
Aggregations