javax.swing.JList#setBackground ( )源码实例Demo

下面列出了javax.swing.JList#setBackground ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Spark   文件: JPanelRenderer.java
@Override
public Component getListCellRendererComponent(JList list,
                                                 Object value,
                                                 int index,
                                                 boolean isSelected,
                                                 boolean cellHasFocus) {
       JPanel panel = (JPanel)value;
       panel.setFocusable(false);

       if (isSelected) {
           panel.setForeground((Color)UIManager.get("List.selectionForeground"));
           panel.setBackground((Color)UIManager.get("List.selectionBackground"));
           panel.setBorder(BorderFactory.createLineBorder((Color)UIManager.get("List.selectionBorder")));
       }
       else {
           panel.setBackground(list.getBackground());
           panel.setForeground(list.getForeground());
           panel.setBorder(BorderFactory.createLineBorder((Color)UIManager.get("ContactItem.background")));
       }

       list.setBackground((Color)UIManager.get("ContactItem.background"));


       return panel;
   }
 
源代码2 项目: Spark   文件: FastpathPanelRenderer.java
public Component getListCellRendererComponent(JList list,
                                              Object value,
                                              int index,
                                              boolean isSelected,
                                              boolean cellHasFocus) {
    JPanel panel = (JPanel)value;
    panel.setFocusable(false);

    if (isSelected) {
        panel.setForeground((Color)UIManager.get("List.selectionForeground"));
        panel.setBackground((Color)UIManager.get("List.selectionBackground"));
        panel.setBorder(BorderFactory.createLineBorder((Color)UIManager.get("List.selectionBorder")));
    }
    else {
        panel.setBackground(list.getBackground());
        panel.setForeground(list.getForeground());
        panel.setBorder(BorderFactory.createMatteBorder(0,0,1,0, Color.lightGray));
    }

    list.setBackground((Color)UIManager.get("List.background"));


    return panel;
}
 
源代码3 项目: Spark   文件: MissedCalls.java
public Component getListCellRendererComponent(JList list,
                                              Object value,
                                              int index,
                                              boolean isSelected,
                                              boolean cellHasFocus) {
    MissedCall panel = (MissedCall)value;
    panel.setFocusable(false);

    if (isSelected) {
        panel.setForeground((Color)UIManager.get("List.selectionForeground"));
        panel.setBackground((Color)UIManager.get("List.selectionBackground"));
        panel.setBorder(BorderFactory.createLineBorder((Color)UIManager.get("List.selectionBorder")));
    }
    else {
        panel.setBackground(new Color(255, 224, 224));

        panel.setForeground(list.getForeground());
        panel.setBorder(BorderFactory.createLineBorder((Color)UIManager.get("List.background")));
    }

    list.setBackground((Color)UIManager.get("List.background"));


    return panel;
}
 
源代码4 项目: HBaseClient   文件: AppFrame.java
/**
 * 初始化数据库表列表的数据模型
 */
@SuppressWarnings("unchecked")
public void initListModel()
{
    JList<String> v_Tables = (JList<String>)XJava.getObject("xlTables");
    
    this.listModel = new DefaultListModel<String>();
    
    v_Tables.setModel(this.listModel);
    v_Tables.setBackground(this.getBackground());
}
 
源代码5 项目: rcrs-server   文件: ScoreTable.java
@Override
public JComponent getGUIComponent() {
    JTable table = new JTable(model.table);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    JScrollPane scroll = new JScrollPane(table);
    JList rowHeader = new JList(model.list);
    rowHeader.setFixedCellHeight(table.getRowHeight());
    rowHeader.setCellRenderer(new RowHeaderRenderer(table));
    rowHeader.setBackground(table.getBackground());
    rowHeader.setOpaque(true);
    scroll.setRowHeaderView(rowHeader);
    return scroll;
}
 
源代码6 项目: Open-Realms-of-Stars   文件: DiplomacyView.java
/**
 * Create Tech List from tech
 * @param techs Which are used for creating Tech List
 * @return JList full of tech
 */
private JList<Tech> createTechList(final Tech[] techs) {
  JList<Tech> techList = new JList<>(techs);
  techList.setCellRenderer(new TechListRenderer());
  techList.setBackground(Color.BLACK);
  techList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
  return techList;
}
 
源代码7 项目: Open-Realms-of-Stars   文件: DiplomacyView.java
/**
 * Create Fleet List from fleet array
 * @param fleets Which are used for creating Fleet List
 * @return JList full of fleets
 */
private JList<Fleet> createFleetList(final Fleet[] fleets) {
  JList<Fleet> fleetList = new JList<>(fleets);
  fleetList.setCellRenderer(new FleetListRenderer());
  fleetList.setBackground(Color.BLACK);
  fleetList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
  return fleetList;
}
 
源代码8 项目: Open-Realms-of-Stars   文件: DiplomacyView.java
/**
 * Create Planet List from planet array
 * @param planets Which are used for creating planet List
 * @return JList full of planets
 */
private JList<Planet> createPlanetList(final Planet[] planets) {
  JList<Planet> planetList = new JList<>(planets);
  planetList.setCellRenderer(new PlanetListRenderer());
  planetList.setBackground(Color.BLACK);
  planetList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
  return planetList;
}
 
源代码9 项目: rapidminer-studio   文件: ConfigurableDialog.java
/**
 * Creates a new JList for a given source of a configurable
 *
 * @param source
 *            can be null for local configurables, otherwise name of the source
 * @return the created JList
 */
private JList<Configurable> createNewConfigurableJList(String source) {

	final JList<Configurable> createdConfigList = new JList<>();
	createdConfigList.setModel(source == null ? localConfigListModel : remoteConfigListModels.get(source));
	createdConfigList.setCellRenderer(new ConfigurableRenderer());
	createdConfigList.setFixedCellHeight(40);
	createdConfigList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	createdConfigList.setBackground(LIGHTER_GRAY);

	return createdConfigList;
}
 
源代码10 项目: rapidminer-studio   文件: ConfigurableDialog.java
/**
 * Creates a new JList for info labels of a source
 *
 * @param source
 *            can be null for local source, otherwise name of the source
 * @return the created JList
 */
private JList<String> createNewInfoLabelJList(String source) {
	final JList<String> createdInfoLabelList = new JList<>();
	createdInfoLabelList.setModel(source == null ? localInfoLabelListModel : remoteInfoLabelListModels.get(source));
	createdInfoLabelList.setCellRenderer(new ConfigurableInfoLabelRenderer());
	createdInfoLabelList.setFixedCellHeight(20);
	createdInfoLabelList.setBackground(LIGHTER_GRAY);
	return createdInfoLabelList;
}
 
源代码11 项目: Spark   文件: CallHistoryRenderer.java
public Component getListCellRendererComponent(JList list,
                                              Object value,
                                              int index,
                                              boolean isSelected,
                                              boolean cellHasFocus) {
    JPanel panel = (JPanel)value;
    panel.setFocusable(false);

    if (isSelected) {
        panel.setForeground(Color.white);
        panel.setBackground(new Color(51, 136, 238));
        panel.setBorder(BorderFactory.createLineBorder((Color)UIManager.get("List.selectionBorder")));
    }
    else {
        if (index % 2 == 0) {
            panel.setBackground((Color)UIManager.get("List.selectionBackground"));
        }
        else {
            panel.setBackground(list.getBackground());
        }
        panel.setForeground(list.getForeground());
        panel.setBorder(BorderFactory.createLineBorder((Color)UIManager.get("List.background")));
    }

    list.setBackground((Color)UIManager.get("List.background"));


    return panel;
}
 
源代码12 项目: nanoleaf-desktop   文件: GroupDeleterDialog.java
private void initUI(Component parent)
{
	setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	setSize(474, 225);
	setLocationRelativeTo(parent);
	setUndecorated(true);
	JPanel contentPane = new JPanel();
	contentPane.setBackground(Color.DARK_GRAY);
	contentPane.setBorder(new LineBorder(new Color(128, 128, 128), 2));
	setContentPane(contentPane);
	contentPane.setLayout(new MigLayout("", "[255.00,grow][106.00,grow][grow]", "[][grow][]"));
	
	WindowDragListener wdl = new WindowDragListener(50);
	addMouseListener(wdl);
	addMouseMotionListener(wdl);
	
	JLabel lblTitle = new JLabel("Select a Group");
	lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 22));
	lblTitle.setForeground(Color.WHITE);
	contentPane.add(lblTitle, "gapx 15 0, cell 0 0");
	
	CloseButton btnClose = new CloseButton(this, JFrame.DISPOSE_ON_CLOSE);
	contentPane.add(btnClose, "cell 2 0,alignx right,gapx 0 15");
	
	JScrollPane devicesScrollPane = new JScrollPane();
	devicesScrollPane.setBorder(null);
	devicesScrollPane.getHorizontalScrollBar().setUI(new ModernScrollBarUI());
	devicesScrollPane.getVerticalScrollBar().setUI(new ModernScrollBarUI());
	contentPane.add(devicesScrollPane, "cell 0 1 3 1,grow");
	
	groupsModel = new DefaultListModel<String>();
	JList<String> listGroups = new JList<String>(groupsModel);
	listGroups.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	listGroups.setFont(new Font("Tahoma", Font.PLAIN, 20));
	listGroups.setBackground(Color.DARK_GRAY);
	listGroups.setBorder(new LineBorder(Color.GRAY));
	listGroups.setForeground(Color.WHITE);
	devicesScrollPane.setViewportView(listGroups);
	
	JButton btnCreateGroup = new ModernButton("Delete Group");
	btnCreateGroup.addActionListener(new ActionListener()
	{
		@Override
		public void actionPerformed(ActionEvent e)
		{
			deleteGroup(listGroups.getSelectedValue());
		}
	});
	contentPane.add(btnCreateGroup, "cell 2 2");
}
 
源代码13 项目: radiance   文件: JCarouselMenu.java
/**
 * Creates a new instance of JCarouselMenu
 * @param border The border to use to draw items in the menu
 */
public JCarouselMenu(ImageBorder border) {
    carousel = new JCarosel();
    carousel.setLayout(new OffsetCaroselLayout(carousel));
    carousel.setBackground(null);
    carousel.setOpaque(false);
    carousel.setContentWidth(256);
    
    super.setLayout(new GridLayout(1,2));
    super.add(carousel);
    
    upButton.setForeground(Color.WHITE);
    downButton.setForeground(Color.WHITE);
    
    JPanel menuPanel = new JPanel();
    menuPanel.setBackground(null);
    menuPanel.setOpaque(false);
    menuPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc  = new GridBagConstraints();
    
    menu = new JList();
    menuScroll = new JScrollPane(menu, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    menuScroll.getViewport().setOpaque(false);
    menuScroll.setBorder(null);
    menuScroll.getViewport().addChangeListener(this);
    menu.setModel(menuModel);
    menu.setCellRenderer(new CarouselListCellRenderer(border));
    menu.setBackground(null);       
    menu.setOpaque(false);
    menu.addListSelectionListener(this);
    menuScroll.setOpaque(true);
    menuScroll.setBackground(Color.BLACK);
    menuScroll.setBorder(BorderFactory.createEmptyBorder());
    
    gbc.weightx=0.0;
    gbc.weighty=0.0;
    gbc.gridy=0;
    gbc.fill=GridBagConstraints.HORIZONTAL;
    menuPanel.add(upButton,gbc);
    gbc.weighty=1.0;
    gbc.weightx=1.0;
    gbc.gridy++;
    gbc.fill=GridBagConstraints.BOTH;
    menuPanel.add(menuScroll,gbc);
    gbc.weighty=0.0;
    gbc.weightx=0.0;
    gbc.gridy++;
    gbc.fill=GridBagConstraints.HORIZONTAL;
    menuPanel.add(downButton,gbc);
    menu.addMouseListener(this);
    menu.addKeyListener(this);
            
    //Don't want it to listen to itself...
    carousel.removeMouseWheelListener(carousel);
    carousel.addMouseWheelListener(this);
    menu.addMouseWheelListener(this);
    menuScroll.addMouseWheelListener(this);
    menuPanel.addMouseWheelListener(this);
    
    super.add(menuPanel);
}
 
源代码14 项目: WorldGrower   文件: JListFactory.java
private static<T> void setListProperties(JList<T> list) {
	list.setOpaque(false);
	list.setBackground(ColorPalette.DARK_BACKGROUND_COLOR);
	list.setForeground(ColorPalette.FOREGROUND_COLOR);
	list.setFont(Fonts.FONT);
}
 
源代码15 项目: osrsclient   文件: ChatMainPane.java
private void setup() {
    UIManager.put("Tree.rendererFillBackground", false);
    Border loweredbevel = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
    DefaultListModel<String> curChans = new DefaultListModel<>();
    messagewindow = new JTextArea();
    messagewindow.setLineWrap(true);
    inputfield = new JTextField();
    userlist = new JTextArea();
    chanlist = new JList(curChans);

    chanscroll = new JScrollPane(chanlist, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    messagescroll = new JScrollPane(messagewindow, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    userscroll = new JScrollPane(userlist, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

    chanscroll.setBorder(loweredbevel);
    messagescroll.setBorder(loweredbevel);
    userscroll.setBorder(loweredbevel);
    inputfield.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED, new Color(51, 51, 51), new Color(51, 51, 51)));

    inputfield.setBackground(new Color(71, 71, 71));
    messagewindow.setBackground(new Color(71, 71, 71));
    userlist.setBackground(new Color(71, 71, 71));
    chanlist.setBackground(new Color(71, 71, 71));

    chanlist.setForeground(Color.white);
    messagewindow.setForeground(Color.white);
    messagewindow.setFont(ircFont);
    inputfield.setForeground(Color.white);
    messagewindow.setText("");

    messagewindow.setEditable(false);
    inputfield.setCaretColor(Color.black);

    chanlist.setForeground(Color.white);

    add(chanscroll, "cell 0 0, growx, growy, height 100%,width 15%, align left, spany, ");
    add(messagescroll, "growy, cell 1 0, width 68%, height 80%, align center, align left");
    add(userscroll, "grow y, cell 2 0, width 17%, height 80%, align left");
    add(inputfield, "growx, cell 1 1, spanx,  width 68%,height 20,align left");

    // messagescroll.setViewportView((messagewindow2));
}