Java Code Examples for javax.swing.JList#setBackground()

The following examples show how to use javax.swing.JList#setBackground() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JPanelRenderer.java    From Spark with Apache License 2.0 6 votes vote down vote up
@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;
   }
 
Example 2
Source File: FastpathPanelRenderer.java    From Spark with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: MissedCalls.java    From Spark with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 4
Source File: AppFrame.java    From HBaseClient with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 初始化数据库表列表的数据模型
 */
@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());
}
 
Example 5
Source File: ScoreTable.java    From rcrs-server with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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;
}
 
Example 6
Source File: DiplomacyView.java    From Open-Realms-of-Stars with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 7
Source File: DiplomacyView.java    From Open-Realms-of-Stars with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 8
Source File: DiplomacyView.java    From Open-Realms-of-Stars with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 9
Source File: ConfigurableDialog.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 10
Source File: ConfigurableDialog.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 11
Source File: CallHistoryRenderer.java    From Spark with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 12
Source File: GroupDeleterDialog.java    From nanoleaf-desktop with MIT License 4 votes vote down vote up
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");
}
 
Example 13
Source File: JCarouselMenu.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * 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);
}
 
Example 14
Source File: JListFactory.java    From WorldGrower with GNU General Public License v3.0 4 votes vote down vote up
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);
}
 
Example 15
Source File: ChatMainPane.java    From osrsclient with GNU General Public License v2.0 4 votes vote down vote up
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));
}