当前位置: 首页>>代码示例>>Java>>正文


Java JList.getSelectionBackground方法代码示例

本文整理汇总了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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:TreeList.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:SelectionList.java

示例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();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:FixProfile.java

示例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();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:RemoveSurroundingCodePanel.java

示例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();        
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:ImportClassPanel.java


注:本文中的javax.swing.JList.getSelectionBackground方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。