本文整理汇总了Java中javax.swing.JList.getForeground方法的典型用法代码示例。如果您正苦于以下问题:Java JList.getForeground方法的具体用法?Java JList.getForeground怎么用?Java JList.getForeground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JList
的用法示例。
在下文中一共展示了JList.getForeground方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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<? extends AuthenticationCheckboxListItem> list, AuthenticationCheckboxListItem value,
int index, boolean isSelected, boolean cellHasFocus) {
final Color bc;
final Color fc;
if (isSelected) {
bc = UIManager.getColor("List.selectionBackground"); //NOI18N
fc = UIManager.getColor("List.selectionForeground"); //NOI18N
} else {
bc = list.getBackground();
fc = list.getForeground();
}
setBackground(bc); // NOI18N
setForeground(fc); // NOI18N
label.setBackground(bc);
label.setForeground(fc);
label.setText(value.getDisplayName());
label.setFont(list.getFont());
check.setSelected(value.isSelected());
check.setBackground(bc);
check.setForeground(fc);
check.setEnabled(list.isEnabled());
Border border;
if (cellHasFocus) {
border = focusBorder;
} else {
border = noFocusBorder;
}
setBorder(border);
return this;
}
示例7: getListCellRendererComponent
import javax.swing.JList; //导入方法依赖的package包/类
@Override
public Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
if (value != null) {
if (value instanceof Configuration) {
setText(((Configuration) value).getDisplayName());
} else {
setText(value.toString());
}
}
if (!bordersInitialized) {
//#222894: the original border must be kept for GTK
originalBorder = getBorder();
Separator separator = new Separator(list.getForeground());
if (originalBorder != null) separatorBorder = new CompoundBorder(originalBorder, separator);
else separatorBorder = separator;
bordersInitialized = true;
}
if (index == list.getModel().getSize()-5 && ((ConfigurationsComboModel) list.getModel()).canModify() ) {
setBorder(separatorBorder);
} else {
setBorder(originalBorder);
}
if (isSelected) {
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
} else {
setBackground(list.getBackground());
setForeground(list.getForeground());
}
// #89393: GTK needs name to render cell renderer "natively"
setName("ComboBox.listRenderer"); // NOI18N
return this;
}