本文整理匯總了Java中org.jdesktop.swingx.JXTable.addHighlighter方法的典型用法代碼示例。如果您正苦於以下問題:Java JXTable.addHighlighter方法的具體用法?Java JXTable.addHighlighter怎麽用?Java JXTable.addHighlighter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jdesktop.swingx.JXTable
的用法示例。
在下文中一共展示了JXTable.addHighlighter方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: interactiveValueBasedGradientHighlightPlusStriping
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Use transparent gradient painter for value-based background highlighting
* with SwingX extended default renderer. Shared by table and list with
* striping.
*/
public void interactiveValueBasedGradientHighlightPlusStriping() {
TableModel model = new AncientSwingTeam();
JXTable table = new JXTable(model);
ComponentProvider<JLabel> controller = new LabelProvider(
JLabel.RIGHT) ;
RelativePainterHighlighter gradientHighlighter =
createRelativeGradientHighlighter(HorizontalAlignment.RIGHT, 100);
table.addHighlighter(gradientHighlighter);
Highlighter alternateRowHighlighter = HighlighterFactory.createSimpleStriping();
table.addHighlighter(alternateRowHighlighter);
table.addHighlighter(gradientHighlighter);
// re-use component controller and highlighter in a JXList
JXList list = new JXList(createListNumberModel(), true);
list.setCellRenderer(new DefaultListRenderer(controller));
list.addHighlighter(alternateRowHighlighter);
list.addHighlighter(gradientHighlighter);
list.toggleSortOrder();
final JXFrame frame = wrapWithScrollingInFrame(table, list,
"transparent value relative highlighting plus striping");
addStatusMessage(frame,
"uses a PainterAwareLabel in renderer");
// crude binding to play with options - the factory is incomplete...
// addStatusComponent(frame, createTransparencyToggle(gradientHighlighter));
// show(frame);
}
示例2: interactiveTableColorBasedOnComponentValue
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Example of custom predicate based on the component's value,
* (as opposed to on the value of the adapter).
*
*
*/
public void interactiveTableColorBasedOnComponentValue() {
TableModel model = new AncientSwingTeam();
JXTable table = new JXTable(model);
table.setForeground(Color.GREEN);
HighlightPredicate predicate = new HighlightPredicate() {
@Override
public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
if (!(renderer instanceof JLabel)) return false;
String text = ((JLabel) renderer).getText();
return text.contains("y");
}
};
ColorHighlighter hl = new ColorHighlighter(predicate, null, Color.RED);
table.addHighlighter(HighlighterFactory.createSimpleStriping(HighlighterFactory.GENERIC_GRAY));
table.addHighlighter(hl);
showWithScrollingInFrame(table,
"component value-based rendering (label text contains y) ");
}
示例3: interactiveColumnHighlighterChange
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Regression Issue ?? swingx: column highlighter change must update view.
*/
public void interactiveColumnHighlighterChange() {
final ColorHighlighter hl = new ColorHighlighter(HighlightPredicate.ODD, Color.RED, Color.BLACK);
JXTable table = new JXTable(new AncientSwingTeam());
table.getColumnExt(0).addHighlighter(hl);
Action action = new AbstractAction("toggle column color") {
@Override
public void actionPerformed(ActionEvent e) {
Color old = hl.getBackground();
hl.setBackground(old == Color.red ? Color.ORANGE : Color.RED);
}
};
table.addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, null, Color.RED));
JXFrame frame = wrapWithScrollingInFrame(table, "column highlighter update");
addAction(frame, action);
addMessage(frame, "toggle column color between orange/red must update immediately");
show(frame);
}
示例4: interactiveSimpleStriping
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* shows the effect of a simple striping highlighter on a
* colored table.
*
*/
public void interactiveSimpleStriping() {
JXTable table = new JXTable(tableModel);
table.setVisibleRowCount(table.getRowCount() + 3);
table.setBackground(new Color(0xC0FFC0));
table.addHighlighter(HighlighterFactory.createSimpleStriping());
Highlighter disabled = new AbstractHighlighter(HighlightPredicate.READ_ONLY) {
@Override
protected Component doHighlight(Component component,
ComponentAdapter adapter) {
component.setEnabled(false);
return component;
}
};
table.getColumnExt(0).setEditable(false);
table.getColumnExt(2).setEditable(false);
table.getColumnExt(0).setCellRenderer(new DefaultTableRenderer(new TextFieldProvider()));
table.addHighlighter(disabled);
showWithScrollingInFrame(table, "Simple gray striping");
}
示例5: interactiveCheckBoxRendererOpacity1513
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Issue #1513-swingx: opacity of JRendererCheckBox can't be effected by
* client code.
*
* Here's a use-case: make all components in the stack not-opaque to show
* a background image. (note: opacity not false for number column)
*/
public void interactiveCheckBoxRendererOpacity1513() {
JXPanel panel = new JXPanel(new BorderLayout());
panel.setBackgroundPainter(new ImagePainter(XTestUtils.loadDefaultImage("moon.jpg")));
JXTable table = new JXTable(new AncientSwingTeam());
table.addHighlighter(HighlighterFactory.createSimpleStriping());
table.addHighlighter(new PainterHighlighter(HighlightPredicate.ROLLOVER_ROW,
new MattePainter(PaintUtils.setAlpha(Color.RED, 100))));
// new BusyPainter()));
panel.add(new JScrollPane(table));
table.setOpaque(false);
JComponent comp = (JComponent) table.prepareRenderer(0, 0);
comp.setOpaque(false);
AbstractButton checkBox = (AbstractButton) table.prepareRenderer(0, AncientSwingTeam.BOOLEAN_COLUMN);
checkBox.setOpaque(false);
((JComponent) table.getParent()).setOpaque(false);
((JComponent) table.getParent().getParent()).setOpaque(false);
showInFrame(panel, "Checkbox: set to opacity");
}
示例6: interactiveIconPainterHighlight
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Use highlighter with background image painter. Shared by table and list.
*/
public void interactiveIconPainterHighlight() throws Exception {
TableModel model = new AncientSwingTeam();
JXTable table = new JXTable(model);
ComponentProvider<JLabel> controller = new LabelProvider(
JLabel.RIGHT);
table.getColumn(0).setCellRenderer(
new DefaultTableRenderer(controller));
final ImagePainter imagePainter = new ImagePainter(XTestUtils.loadDefaultImage());
HighlightPredicate predicate = new ColumnHighlightPredicate(0);
Highlighter iconHighlighter = new PainterHighlighter(predicate, imagePainter );
Highlighter alternateRowHighlighter = HighlighterFactory.createSimpleStriping();
table.addHighlighter(alternateRowHighlighter);
table.addHighlighter(iconHighlighter);
// re-use component controller and highlighter in a JXList
JXList list = new JXList(createListNumberModel(), true);
list.setCellRenderer(new DefaultListRenderer(controller));
list.addHighlighter(alternateRowHighlighter);
list.addHighlighter(iconHighlighter);
list.toggleSortOrder();
final JXFrame frame = showWithScrollingInFrame(table, list,
"image highlighting plus striping");
frame.pack();
}
示例7: interactiveXLabelRenderer
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Quick example of using a JXLabel as rendering component.
* Looks funny .. wrapping jumps?
*/
public void interactiveXLabelRenderer() {
DefaultTableModel model = new DefaultTableModel(0, 1);
model.addRow(new String[] {"some really, maybe really really long text - "
+ "wrappit .... where needed "});
model.addRow(new String[] {"another really, maybe really really long text - "
+ "with nothing but junk. wrappit .... where needed"});
JXTable table = new JXTable(model);
table.setVisibleRowCount(4);
table.setVisibleColumnCount(2);
table.setColumnControlVisible(true);
table.getColumnExt(0).setCellRenderer(new DefaultTableRenderer(new XLabelProvider()));
table.addHighlighter(
HighlighterFactory.createAlternateStriping());
table.setRowHeight(50);
showWithScrollingInFrame(table, "textArea as rendering comp");
}
示例8: interactiveColorValueMappedHighlighterPredicate
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Example to highlight against a value/color map.
* Here the control is in predicate. <p>
*
*/
public void interactiveColorValueMappedHighlighterPredicate() {
JXTable table = new JXTable(new AncientSwingTeam());
// build a quick color lookup to simulate multi-value value-based
// coloring
final int numberColumn = 3;
table.toggleSortOrder(numberColumn);
Color[] colors = new Color[] { Color.YELLOW, Color.CYAN, Color.MAGENTA,
Color.GREEN };
int rowsPerColor = (table.getRowCount() - 5) / colors.length;
Map<Color, HighlightPredicate> map = new HashMap<Color, HighlightPredicate>();
for (int i = 0; i < colors.length; i++) {
List<Integer> values = new ArrayList<Integer>();
for (int j = 0; j < rowsPerColor; j++) {
values.add((Integer) table.getValueAt(i * rowsPerColor + j, numberColumn));
}
map.put(colors[i], new ValueMappedHighlightPredicate(values, numberColumn));
}
// create one ColorHighlighter for each color/predicate pair and
// add to a compoundHighlighter
CompoundHighlighter chl = new CompoundHighlighter();
for (Color color : colors) {
chl.addHighlighter(new ColorHighlighter(map.get(color), color, null));
}
table.resetSortOrder();
table.addHighlighter(chl);
showWithScrollingInFrame(table,
"compound highlighter with value-based color mapping predicate");
}
示例9: interactiveExitToChild
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Issue #1249-swingx: RolloverProducer clears rollover point when inserting child
*
* Happens f.i. when starting an edit.
*
*/
public void interactiveExitToChild() {
JXTable table = new JXTable(new AncientSwingTeam());
table.addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW,
Color.MAGENTA, null, Color.MAGENTA, null));
JXFrame frame = wrapWithScrollingInFrame(table, "rollover child");
addStatusMessage(frame, "edit under mouse, move");
show(frame);
}
示例10: interactiveSearchPanel
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* test to see searchPanel functionality in new Highlighter api
*
*/
public void interactiveSearchPanel() {
JXTable table = new JXTable(tableModel);
final ColorHighlighter cl = new ColorHighlighter(new PatternPredicate((Pattern) null, 0), null,
Color.RED);
table.addHighlighter(cl);
JXSearchPanel searchPanel = new JXSearchPanel();
PatternMatcher patternMatcher = new PatternMatcher() {
@Override
public Pattern getPattern() {
return getPatternPredicate().getPattern();
}
@Override
public void setPattern(Pattern pattern) {
PatternPredicate old = getPatternPredicate();
cl.setHighlightPredicate(new PatternPredicate(pattern, old
.getTestColumn(), old.getHighlightColumn()));
}
private PatternPredicate getPatternPredicate() {
return (PatternPredicate) cl.getHighlightPredicate();
}
};
searchPanel.addPatternMatcher(patternMatcher);
JXFrame frame = wrapWithScrollingInFrame(table,
"Pattern highlighting col 0");
addStatusComponent(frame, searchPanel);
show(frame);
}
示例11: interactiveTableGetStringUsedInFind
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Issue #767-swingx: consistent string representation.
*
* used in find/highlight
*/
public void interactiveTableGetStringUsedInFind() {
JXTable table = new JXTable(new AncientSwingTeam());
table.setDefaultRenderer(Color.class, new DefaultTableRenderer(sv));
HighlightPredicate predicate = new PatternPredicate("R/G/B: -2", 2, 2);
table.addHighlighter(new ColorHighlighter(predicate, null, Color.RED));
table.setColumnControlVisible(true);
JXFrame frame = wrapWithScrollingInFrame(table, "Find/Highlight use adapter string value");
addSearchModeToggle(frame);
addMessage(frame, "Press ctrl-F to open search widget");
show(frame);
}
示例12: interactiveTableCustomRendererColor
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Issue #258-swingx: Background LegacyHighlighter must not change custom
* foreground.
* <p>
*
* Use SwingX extended default renderer.
*/
public void interactiveTableCustomRendererColor() {
TableModel model = new AncientSwingTeam();
JXTable table = new JXTable(model);
DefaultTableRenderer renderer = new DefaultTableRenderer();
renderer.setForeground(foreground);
renderer.setBackground(background);
table.addHighlighter(HighlighterFactory.createAlternateStriping(Color.WHITE, HighlighterFactory.GENERIC_GRAY));
table.setDefaultRenderer(Object.class, renderer);
JXTable nohighlight = new JXTable(model);
nohighlight.setDefaultRenderer(Object.class, renderer);
showWithScrollingInFrame(table, nohighlight,
"ext: custom colored renderer with bg highlighter <--> shared without highl");
}
示例13: interactiveTableRolloverScroll
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Issue #1193-swingx: rollover state not updated on scrolling/mouseWheel
*
* visualize behaviour on
* - scrolling (with mouse wheel)
* - resizing (added custom actions)
*/
public void interactiveTableRolloverScroll() {
final JXTable table = new JXTable(new AncientSwingTeam());
table.setEditable(false);
table.setHorizontalScrollEnabled(true);
table.addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, Color.YELLOW, null));
final JXFrame frame = getResizableFrame(table);
show(frame);
}
示例14: interactiveValueBasedGradientHighlight
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* Use transparent gradient painter for value-based background highlighting
* with SwingX extended default renderer. Shared by table and list with
* background color.
*/
public void interactiveValueBasedGradientHighlight() {
TableModel model = new AncientSwingTeam();
JXTable table = new JXTable(model);
table.setBackground(HighlighterFactory.LEDGER);
ComponentProvider<JLabel> controller = new LabelProvider(
JLabel.RIGHT);
// table.setDefaultRenderer(Number.class, new DefaultTableRenderer(
// controller));
RelativePainterHighlighter gradientHighlighter =
createRelativeGradientHighlighter(HorizontalAlignment.RIGHT, 100);
table.addHighlighter(gradientHighlighter);
// re-use component controller and highlighter in a JXList
JXList list = new JXList(createListNumberModel(), true);
list.setBackground(table.getBackground());
list.setCellRenderer(new DefaultListRenderer(controller));
list.addHighlighter(gradientHighlighter);
list.toggleSortOrder();
JXFrame frame = wrapWithScrollingInFrame(table, list,
"transparent value relative highlighting (with RelativePH)");
// addStatusMessage(frame,
// "uses the default painter-aware label in renderer");
// crude binding to play with options - the factory is incomplete...
// addStatusComponent(frame, createTransparencyToggle(gradientHighlighter));
show(frame);
}
示例15: interactiveSimpleStripingGroup
import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
* shows the effect of a simple striping highlighter on a
* colored table.
*
*/
public void interactiveSimpleStripingGroup() {
JXTable table = new JXTable(tableModel);
table.setVisibleRowCount(table.getRowCount() + 3);
table.setBackground(Color.YELLOW);
table.addHighlighter(HighlighterFactory.createSimpleStriping(Color.LIGHT_GRAY, 3));
showWithScrollingInFrame(table, "Simple gray striping, grouped by 3");
}