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

The following examples show how to use javax.swing.JList#setToolTipText() . 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: ExtendedJComboBox.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("rawtypes")
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
		boolean cellHasFocus) {
	if (isSelected) {
		setBackground(list.getSelectionBackground());
		setForeground(list.getSelectionForeground());
		if (index >= 0) {
			list.setToolTipText((value == null) ? null : value.toString());
		}
	} else {
		setBackground(list.getBackground());
		setForeground(list.getForeground());
	}
	setFont(list.getFont());
	setText((value == null) ? "" : value.toString());
	return this;
}
 
Example 2
Source File: ComboboxRenderer.java    From WorldGrower with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList list, Object value,
                    int index, boolean isSelected, boolean cellHasFocus) {

    JComponent comp = (JComponent) super.getListCellRendererComponent(list,
            value, index, isSelected, cellHasFocus);

    if (index == -1) {
    	index = list.getSelectedIndex();
    }
    
    if (index != -1) {
    	if (tooltips != null) {
    		list.setToolTipText(tooltips[index]);
    	}
    	if (images != null) {
    		setIcon(new ImageIcon(images[index]));
    	}
    }
    return comp;
}
 
Example 3
Source File: SelectionColumnPanel.java    From nextreports-designer with Apache License 2.0 6 votes vote down vote up
public Component getListCellRendererComponent(JList list, Object value, int index,
                                              boolean isSelected, boolean cellHasFocus) {
    JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index,
            isSelected, cellHasFocus);

    if (value != null) {
        DBTable table = (DBTable) value;
        if (table.getType().equals("VIEW")) {
            comp.setIcon(ImageUtil.VIEW_IMAGE_ICON);
            comp.setText(table.getName());
        } else {
            comp.setIcon(ImageUtil.TABLE_IMAGE_ICON);
            comp.setText(table.getName());
        }
        value = table.getName();
        list.setToolTipText(value.toString());
    }

    return comp;
}
 
Example 4
Source File: ReportLayoutPanel.java    From nextreports-designer with Apache License 2.0 6 votes vote down vote up
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
		boolean cellHasFocus) {
	if (isSelected) {
		setBackground(list.getSelectionBackground());
		setForeground(list.getSelectionForeground());
		if (-1 < index) {
			list.setToolTipText(value.toString());
		}
	} else {
		setForeground(list.getForeground());
		if (DefaultDataSourceManager.getInstance().getConnectedDataSource().getName().equals(value)) {
			setBackground(new Color(204, 255, 255));
		} else {
			setBackground(list.getBackground());
		}
	}
	setFont(list.getFont());
	setText((value == null) ? "" : value.toString());
	return this;
}
 
Example 5
Source File: BuildingPanelFarming.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList<?> list, Object value,
                    int index, boolean isSelected, boolean cellHasFocus) {

	JComponent comp = (JComponent) super.getListCellRendererComponent(list,
            value, index, isSelected, cellHasFocus);

    if (-1 < index && null != value && null != tooltipArray) {
    	list.setToolTipText((String) tooltipArray.get(index));
    	//System.out.println("value.toString is "+ value.toString());
    	//System.out.println("list.toString is "+ list.toString());
    	//balloonToolTip.createListItemBalloonTip(list, (String)(tooltipArray.get(index)), index);
    }
    return comp;
}
 
Example 6
Source File: VisualSettings.java    From stendhal with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList<?> list, Object value,
		int index, boolean isSelected, boolean cellHasFocus) {

	JComponent comp = (JComponent) super.getListCellRendererComponent(list,
			value, index, isSelected, cellHasFocus);

	if ((index > -1) && (value != null)) {
		list.setToolTipText("<html>" + data[index][2] + "</html>");
	}
	return comp;
}
 
Example 7
Source File: BoardEditor.java    From megamek with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected,
        boolean cellHasFocus) {

    JComponent comp = (JComponent) super.getListCellRendererComponent(list, value, index, isSelected,
            cellHasFocus);

    if (-1 < index && null != value && null != terrains) {
        list.setToolTipText(terrains[index].getTerrainTooltip());
    }
    if (-1 < index && null != value && null != terrainTypes) {
        list.setToolTipText(terrainTypes.get(index).getTooltip());
    }
    return comp;
}
 
Example 8
Source File: SaveEntityPanel.java    From nextreports-designer with Apache License 2.0 5 votes vote down vote up
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
		boolean cellHasFocus) {
	JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

	if (value != null) {
		DBBrowserNode node = (DBBrowserNode) value;
		value = node.getDBObject().getName();
		list.setToolTipText(value.toString());
	}

	return comp;
}
 
Example 9
Source File: SelectionColumnPanel.java    From nextreports-designer with Apache License 2.0 5 votes vote down vote up
public Component getListCellRendererComponent(JList list, Object value, int index,
                                              boolean isSelected, boolean cellHasFocus) {

    JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index,
            isSelected, cellHasFocus);

    if (value != null) {
        DBColumn column = (DBColumn) value;
        if (column.isPrimaryKey()) {
            comp.setIcon(primaryKeyIcon);
            comp.setText(column.getName());
        } else if (column.isForeignKey()) {
            comp.setIcon(foreignKeyIcon);
            comp.setText(column.getName());
        } else if (column.isIndex()) {
            comp.setIcon(indexKeyIcon);
            comp.setText(column.getName());    
        } else {
            comp.setIcon(columnIcon);
            comp.setText(column.getName());
        }

        value = column.getName();
        list.setToolTipText(value.toString());
    }
    return comp;
}
 
Example 10
Source File: DDChangesPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Initializes the Form */
public DDChangesPanel (String caption, final JButton processButton) {
    setLayout (new java.awt.BorderLayout (0, 12));
    setBorder (new EmptyBorder (12, 12, 11, 0));
    
    JTextArea text = new JTextArea ();
    text.setEnabled (false);
    text.setEditable (false);
    text.setDisabledTextColor (UIManager.getColor ("Label.foreground")); // NOI18N
    text.setBackground (UIManager.getColor ("Label.background")); // NOI18N
    text.setLineWrap (true);
    text.setWrapStyleWord (true);
    text.setText (caption);
    add (text, "North"); // NOI18N
    
    changesPanel = new JPanel ();
    changesPanel.setLayout (new java.awt.BorderLayout (5, 5));
    
    JLabel changesLabel = new JLabel ();
    changesLabel.setText (NbBundle.getMessage (DDChangesPanel.class, "LAB_ChangesList"));
    changesLabel.getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage (DDChangesPanel.class, "ACS_ChangesListA11yDesc"));  // NOI18N
    changesPanel.add (changesLabel, "North"); // NOI18N
    
    jScrollPane1 = new JScrollPane ();
    
    listModel = new DefaultListModel ();
    
    changesList = new JList (listModel);
    changesList.setToolTipText (NbBundle.getMessage (DDChangesPanel.class, "HINT_ChangesList"));
    changesList.setCellRenderer (new ChangesListCellRenderer ());
    changesList.addListSelectionListener (new ListSelectionListener () {
        public void valueChanged (ListSelectionEvent e) {
            processButton.setEnabled (!changesList.isSelectionEmpty ());
        }
    });
    changesLabel.setLabelFor (changesList);
    changesLabel.setDisplayedMnemonic (NbBundle.getMessage (DDChangesPanel.class, "LAB_ChangesList_Mnemonic").charAt (0));
    getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (DDChangesPanel.class, "ACS_ChangesListA11yPanelDesc"));
    
    jScrollPane1.setViewportView (changesList);
    
    changesPanel.add (jScrollPane1, "Center"); // NOI18N
    
    add (changesPanel, "Center"); // NOI18N
}
 
Example 11
Source File: DDChangesPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Initializes the Form */
public DDChangesPanel (String caption, final JButton processButton) {
    setLayout (new java.awt.BorderLayout (0, 12));
    setBorder (new EmptyBorder (12, 12, 11, 0));
    
    JTextArea text = new JTextArea ();
    text.setEnabled (false);
    text.setEditable (false);
    text.setDisabledTextColor (UIManager.getColor ("Label.foreground")); // NOI18N
    text.setBackground (UIManager.getColor ("Label.background")); // NOI18N
    text.setLineWrap (true);
    text.setWrapStyleWord (true);
    text.setText (caption);
    add (text, "North"); // NOI18N
    
    changesPanel = new JPanel ();
    changesPanel.setLayout (new java.awt.BorderLayout (5, 5));
    
    JLabel changesLabel = new JLabel ();
    changesLabel.setText (NbBundle.getMessage (DDChangesPanel.class, "LAB_ChangesList"));
    changesLabel.getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage (DDChangesPanel.class, "ACS_ChangesListA11yDesc"));  // NOI18N
    changesPanel.add (changesLabel, "North"); // NOI18N
    
    jScrollPane1 = new JScrollPane ();
    
    listModel = new DefaultListModel ();
    
    changesList = new JList (listModel);
    changesList.setToolTipText (NbBundle.getMessage (DDChangesPanel.class, "HINT_ChangesList"));
    changesList.setCellRenderer (new ChangesListCellRenderer ());
    changesList.addListSelectionListener (new ListSelectionListener () {
        public void valueChanged (ListSelectionEvent e) {
            processButton.setEnabled (!changesList.isSelectionEmpty ());
        }
    });
    changesLabel.setLabelFor (changesList);
    changesLabel.setDisplayedMnemonic (NbBundle.getMessage (DDChangesPanel.class, "LAB_ChangesList_Mnemonic").charAt (0));
    getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (DDChangesPanel.class, "ACS_ChangesListA11yPanelDesc"));
    
    jScrollPane1.setViewportView (changesList);
    
    changesPanel.add (jScrollPane1, "Center"); // NOI18N
    
    add (changesPanel, "Center"); // NOI18N
}
 
Example 12
Source File: DDChangesPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Initializes the Form */
public DDChangesPanel (String caption, final JButton processButton) {
    setLayout (new java.awt.BorderLayout (0, 12));
    setBorder (new EmptyBorder (12, 12, 11, 0));
    
    JTextArea text = new JTextArea ();
    text.setEnabled (false);
    text.setEditable (false);
    text.setDisabledTextColor (UIManager.getColor ("Label.foreground")); // NOI18N
    text.setBackground (UIManager.getColor ("Label.background")); // NOI18N
    text.setLineWrap (true);
    text.setWrapStyleWord (true);
    text.setText (caption);
    add (text, "North"); // NOI18N
    
    changesPanel = new JPanel ();
    changesPanel.setLayout (new java.awt.BorderLayout (5, 5));
    
    JLabel changesLabel = new JLabel ();
    changesLabel.setText (NbBundle.getMessage (DDChangesPanel.class, "LAB_ChangesList"));
    changesLabel.getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage (DDChangesPanel.class, "ACS_ChangesListA11yDesc"));  // NOI18N
    changesPanel.add (changesLabel, "North"); // NOI18N
    
    jScrollPane1 = new JScrollPane ();
    
    listModel = new DefaultListModel ();
    
    changesList = new JList (listModel);
    changesList.setToolTipText (NbBundle.getMessage (DDChangesPanel.class, "HINT_ChangesList"));
    changesList.setCellRenderer (new ChangesListCellRenderer ());
    changesList.addListSelectionListener (new ListSelectionListener () {
        public void valueChanged (ListSelectionEvent e) {
            processButton.setEnabled (!changesList.isSelectionEmpty ());
        }
    });
    changesLabel.setLabelFor (changesList);
    changesLabel.setDisplayedMnemonic (NbBundle.getMessage (DDChangesPanel.class, "LAB_ChangesList_Mnemonic").charAt (0));
    getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (DDChangesPanel.class, "ACS_ChangesListA11yPanelDesc"));
    
    jScrollPane1.setViewportView (changesList);
    
    changesPanel.add (jScrollPane1, "Center"); // NOI18N
    
    add (changesPanel, "Center"); // NOI18N
}
 
Example 13
Source File: SwingListBoxWidget.java    From atdl4j with MIT License 4 votes vote down vote up
@Override
protected List< ? extends Component> createBrickComponents() {
  
  List<Component> components = new ArrayList<Component>();
  
  String tooltip = getTooltip();

     // label
     if ( control.getLabel() != null ) {
         label = new JLabel();
         label.setName(getName()+"/label");          
         label.setText( control.getLabel() );
         if ( tooltip != null ) label.setToolTipText( tooltip );
         components.add(label);
     }

     // listbox
     listBox =  new JList(list);
     if (control instanceof MultiSelectListT) {
         listBox.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
     } else if (control instanceof SingleSelectListT) {
         listBox.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
     }
     listBox.setName(getName()+"/listbox");
     
     // listBox items
     java.util.List<ListItemT> listItems = control instanceof MultiSelectListT ? ( (MultiSelectListT) control ).getListItem()
             : ( (SingleSelectListT) control ).getListItem();
     for ( ListItemT listItem : listItems )
     {
         list.add(listItem.getUiRep() != null ? listItem.getUiRep() : "");
     }

     // tooltip
     if ( tooltip != null ) listBox.setToolTipText( tooltip );

     // init value
     String initValue = (String) ControlHelper.getInitValue( control, getAtdl4jOptions() );
     if ( initValue != null ) setValue( initValue, true );
     
     return components;
}