本文整理汇总了Java中org.jdesktop.swingx.decorator.ComponentAdapter类的典型用法代码示例。如果您正苦于以下问题:Java ComponentAdapter类的具体用法?Java ComponentAdapter怎么用?Java ComponentAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ComponentAdapter类属于org.jdesktop.swingx.decorator包,在下文中一共展示了ComponentAdapter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testConfiguredComponentAdapter
import org.jdesktop.swingx.decorator.ComponentAdapter; //导入依赖的package包/类
/**
* test convenience method accessing the configured adapter.
*
*/
@Test
public void testConfiguredComponentAdapter() {
JXTree list = new JXTree();
list.expandAll();
assertTrue(list.getRowCount() > 0);
ComponentAdapter adapter = list.getComponentAdapter();
assertEquals(0, adapter.column);
assertEquals(0, adapter.row);
assertTrue(adapter.isHierarchical());
adapter.row = 1;
// corrupt adapter
adapter.column = 1;
adapter = list.getComponentAdapter(0);
assertEquals(0, adapter.column);
assertEquals(0, adapter.row);
}
开发者ID:RockManJoe64,项目名称:swingx,代码行数:22,代码来源:JXTreeUnitTest.java
示例2: interactiveTableColorBasedOnComponentValue
import org.jdesktop.swingx.decorator.ComponentAdapter; //导入依赖的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) ");
}
开发者ID:RockManJoe64,项目名称:swingx,代码行数:27,代码来源:HighlighterClientVisualCheck.java
示例3: interactiveSimpleStriping
import org.jdesktop.swingx.decorator.ComponentAdapter; //导入依赖的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");
}
开发者ID:RockManJoe64,项目名称:swingx,代码行数:26,代码来源:HighlighterClientVisualCheck.java
示例4: testConfiguredComponentAdapter
import org.jdesktop.swingx.decorator.ComponentAdapter; //导入依赖的package包/类
/**
* test convenience method accessing the configured adapter.
*/
@Test
public void testConfiguredComponentAdapter() {
JXComboBox combo = new JXComboBox(new Object[] {1, 2, 3});
ComponentAdapter adapter = combo.getComponentAdapter();
assertThat(adapter.column, is(0));
assertThat(adapter.row, is(0));
// corrupt adapter
adapter.row = 1;
adapter.column = 1;
adapter = combo.getComponentAdapter(0);
assertThat(adapter.column, is(0));
assertThat(adapter.row, is(0));
}
开发者ID:RockManJoe64,项目名称:swingx,代码行数:21,代码来源:JXComboBoxTest.java
示例5: createXTableWithIndyRowHeights
import org.jdesktop.swingx.decorator.ComponentAdapter; //导入依赖的package包/类
/**
* Creates and returns a JXTable with model as returned by createTableModel with
* eventBig == false.
* Has a FontHighlighter which decorates the renderer with a big font if
* the cell value is BIG.
*
* @return a JXTable configured
*/
private JXTable createXTableWithIndyRowHeights() {
DefaultTableModel model = createTableModel(false);
JXTable table = new JXTable(model);
HighlightPredicate predicate = new HighlightPredicate() {
@Override
public boolean isHighlighted(Component renderer,
ComponentAdapter adapter) {
return BIG.equals(adapter.getValue());
}
};
FontHighlighter highlighter = new FontHighlighter(predicate, table.getFont().deriveFont(50f));
table.addHighlighter(highlighter);
return table;
}
开发者ID:RockManJoe64,项目名称:swingx,代码行数:25,代码来源:TableRowHeightControllerTest.java
示例6: interactiveTestHierarchicalColumnHighlightConditional
import org.jdesktop.swingx.decorator.ComponentAdapter; //导入依赖的package包/类
/**
* Requirement: color the leafs of the hierarchical columns differently.
*
* http://forums.java.net/jive/thread.jspa?messageID=165876
*
*
*/
public void interactiveTestHierarchicalColumnHighlightConditional() {
JXTreeTable treeTable = new JXTreeTable(treeTableModel);
HighlightPredicate hierarchical = new ColumnHighlightPredicate(0);
treeTable.addHighlighter(new ShadingColorHighlighter(hierarchical));
HighlightPredicate predicate = new HighlightPredicate() {
@Override
public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
return adapter.isLeaf();
}
};
ColorHighlighter highlighter = new ColorHighlighter(new AndHighlightPredicate(hierarchical, predicate),
new Color(247,246,239), null);
treeTable.addHighlighter(highlighter);
showWithScrollingInFrame(treeTable,
"HierarchicalColumn And Conditional ");
}
开发者ID:RockManJoe64,项目名称:swingx,代码行数:26,代码来源:JXTreeTableVisualCheck.java
示例7: interactiveRepaintOnUpdateSingleCell
import org.jdesktop.swingx.decorator.ComponentAdapter; //导入依赖的package包/类
/**
* After moving to Mustang, this might be vieweda as a bug ;-)
* Was: Unconditional repaint on cell update (through the default
* identify filter).
* Is: only the updated cell is repainted, unrelated (from model perspective)
* cells (like others in row) are not repainted.
*/
public void interactiveRepaintOnUpdateSingleCell() {
JXTable table = new JXTable(10, 5);
// highlight complete row if first cell starts with a
HighlightPredicate predicate = new HighlightPredicate() {
public boolean isHighlighted(Component renderer,
ComponentAdapter adapter) {
return adapter.getString(0).startsWith("a");
}
};
ColorHighlighter highlighter = new ColorHighlighter(predicate, Color.MAGENTA, null, Color.MAGENTA, null);
table.addHighlighter(highlighter);
JXTable other = new JXTable(table.getModel());
other.addHighlighter(highlighter);
JXFrame frame = wrapWithScrollingInFrame(table, other, "repaint on update in first");
addMessage(frame, "edit first cell in left table (start with/out a)");
show(frame);
}
开发者ID:RockManJoe64,项目名称:swingx,代码行数:27,代码来源:JXTableIssues.java
示例8: updateHighlighter
import org.jdesktop.swingx.decorator.ComponentAdapter; //导入依赖的package包/类
protected void updateHighlighter(Component component) {
mouseOverHighlighter.setHighlightPredicate(HighlightPredicate.NEVER);
if (component != null) {
List<Component> pathList = new ArrayList<Component>();
while (component != null) {
pathList.add(0, component);
component = component.getParent();
}
final TreePath treePath = new TreePath(pathList.toArray());
treeTable.scrollPathToVisible(treePath);
HighlightPredicate predicate = new HighlightPredicate() {
@Override
public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
return adapter.row == treeTable.getRowForPath(treePath);
}
};
mouseOverHighlighter.setHighlightPredicate(predicate);
// </snip>
}
}
开发者ID:RockManJoe64,项目名称:swingx,代码行数:24,代码来源:TreeTableDemo.java
示例9: highlight
import org.jdesktop.swingx.decorator.ComponentAdapter; //导入依赖的package包/类
@Override
public Component highlight(Component comp, ComponentAdapter compAdapter) {
Color bg = comp.getBackground();
JPanel panel = new JPanel(new MigLayout("ins 3"));
panel.setOpaque(true);
panel.setBackground(bg);
try {
Object val = compAdapter.getValue();
Integer intVal = Integer.parseInt(val.toString());
Color clr = new Color(intVal);
JLabel lb = new JLabel();
lb.setPreferredSize(new Dimension(24, 16));
lb.setOpaque(true);
lb.setBackground(clr);
panel.add(lb);
return panel;
} catch (NumberFormatException e) {
return panel;
}
}
开发者ID:markkohdev,项目名称:oStorybook,代码行数:21,代码来源:ColorHighlighter.java
示例10: highlight
import org.jdesktop.swingx.decorator.ComponentAdapter; //导入依赖的package包/类
public Component highlight( Component component, ComponentAdapter adapter ) {
if ( adapter.getValue() instanceof Ticket ) {
Ticket ticket = (Ticket) adapter.getValue();
switch( ticket.getPriority() ) {
case 1:
component.setBackground( new Color( 0xAA, 0xAA, 0xFF ) );
break;
case 2:
component.setBackground( new Color( 0xDD, 0xDD, 0xFF ) );
break;
case 3:
component.setBackground( new Color( 0xFF, 0xFF, 0xFF ) );
break;
case 4:
component.setBackground( new Color( 0xFF, 0xDD, 0xDD ) );
break;
case 5:
component.setBackground( new Color( 0xFF, 0xAA, 0xAA ) );
break;
default:
System.out.println( "WARNING: unknown priority!" );
}
if ( ticket.getStatus().equals( "closed" ) ) {
component.setForeground( new Color( 0x33, 0x33, 0x33 ) );
}
else if ( ticket.getStatus().equals( "resolved" ) ) {
component.setForeground( new Color( 0x00, 0x88, 0x00 ) );
}
else {
component.setForeground( new Color( 0x00, 0x00, 0x00 ) );
Font f = component.getFont();
component.setFont( f.deriveFont( f.getStyle() ^ Font.BOLD ) );
}
}
return component;
}
开发者ID:mleoking,项目名称:PhET,代码行数:40,代码来源:TicketHighlighter.java
示例11: getComponentAdapter
import org.jdesktop.swingx.decorator.ComponentAdapter; //导入依赖的package包/类
/**
* @return the unconfigured ComponentAdapter.
*/
protected ComponentAdapter getComponentAdapter() {
if (dataAdapter == null) {
dataAdapter = new ListAdapter(this);
}
return dataAdapter;
}
开发者ID:RockManJoe64,项目名称:swingx,代码行数:10,代码来源:JXList.java
示例12: applyBackground
import org.jdesktop.swingx.decorator.ComponentAdapter; //导入依赖的package包/类
@Override
protected void applyBackground(Component renderer, ComponentAdapter adapter) {
if (!adapter.isSelected()) {
Color ok, error, disabled;
if (adapter.getDepth() == 1) {
ok = new Color(157, 204, 88);
error = new Color(204, 0, 20);
disabled = Color.darkGray;
} else {
ok = new Color(208, 217, 146);
error = new Color(230, 80, 70);
disabled = Color.lightGray;
}
Object value = adapter.getValue(PluginInformationPane.UID_INDEX);
if (value instanceof String) {
String uid = (String) value;
if (PluginManager.getInstance().isActive(uid) && PluginManager.getInstance().isCurrentlyEnabled(uid)) {
renderer.setBackground(ok);
} else if (!PluginManager.getInstance().isCurrentlyEnabled(uid)) {
renderer.setBackground(disabled);
} else if (!PluginManager.getInstance().isActive(uid)) {
renderer.setBackground(error);
}
}
}
super.applyBackground(renderer, adapter);
}
开发者ID:sing-group,项目名称:aibench-project,代码行数:28,代码来源:PluginInformationPane.java
示例13: getComponentAdapter
import org.jdesktop.swingx.decorator.ComponentAdapter; //导入依赖的package包/类
/**
* @return the unconfigured ComponentAdapter.
*/
protected ComponentAdapter getComponentAdapter() {
if (dataAdapter == null) {
dataAdapter = new ComboBoxAdapter(this);
}
return dataAdapter;
}
开发者ID:RockManJoe64,项目名称:swingx,代码行数:10,代码来源:JXComboBox.java
示例14: applyRenderer
import org.jdesktop.swingx.decorator.ComponentAdapter; //导入依赖的package包/类
/**
* Performs configuration of the tree's renderer if the adapter's column is
* the hierarchical column, does nothing otherwise.
* <p>
*
* Note: this is legacy glue if the treeCellRenderer is of type
* DefaultTreeCellRenderer. In that case the renderer's
* background/foreground/Non/Selection colors are set to the tree's
* background/foreground depending on the adapter's selection state. Does
* nothing if the treeCellRenderer is backed by a ComponentProvider.
*
* @param component the rendering component
* @param adapter component data adapter
* @throws NullPointerException if the specified component or adapter is
* null
*/
protected Component applyRenderer(Component component,
ComponentAdapter adapter) {
if (component == null) {
throw new IllegalArgumentException("null component");
}
if (adapter == null) {
throw new IllegalArgumentException("null component data adapter");
}
if (isHierarchical(adapter.column)) {
// After all decorators have been applied, make sure that relevant
// attributes of the table cell renderer are applied to the
// tree cell renderer before the hierarchical column is rendered!
TreeCellRenderer tcr = renderer.getCellRenderer();
if (tcr instanceof JXTree.DelegatingRenderer) {
tcr = ((JXTree.DelegatingRenderer) tcr).getDelegateRenderer();
}
if (tcr instanceof DefaultTreeCellRenderer) {
DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);
// this effectively overwrites the dtcr settings
if (adapter.isSelected()) {
dtcr.setTextSelectionColor(component.getForeground());
dtcr.setBackgroundSelectionColor(component.getBackground());
} else {
dtcr.setTextNonSelectionColor(component.getForeground());
dtcr.setBackgroundNonSelectionColor(component
.getBackground());
}
}
}
return component;
}
开发者ID:sing-group,项目名称:aibench-project,代码行数:51,代码来源:JXTreeTable.java
示例15: getComponentAdapter
import org.jdesktop.swingx.decorator.ComponentAdapter; //导入依赖的package包/类
/**
* @return the unconfigured ComponentAdapter.
*/
protected ComponentAdapter getComponentAdapter() {
if (dataAdapter == null) {
dataAdapter = new TableAdapter(this);
}
return dataAdapter;
}
开发者ID:RockManJoe64,项目名称:swingx,代码行数:10,代码来源:JXTable.java
示例16: getComponentAdapter
import org.jdesktop.swingx.decorator.ComponentAdapter; //导入依赖的package包/类
/**
* @return the unconfigured ComponentAdapter.
*/
protected ComponentAdapter getComponentAdapter() {
if (dataAdapter == null) {
dataAdapter = new TreeAdapter(this);
}
return dataAdapter;
}
开发者ID:RockManJoe64,项目名称:swingx,代码行数:10,代码来源:JXTree.java
示例17: getComponentAdapter
import org.jdesktop.swingx.decorator.ComponentAdapter; //导入依赖的package包/类
/**
* Returns the adapter that knows how to access the component data model.
* The component data adapter is used by filters, sorters, and highlighters.
*
* @return the adapter that knows how to access the component data model
*/
@Override
protected ComponentAdapter getComponentAdapter() {
if (dataAdapter == null) {
dataAdapter = new TreeTableDataAdapter(this);
}
return dataAdapter;
}
开发者ID:RockManJoe64,项目名称:swingx,代码行数:14,代码来源:JXTreeTable.java
示例18: testStringAtComponentAdapterUseProvider
import org.jdesktop.swingx.decorator.ComponentAdapter; //导入依赖的package包/类
/**
* Issue #1152-swingx: re-enable filtering with single-string-representation.
* was: Issue #767-swingx: consistent string representation.
*
* Here: test getStringAt of ComponentAdapter use provider
* (sanity, trying to pull the rag failed during re-enable)
*/
@Test
public void testStringAtComponentAdapterUseProvider() {
JXListT list = new JXListT(AncientSwingTeam.createNamedColorListModel(), true);
list.setCellRenderer(new DefaultListRenderer(sv));
list.getStringValueRegistry().setStringValue(StringValues.TO_STRING, 0);
ComponentAdapter adapter = list.getComponentAdapter();
assertEquals(StringValues.TO_STRING.getString(list.getElementAt(0)),
adapter.getStringAt(0, 0));
}
开发者ID:RockManJoe64,项目名称:swingx,代码行数:18,代码来源:JXListTest.java
示例19: testComponentAdapterCoordinates
import org.jdesktop.swingx.decorator.ComponentAdapter; //导入依赖的package包/类
/**
* Test assumptions of accessing list model/view values through
* the list's componentAdapter.
*/
@Test
public void testComponentAdapterCoordinates() {
JXList list = new JXList(ascendingListModel, true);
list.setComparator(TableSortController.COMPARABLE_COMPARATOR);
Object originalFirstRowValue = list.getElementAt(0);
Object originalLastRowValue = list.getElementAt(list.getElementCount() - 1);
assertEquals("view row coordinate equals model row coordinate",
list.getModel().getElementAt(0), originalFirstRowValue);
// sort first column - actually does not change anything order
list.toggleSortOrder();
// sanity asssert
assertEquals("view order must be unchanged ",
list.getElementAt(0), originalFirstRowValue);
// invert sort
list.toggleSortOrder();
// sanity assert
assertEquals("view order must be reversed changed ",
list.getElementAt(0), originalLastRowValue);
ComponentAdapter adapter = list.getComponentAdapter();
assertEquals("adapter filteredValue expects row view coordinates",
list.getElementAt(0), adapter.getFilteredValueAt(0, 0));
// adapter coordinates are view coordinates
adapter.row = 0;
adapter.column = 0;
assertEquals("adapter.getValue must return value at adapter coordinates",
list.getElementAt(0), adapter.getValue());
assertEquals("adapter.getValue must return value at adapter coordinates",
list.getElementAt(0), adapter.getValue(0));
}
开发者ID:RockManJoe64,项目名称:swingx,代码行数:34,代码来源:JXListTest.java
示例20: testConfiguredComponentAdapter
import org.jdesktop.swingx.decorator.ComponentAdapter; //导入依赖的package包/类
/**
* test convenience method accessing the configured adapter.
*
*/
@Test
public void testConfiguredComponentAdapter() {
JXList list = new JXList(new Object[] {1, 2, 3});
ComponentAdapter adapter = list.getComponentAdapter();
assertEquals(0, adapter.column);
assertEquals(0, adapter.row);
adapter.row = 1;
// corrupt adapter
adapter.column = 1;
adapter = list.getComponentAdapter(0);
assertEquals(0, adapter.column);
assertEquals(0, adapter.row);
}
开发者ID:RockManJoe64,项目名称:swingx,代码行数:18,代码来源:JXListTest.java
注:本文中的org.jdesktop.swingx.decorator.ComponentAdapter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论