本文整理汇总了Java中javax.swing.JList.getSelectionForeground方法的典型用法代码示例。如果您正苦于以下问题:Java JList.getSelectionForeground方法的具体用法?Java JList.getSelectionForeground怎么用?Java JList.getSelectionForeground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JList
的用法示例。
在下文中一共展示了JList.getSelectionForeground方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getListCellRendererComponent
import javax.swing.JList; //导入方法依赖的package包/类
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (!(value instanceof TreeListNode)) {
//shoudln't happen
return new JLabel();
}
TreeListNode node = (TreeListNode) value;
int rowHeight = list.getFixedCellHeight();
int rowWidth = list.getVisibleRect().width;
int dropIndex = -1;
DropLocation dropLocation = list.getDropLocation();
if (dropLocation != null && !dropLocation.isInsert()) {
dropIndex = dropLocation.getIndex();
}
boolean isDropTarget = dropIndex == index;
isSelected = isSelected || isDropTarget;
Color background = isSelected ? list.getSelectionBackground() : list.getBackground();
Color foreground = isSelected ? list.getSelectionForeground() : list.getForeground();
return node.getRenderer(foreground, background, isSelected, cellHasFocus, rowHeight, rowWidth);
}
示例2: getListCellRendererComponent
import javax.swing.JList; //导入方法依赖的package包/类
@Override
public Component getListCellRendererComponent( JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus ) {
if (!(value instanceof ListNode)) {
//shoudln't happen
return new JLabel();
}
if( list instanceof SelectionList ) {
isSelected |= index == ((SelectionList)list).getMouseOverRow();
}
ListNode node = (ListNode) value;
int rowHeight = list.getFixedCellHeight();
int rowWidth = list.getWidth();
JScrollPane scroll = ( JScrollPane ) SwingUtilities.getAncestorOfClass( JScrollPane.class, list);
if( null != scroll )
rowWidth = scroll.getViewport().getWidth();
Color background = isSelected ? list.getSelectionBackground() : list.getBackground();
Color foreground = isSelected ? list.getSelectionForeground() : list.getForeground();
return node.getListRenderer(foreground, background, isSelected, cellHasFocus, rowHeight, rowWidth);
}
示例3: LibsRenderer
import javax.swing.JList; //导入方法依赖的package包/类
LibsRenderer(@NonNull final JList list) {
this.root = new JLabel();
this.root.setHorizontalAlignment(LEFT);
this.root.setOpaque(false);
this.root.setFont(list.getFont());
this.profile = new JLabel();
this.profile.setHorizontalAlignment(RIGHT);
this.profile.setOpaque(false);
this.profile.setFont(list.getFont());
this.container = new JPanel();
this.container.setLayout(new BorderLayout());
this.container.add (this.root, BorderLayout.WEST);
this.container.add (this.profile, BorderLayout.EAST);
fgColor = list.getForeground();
fgColorLighter = new Color(
Math.min(255, fgColor.getRed() + LIGHTER_COLOR_COMPONENT),
Math.min(255, fgColor.getGreen() + LIGHTER_COLOR_COMPONENT),
Math.min(255, fgColor.getBlue() + LIGHTER_COLOR_COMPONENT));
bgColor = new Color(list.getBackground().getRGB());
bgSelectionColor = list.getSelectionBackground();
fgSelectionColor = list.getSelectionForeground();
}
示例4: Renderer
import javax.swing.JList; //导入方法依赖的package包/类
public Renderer(JList list) {
setFont(list.getFont());
fgColor = list.getForeground();
bgColor = list.getBackground();
bgColorDarker = new Color(Math.abs(bgColor.getRed() - DARKER_COLOR_COMPONENT),
Math.abs(bgColor.getGreen() - DARKER_COLOR_COMPONENT),
Math.abs(bgColor.getBlue() - DARKER_COLOR_COMPONENT));
bgSelectionColor = list.getSelectionBackground();
fgSelectionColor = list.getSelectionForeground();
}
示例5: Renderer
import javax.swing.JList; //导入方法依赖的package包/类
public Renderer( JList list ) {
setFont( list.getFont() );
fgColor = list.getForeground();
bgColor = list.getBackground();
bgColorDarker = new Color(
Math.abs(bgColor.getRed() - DARKER_COLOR_COMPONENT),
Math.abs(bgColor.getGreen() - DARKER_COLOR_COMPONENT),
Math.abs(bgColor.getBlue() - DARKER_COLOR_COMPONENT)
);
bgSelectionColor = list.getSelectionBackground();
fgSelectionColor = list.getSelectionForeground();
}
示例6: getListCellRendererComponent
import javax.swing.JList; //导入方法依赖的package包/类
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
boolean cellHasFocus)
{
FileInfo info = (FileInfo) value;
icon.setIcon(SystemIconCache.getIcon(info, true));
icon.setMarkAsResource(info.isMarkAsAttachment());
base.setBackground(isSelected ? list.getSelectionBackground() : list.getBackground());
filename.setForeground(isSelected ? list.getSelectionForeground() : list.getForeground());
Color fg = isSelected ? list.getSelectionForeground() : LIGHTER_GRAY;
size.setForeground(fg);
modified.setForeground(fg);
sizeLabel.setForeground(fg);
modifiedLabel.setForeground(fg);
boolean isFile = !info.isDirectory();
size.setVisible(isFile);
modified.setVisible(isFile);
sizeLabel.setVisible(isFile);
modifiedLabel.setVisible(isFile);
base.remove(filename);
int height = isFile ? 1 : 3;
base.add(filename, "cell 1 0, spanx 2, spany " + height);
filename.setText(info.getName());
size.setText(FileSizeUtils.humanReadableFileSize(info.getSize()));
modified.setText(dateFormat.format(new Date(info.getLastModified())));
if( CurrentLocale.isRightToLeft() )
{
base.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
}
return base;
}