本文整理匯總了Java中javax.swing.JList.getSelectionBackground方法的典型用法代碼示例。如果您正苦於以下問題:Java JList.getSelectionBackground方法的具體用法?Java JList.getSelectionBackground怎麽用?Java JList.getSelectionBackground使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JList
的用法示例。
在下文中一共展示了JList.getSelectionBackground方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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();
}