本文整理匯總了Java中org.openide.nodes.Node.getIcon方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.getIcon方法的具體用法?Java Node.getIcon怎麽用?Java Node.getIcon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openide.nodes.Node
的用法示例。
在下文中一共展示了Node.getIcon方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getListCellRendererComponent
import org.openide.nodes.Node; //導入方法依賴的package包/類
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Node node = Visualizer.findNode(value);
thumbImage = node.getIcon(BeanInfo.ICON_COLOR_32x32);
this.selected = isSelected;
label.setOpaque(selected);
if (selected) {
label.setBackground(UIManager.getColor("List.selectionBackground"));
label.setForeground(UIManager.getColor("List.selectionForeground"));
} else {
label.setBackground(UIManager.getColor("Label.background"));
label.setForeground(UIManager.getColor("Label.foreground"));
}
this.focused = cellHasFocus;
this.label.setText(node.getDisplayName());
return this;
}
示例2: configureForNode
import org.openide.nodes.Node; //導入方法依賴的package包/類
private void configureForNode(Node node) {
renderer.reset();
Image nodeIcon = node.getIcon(BeanInfo.ICON_COLOR_16x16);
Icon icon = nodeIcon != null && nodeIcon != BreadcrumbsController.NO_ICON ? ImageUtilities.image2Icon(nodeIcon) : null;
int width = icon != null ? icon.getIconWidth() : 0;
if (width > 0) {
renderer.setIcon(icon);
renderer.setIconTextGap(ICON_TEXT_SEPARATOR);
} else {
renderer.setIcon(null);
renderer.setIconTextGap(0);
}
String html = node.getHtmlDisplayName();
if (html != null) {
renderer.setHtml(true);
renderer.setText(html);
} else {
renderer.setHtml(false);
renderer.setText(node.getDisplayName());
}
renderer.setFont(getFont());
}
示例3: testIconOfTheNode
import org.openide.nodes.Node; //導入方法依賴的package包/類
public void testIconOfTheNode() throws Exception {
LogRecord r = new LogRecord(Level.INFO, "icon_msg");
r.setResourceBundleName("org.netbeans.modules.uihandler.TestBundle");
r.setResourceBundle(ResourceBundle.getBundle("org.netbeans.modules.uihandler.TestBundle"));
r.setParameters(new Object[] { new Integer(1), "Ahoj" });
Node n = UINode.create(r);
assertEquals("Name is taken from the message", "icon_msg", n.getName());
if (!n.getDisplayName().matches(".*Ahoj.*")) {
fail("wrong display name, shall contain Ahoj: " + n.getDisplayName());
}
Image img = n.getIcon(BeanInfo.ICON_COLOR_32x32);
assertNotNull("Some icon", img);
IconInfo imgReal = new IconInfo(img);
IconInfo template = new IconInfo(getClass().getResource("testicon.png"));
assertEquals("Icon from ICON_BASE used", template, imgReal);
assertSerializedWell(n);
}
示例4: getTableCellRendererComponent
import org.openide.nodes.Node; //導入方法依賴的package包/類
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
Icon icon = null;
BookmarksTableModel model = (BookmarksTableModel) table.getModel();
BookmarkNode bNode = model.getEntry(row);
BookmarkInfo bookmark = bNode.getBookmarkInfo();
Node fNode = bNode.getParentNode();
if (fNode != null) {
if (!isSelected) {
String text = fNode.getHtmlDisplayName();
if (text != null) {
text = bookmark.getDescription(text, forHistoryPopup, forHistoryPopup, true);
setText("<html>" + text + "</html>");
} // else leave original text set by "super"
}
Image image = fNode.getIcon(BeanInfo.ICON_COLOR_16x16);
if (image != null) {
icon = ImageUtilities.image2Icon(image);
}
}
setIcon(icon);
return this;
}
示例5: getIcon
import org.openide.nodes.Node; //導入方法依賴的package包/類
@Override
public Icon getIcon() {
Node[] nodes = getNodes();
if (nodes.length > 1) {
return MULTI_SELECTION_ICON;
} else if (nodes.length == 1 && nodes[0] != null) {
Node n = nodes[0];
Image image = n.getIcon(BeanInfo.ICON_COLOR_16x16);
if (image != null) {
return ImageUtilities.image2Icon(image);
} else {
return null;
}
} else {
return null;
}
}
示例6: getIcon
import org.openide.nodes.Node; //導入方法依賴的package包/類
public javax.swing.Icon getIcon(Object o) {
if (!showIcons) {
return emptyIcon;
}
Node n = Visualizer.findNode(o);
if (n == null) {
throw new IllegalStateException("TreeNode must be VisualizerNode but was: " + o + " of class " + o.getClass().getName());
}
boolean expanded = false;
if (o instanceof TreeNode) {
TreeNode tn = (TreeNode)o;
ArrayList<TreeNode> al = new ArrayList<TreeNode> ();
while (tn != null) {
al.add(tn);
tn = tn.getParent();
}
Collections.reverse(al);
TreePath tp = new TreePath(al.toArray());
AbstractLayoutCache layout = table.getLayoutCache();
expanded = layout.isExpanded(tp);
}
java.awt.Image image = null;
if (expanded) {
image = n.getOpenedIcon(java.beans.BeanInfo.ICON_COLOR_16x16);
} else {
image = n.getIcon(java.beans.BeanInfo.ICON_COLOR_16x16);
}
return new ImageIcon(image);
}
示例7: getListCellRendererComponent
import org.openide.nodes.Node; //導入方法依賴的package包/類
@Override
public Component getListCellRendererComponent (JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) // the list and the cell have the focus
{
final DataObject obj = (DataObject)value;
if (!obj.isValid()) {
// #17059: it might be invalid already.
// #18886: but if so, remove it later, otherwise BasicListUI gets confused.
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
listModel.removeElement(obj);
}
});
setText("");
return this;
}
Node node = obj.getNodeDelegate();
ImageIcon icon = new ImageIcon(node.getIcon(BeanInfo.ICON_COLOR_16x16));
super.setIcon(icon);
setText(node.getDisplayName());
if (isSelected){
this.setBackground(UIManager.getColor("List.selectionBackground")); // NOI18N
this.setForeground(UIManager.getColor("List.selectionForeground")); // NOI18N
}
else {
this.setBackground(list.getBackground());
this.setForeground(list.getForeground());
}
this.setBorder(cellHasFocus ? hasFocusBorder : noFocusBorder);
return this;
}
示例8: testIconFromURL
import org.openide.nodes.Node; //導入方法依賴的package包/類
public void testIconFromURL() throws Exception {
FileObject bar = FileUtil.getConfigFile("foo/bar.txt");
Node n = DataObject.find(bar).getNodeDelegate();
Image reference = Toolkit.getDefaultToolkit().createImage(new URL("jar:" + satJar.toURL() + "!/sfs_attr_test/main.gif"));
Image tested = n.getIcon(BeanInfo.ICON_COLOR_16x16);
int h1 = imageHash("main.gif", reference, 16, 16);
int h2 = imageHash("bar.txt icon", tested, 16, 16);
assertEquals("correct icon", h1, h2);
}
示例9: testIconFromImageMethod
import org.openide.nodes.Node; //導入方法依賴的package包/類
/** @see "#18832" */
public void testIconFromImageMethod() throws Exception {
FileObject baz = FileUtil.getConfigFile("foo/baz.txt");
Node n = DataObject.find(baz).getNodeDelegate();
Image reference = Toolkit.getDefaultToolkit().createImage(new URL("jar:" + satJar.toURL() + "!/sfs_attr_test/main-plus-badge.gif"));
Image tested = n.getIcon(BeanInfo.ICON_COLOR_16x16);
int h1 = imageHash("main-plus-badge.gif", reference, 16, 16);
int h2 = imageHash("baz.txt icon", tested, 16, 16);
assertEquals("correct icon", h1, h2);
}
示例10: inspectNode
import org.openide.nodes.Node; //導入方法依賴的package包/類
private void inspectNode(Node n) {
n.getDisplayName();
n.getHtmlDisplayName();
n.getShortDescription();
n.getIcon(BeanInfo.ICON_COLOR_16x16);
n.canCopy();
n.canCut();
n.canRename();
n.getNewTypes();
n.getActions(true);
n.getPreferredAction();
inspectProperties(n);
}
示例11: getIcon
import org.openide.nodes.Node; //導入方法依賴的package包/類
@Override
public Icon getIcon (Object o) {
Node n = Visualizer.findNode(o);
return new ImageIcon(n.getIcon(java.beans.BeanInfo.ICON_COLOR_16x16));
}
示例12: getTableCellRendererComponent
import org.openide.nodes.Node; //導入方法依賴的package包/類
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
if (value == null) {
return new DefaultTableCellRenderer().getTableCellRendererComponent(table, value,
isSelected, hasFocus, row, column);
}
if (isSelected) {
super.setForeground(table.getSelectionForeground());
super.setBackground(table.getSelectionBackground());
} else {
super.setForeground(table.getForeground());
super.setBackground(table.getBackground());
}
setFont(table.getFont());
if (hasFocus) {
Border border = null;
if (isSelected) {
border = UIManager.getBorder("Table.focusSelectedCellHighlightBorder"); // NOI18N
}
if (border == null) {
border = UIManager.getBorder("Table.focusCellHighlightBorder"); // NOI18N
}
setBorder(border);
} else {
setBorder(new EmptyBorder(1, 1, 1, 1));
}
FileCoverageSummary summary = (FileCoverageSummary) table.getValueAt(row, -1);
FileObject file = summary.getFile();
setText(summary.getDisplayName());
if (file != null && file.isValid()) {
try {
DataObject dobj = DataObject.find(file);
Node node = dobj.getNodeDelegate();
Image icon = node.getIcon(BeanInfo.ICON_COLOR_32x32);
setIcon(new ImageIcon(icon));
} catch (DataObjectNotFoundException ex) {
Exceptions.printStackTrace(ex);
}
} else {
setIcon(null);
}
return this;
}