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

The following examples show how to use javax.swing.JList#setOpaque() . 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: 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 2
Source File: AudioPlayerDemo.java    From pumpernickel with MIT License 5 votes vote down vote up
private void setupAquaList() {
	DefaultListModel<URL> listModel = new DefaultListModel<>();
	JList<URL> list = new JList<>(listModel);
	for (URL url : urls) {
		listModel.addElement(url);
	}
	list.setUI(new AquaAudioListUI());
	listSection.getBody().add(list);
	list.setOpaque(false);
}
 
Example 3
Source File: LoadSaveDialog.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
public LoadSaveDialog(SaveGameHandler saveGameHandler, LoadSaveMode loadSaveMode, ImageInfoReader imageInfoReader, SoundIdReader soundIdReader) {
	super(500, 475, imageInfoReader);
	((JComponent)getRootPane()).setBorder(BorderFactory.createLineBorder(Color.WHITE, 5));
	
	JScrollPane scrollPane = JScrollPaneFactory.createScrollPane();
	scrollPane.setBounds(16, 16, 462, 375);
	addComponent(scrollPane);
	
	JList<SaveGame> list = JListFactory.createJList(loadSaveMode.getSaveFiles());
	list.setOpaque(false);
	list.setSelectedIndex(0);
	list.setCellRenderer(new SaveGameRenderer(imageInfoReader));
	scrollPane.setViewportView(list);
	
	JPanel buttonPane = new JPanel();
	buttonPane.setLayout(new BorderLayout());
	buttonPane.setOpaque(false);
	buttonPane.setBounds(16, 410, 465, 50);
	addComponent(buttonPane);

	JButton cancelButton = JButtonFactory.createButton("Cancel", imageInfoReader, soundIdReader);
	cancelButton.setActionCommand("Cancel");
	buttonPane.add(cancelButton, BorderLayout.WEST);
	getRootPane().setDefaultButton(cancelButton);
	
	JButton okButton = JButtonFactory.createButton(loadSaveMode.getDescription(), imageInfoReader, soundIdReader);
	okButton.setActionCommand("OK");
	okButton.setEnabled(false);
	buttonPane.add(okButton, BorderLayout.EAST);
	getRootPane().setDefaultButton(okButton);
	
	addActions(list, okButton, cancelButton, loadSaveMode, saveGameHandler);
}
 
Example 4
Source File: ImageSetsPanel.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
ImageSetsPanel(final AvatarImagesScreen screen) {

        // List of avatar image sets.
        final JList<AvatarImageSet> imageSetsList = new JList<>(getAvatarImageSetsArray());
        imageSetsList.setOpaque(false);
        imageSetsList.addListSelectionListener(e -> {
            if (!e.getValueIsAdjusting()) {
                SwingUtilities.invokeLater(() -> {
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    screen.displayImageSetIcons(imageSetsList.getSelectedValue());
                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                });
            }
        });
        imageSetsList.setSelectedIndex(0);

        final AvatarListCellRenderer renderer = new AvatarListCellRenderer();
        imageSetsList.setCellRenderer(renderer);

        final JScrollPane scrollPane = new JScrollPane();
        scrollPane.setViewportView(imageSetsList);
        scrollPane.setBorder(BorderFactory.createEmptyBorder());
        scrollPane.setOpaque(false);
        scrollPane.getViewport().setOpaque(false);

        setLayout(new MigLayout("insets 0, gap 0, flowy"));
        setBorder(FontsAndBorders.BLACK_BORDER);
        add(scrollPane, "w 100%, h 100%");

        refreshStyle();
    }
 
Example 5
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 6
Source File: PerformanceVectorViewer.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
public PerformanceVectorViewer(final PerformanceVector performanceVector, final IOContainer container) {
	setLayout(new BorderLayout());

	// all criteria
	final CardLayout cardLayout = new CardLayout();
	final JPanel mainPanel = new JPanel(cardLayout);
	add(mainPanel, BorderLayout.CENTER);
	List<String> criteriaNameList = new LinkedList<>();
	for (int i = 0; i < performanceVector.getSize(); i++) {
		PerformanceCriterion criterion = performanceVector.getCriterion(i);
		criteriaNameList.add(criterion.getName());
		JPanel component = ResultDisplayTools.createVisualizationComponent(criterion, container,
				"Performance Criterion", false);
		JScrollPane criterionPane = new ExtendedJScrollPane(component);
		criterionPane.setBorder(null);
		criterionPane.setBackground(Colors.WHITE);
		mainPanel.add(criterionPane, criterion.getName());
	}
	if (criteriaNameList.isEmpty()) {
		remove(mainPanel);
		add(new ResourceLabel("result_view.no_criterions"));
		return;
	}
	String[] criteriaNames = new String[criteriaNameList.size()];
	criteriaNameList.toArray(criteriaNames);

	// selection list
	final JList<String> criteriaList = new MenuShortcutJList<String>(criteriaNames, false) {

		private static final long serialVersionUID = 3031125186920370793L;

		@Override
		public Dimension getPreferredSize() {
			Dimension dim = super.getPreferredSize();
			dim.width = Math.max(150, dim.width);
			return dim;
		}
	};
	criteriaList.setCellRenderer(new CriterionListCellRenderer());
	criteriaList.setOpaque(false);

	criteriaList.setBorder(BorderFactory.createTitledBorder("Criterion"));
	criteriaList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

	criteriaList.addListSelectionListener(new ListSelectionListener() {

		@Override
		public void valueChanged(ListSelectionEvent e) {
			String selected = criteriaList.getSelectedValue();
			cardLayout.show(mainPanel, selected);
		}
	});

	JScrollPane listScrollPane = new ExtendedJScrollPane(criteriaList);
	listScrollPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 2));
	add(listScrollPane, BorderLayout.WEST);

	// select first criterion
	criteriaList.setSelectedIndices(new int[] { 0 });
}
 
Example 7
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 8
Source File: SelectPlayerScreen.java    From magarena with GNU General Public License v3.0 4 votes vote down vote up
public ContainerPanel(final JList<? extends PlayerProfile> profilesJList) {
    profilesJList.setOpaque(false);
    refreshStyle();
    setLayout(new MigLayout("insets 0, gap 0, flowy"));
    add(new ScrollPane(profilesJList), "w 100%, h 100%");
}
 
Example 9
Source File: KeywordsListPane.java    From magarena with GNU General Public License v3.0 4 votes vote down vote up
KeywordsListPane(final KeywordPanelB keywordPanel) throws IOException {

        JList<Keyword> list = new JList<>(KeywordsHelper.getKeywords());

        list.setLayoutOrientation(JList.VERTICAL_WRAP);
        list.setVisibleRowCount(-1);

        list.setOpaque(false);
        list.setCellRenderer(new KeywordsListCellRenderer());

        list.setForeground(Color.WHITE);
        list.setFont(list.getFont().deriveFont(14f));

        list.addListSelectionListener((e) -> {
            final Keyword keyword = list.getSelectedValue();
            keywordPanel.setKeyword(keyword);
        });

        list.setSelectedIndex(0);

        setViewportView(list);

        setOpaque(false);
        getViewport().setOpaque(false);
    }