Java Code Examples for javax.swing.JLabel.setToolTipText()

The following are Jave code examples for showing how to use setToolTipText() of the javax.swing.JLabel class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: TableUISupport.java   View Source Code Vote up 6 votes
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    DisabledReason disabledReason = null;
    Object displayName = null;

    if (value instanceof Table) {
        Table tableItem = (Table)value;
        disabledReason = tableItem.getDisabledReason();
        if (disabledReason!= null) {
            displayName = NbBundle.getMessage(TableUISupport.class, "LBL_TableNameWithDisabledReason", tableItem.getName(), disabledReason.getDisplayName());
        } else {
            if(tableItem.isTable())
                displayName = tableItem.getName();
            else
                displayName = tableItem.getName() + NbBundle.getMessage(TableUISupport.class, "LBL_DB_VIEW");
        }
    }

    JLabel component = (JLabel)super.getListCellRendererComponent(list, displayName, index, isSelected, cellHasFocus);
    boolean needDisable = (disabledReason instanceof Table.NoPrimaryKeyDisabledReason) || (disabledReason instanceof Table.ExistingNotInSourceDisabledReason) || 
            (filter.equals(FilterAvailable.NEW) && (disabledReason instanceof Table.ExistingDisabledReason)) ||
            (filter.equals(FilterAvailable.UPDATE) && (disabledReason==null));
    component.setEnabled(!needDisable);
    component.setToolTipText(disabledReason != null ? disabledReason.getDescription() : null);

    return component;
}
 
Example 2
Project: gate-core   File: LuceneDataStoreSearchGUI.java   View Source Code Vote up 6 votes
@Override
public void mouseEntered(MouseEvent e) {
  dismissDelay = toolTipManager.getDismissDelay();
  initialDelay = toolTipManager.getInitialDelay();
  reshowDelay = toolTipManager.getReshowDelay();
  enabled = toolTipManager.isEnabled();
  Component component = e.getComponent();
  if(feature != null && !isTooltipSet && component instanceof JLabel) {
    isTooltipSet = true;
    JLabel label = (JLabel)component;
    String toolTip = label.getToolTipText();
    toolTip =
            (toolTip == null || toolTip.equals("")) ? "" : toolTip
                    .replaceAll("</?html>", "") + "<br>";
    toolTip = "<html>" + toolTip + "Right click to get statistics.</html>";
    label.setToolTipText(toolTip);
  }
  // make the tooltip indefinitely shown when the mouse is over
  toolTipManager.setDismissDelay(Integer.MAX_VALUE);
  toolTipManager.setInitialDelay(0);
  toolTipManager.setReshowDelay(0);
  toolTipManager.setEnabled(true);
}
 
Example 3
Project: Neukoelln_SER316   File: NotesList.java   View Source Code Vote up 5 votes
public ListCellRenderer getCellRenderer() {
       return new DefaultListCellRenderer()  {

    public Component getListCellRendererComponent(
      JList list,
      Object value,            // value to display
      int index,               // cell index
      boolean isSelected,      // is the cell selected
      boolean cellHasFocus)    // the list and the cell have the focus
    {
        JLabel label = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        String s = value.toString();
        label.setText(s);
        //Note currentNote = CurrentProject.getNoteList().getActiveNote();
	 Note currentNote = CurrentNote.get();
        if (currentNote != null) {
           if (getNote(index).getId().equals(currentNote.getId()))
               label.setFont(label.getFont().deriveFont(Font.BOLD));
        }
        if (getNote(index).isMarked())
           label.setIcon(bookmarkIcon);
        //setIcon();
      /*if (isSelected) {
            setBackground(list.getSelectionBackground());
          setForeground(list.getSelectionForeground());
      }
        else {
          setBackground(list.getBackground());
          setForeground(list.getForeground());
      }
      setEnabled(list.isEnabled());
      setFont(list.getFont());
        setOpaque(true);*/
        label.setToolTipText(s);
        return label;
    }
   };

}
 
Example 4
Project: rapidminer   File: IOObjectCacheEntryPanel.java   View Source Code Vote up 5 votes
/**
 * Creates a new {@link IOObjectCacheEntryPanel}.
 *
 * @param icon
 *            The {@link Icon} associated with the entry's type.
 * @param entryType
 *            Human readable representation of the entry's type (e.g., 'Data Table').
 * @param openAction
 *            The action to be performed when clicking in the entry.
 * @param removeAction
 *            An action triggering the removal of the entry.
 */
public IOObjectCacheEntryPanel(Icon icon, String entryType, Action openAction, Action removeAction) {
	super(ENTRY_LAYOUT);

	this.openAction = openAction;

	// add icon label
	JLabel iconLabel = new JLabel(icon);
	add(iconLabel, ICON_CONSTRAINTS);

	// add object type label
	JLabel typeLabel = new JLabel(entryType);
	typeLabel.setMaximumSize(new Dimension(MAX_TYPE_WIDTH, 24));
	typeLabel.setPreferredSize(typeLabel.getMaximumSize());
	typeLabel.setToolTipText(entryType);
	add(typeLabel, TYPE_CONSTRAINTS);

	// add link button performing the specified action, the label displays the entry's key name
	LinkLocalButton openButton = new LinkLocalButton(openAction);
	openButton.setMargin(new Insets(0, 0, 0, 0));
	add(openButton, KEY_CONSTRAINTS);

	// add removal button
	JButton removeButton = new JButton(removeAction);
	removeButton.setBorderPainted(false);
	removeButton.setOpaque(false);
	removeButton.setMinimumSize(buttonSize);
	removeButton.setPreferredSize(buttonSize);
	removeButton.setContentAreaFilled(false);
	removeButton.setText(null);
	add(removeButton, REMOVE_BUTTON_CONSTRAINTS);

	// register mouse listeners
	addMouseListener(hoverMouseListener);
	iconLabel.addMouseListener(dispatchMouseListener);
	typeLabel.addMouseListener(dispatchMouseListener);
	openButton.addMouseListener(dispatchMouseListener);
	removeButton.addMouseListener(dispatchMouseListener);
}
 
Example 5
Project: incubator-netbeans   File: StatusBar.java   View Source Code Vote up 5 votes
public void setText(String cellName, String text, Coloring extraColoring, int importance) {
    JLabel cell = getCellByName(cellName);
    if (cell != null) {
        cell.setText(text);
        if (visible) {
            JTextComponent jtc = editorUI.getComponent();
            Coloring c = jtc != null ? getColoring(
                org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(jtc),
                FontColorNames.STATUS_BAR_COLORING
            ) : null;

            if (c != null && extraColoring != null) {
                c = extraColoring.apply(c);
            } else if (c == null) {
                c = extraColoring;
            }
            if (CELL_POSITION.equals(cellName)){
                cell.setToolTipText(caretPositionLocaleString);
            } else if (CELL_TYPING_MODE.equals(cellName)) {
                cell.setToolTipText(insText.equals(text)? insertModeLocaleString : overwriteModeLocaleString);
            } else {
                cell.setToolTipText(text == null || text.length() == 0 ? null : text);
            }

            if (c != null && cell instanceof Cell) {
                applyColoring((Cell) cell, c);
            }
        } else { // Status bar not visible => use global status bar if possible
            JLabel globalCell = cellName2GlobalCell.get(cellName);
            if (globalCell != null) {
                if (CELL_MAIN.equals(cellName)) {
                    globalCell.putClientProperty("importance", importance);
                }
                globalCell.setText(text);
            }
        }
    }
}
 
Example 6
Project: code-sentinel   File: BaseDialogGUI.java   View Source Code Vote up 5 votes
protected void createField(String label, JComponent tf, String tooltip) {
    JLabel jl = new JLabel(label+": ");
    jl.setToolTipText(tooltip);
    tf.setToolTipText(tooltip);
    pLabels.add(jl);
    JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT));
    p.add(tf);
    pFields.add(p);
}
 
Example 7
Project: FreeCol   File: ModOptionUI.java   View Source Code Vote up 5 votes
/**
 * Add information from a mod file to a label.
 *
 * @param label The {@code JLabel} to modify.
 * @param modFile The {@code FreeColModFile} to use.
 */
private static void labelModFile(JLabel label, FreeColModFile modFile) {
    String key = "mod." + modFile.getId();
    label.setText(Messages.getName(key));
    if (Messages.containsKey(Messages.shortDescriptionKey(key))) {
        label.setToolTipText(Messages.getShortDescription(key));
    }
}
 
Example 8
Project: ISO8583   File: PayloadMessageConfig.java   View Source Code Vote up 5 votes
private GuiPayloadField(FieldVO fieldVO, FieldVO superfieldVO) {

			this.isSubfield = (superfieldVO != null);
			this.superFieldVO = superfieldVO;
			this.fieldVO = fieldVO.getInstanceCopy();
			this.fieldVO.setFieldList(new ArrayList<FieldVO>());
			
			if (isSubfield)
				superFieldVO.getFieldList().add(this.fieldVO);
			else
				messageVO.getFieldList().add(this.fieldVO);
			
			ckBox = new JCheckBox();
			txtType = new JTextField();
			txtLength = new JTextField();
			txtValue = new JTextField();
			subfieldList = new ArrayList<GuiPayloadField>();
			
			lblFieldNum = new JLabel(fieldVO.getBitNum().toString());
			lblFieldName = new JLabel(fieldVO.getName());
			lblType = new JLabel(fieldVO.getType().toString());
			lblDynamic = new JLabel();
			lblDynamic.setIcon(new ImageIcon(PnlGuiPayload.class.getResource("/resource/search.png")));
			lblDynamic.setToolTipText(fieldVO.getDynaCondition());

			lineNum = numLines;
			numLines++;
			
			ckBox.setBounds(10, 10 + (lineNum * 25), 22, 22);
			lblFieldNum.setBounds(40, 10 + (lineNum * 25), 50, 22);
			lblFieldName.setBounds(80, 10 + (lineNum * 25), 100, 22);
			lblType.setBounds(470, 10 + (lineNum * 25), 100, 22);
			lblDynamic.setBounds(600, 10 + (lineNum * 25), 50, 22);
			
			if (fieldVO.getType() == TypeEnum.ALPHANUMERIC) {
				txtValue.setBounds(190, 10 + (lineNum * 25), 260, 22);
			}
			else if (fieldVO.getType() == TypeEnum.TLV) {
				txtType.setBounds(190, 10 + (lineNum * 25), 80, 22);
				txtLength.setBounds(280, 10 + (lineNum * 25), 80, 22);
				txtValue.setBounds(370, 10 + (lineNum * 25), 80, 22);
				
				pnlFields.add(txtType);
				pnlFields.add(txtLength);
			}
			
			if (!isSubfield)
				pnlFields.add(ckBox);
				
			pnlFields.add(lblFieldNum);
			pnlFields.add(lblFieldName);
			pnlFields.add(txtValue);
			pnlFields.add(lblType);

			txtType.addKeyListener(saveFieldPayloadAction);
			txtLength.addKeyListener(saveFieldPayloadAction);
			txtValue.addKeyListener(saveFieldPayloadAction);
			
			if (!fieldVO.getDynaCondition().equals("") && !fieldVO.getDynaCondition().equals("true"))
				pnlFields.add(lblDynamic);
			
			if (fieldVO.getDynaCondition().equals("true")) {
				ckBox.setSelected(true);
				ckBox.setEnabled(false);
				ckBoxClick(ckBox);
				
				setEnabled(true);
			}
			else {
				ckBox.addActionListener(new ActionListener() {
					@Override
					public void actionPerformed(ActionEvent e) {
						ckBoxClick((JCheckBox) e.getSource());
						saveFieldValue();
					}
				});
				
				setEnabled(false);
			}
		}
 
Example 9
Project: OpenDA   File: Query.java   View Source Code Vote up 5 votes
/** Specify a tool tip to appear when the mouse lingers over the label.
 *  @param name The name of the entry.
 *  @param tip The text of the tool tip.
 */
public void setToolTip(String name, String tip) {
    JLabel label = (JLabel) _labels.get(name);
    if (label != null) {
        label.setToolTipText(tip);
    }
}
 
Example 10
Project: JWT4B   File: JLabelLink.java   View Source Code Vote up 5 votes
public void addURL(String content) {
	JLabel label = new JLabel("<html>"+content+"</html>");
	label.setCursor(new Cursor(Cursor.HAND_CURSOR));
	label.setToolTipText(content);
	addMouseHandler(label);
	pan.add(label);
}
 
Example 11
Project: incubator-netbeans   File: Renderers.java   View Source Code Vote up 5 votes
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {        
    
    if ( value instanceof DefaultMutableTreeNode ) {
        value = ((DefaultMutableTreeNode)value).getUserObject();
    }
    
    String name;
    String toolTip;
    Icon icon;
    if (value instanceof TypeElement) {
        TypeElement te = (TypeElement) value;
        name = getDisplayName(te);
        toolTip = getToolTipText(te);            
        icon = UiUtils.getElementIcon( te.getKind(), te.getModifiers() );
    }
    else {
        name = "???";
        toolTip = name = (value == null ? "NULL" : value.toString());
        icon = null;
    }
    
    JLabel comp = (JLabel)renderer.getTreeCellRendererComponent( tree, value, selected, expanded, leaf, row, hasFocus );
    comp.setText( name );
    comp.setToolTipText(toolTip);
    if (icon != null) {
        comp.setIcon(icon);
    }
    return comp;
}
 
Example 12
Project: rapidminer   File: SOMModelPlotter.java   View Source Code Vote up 5 votes
@Override
public JComponent getOptionsComponent(int index) {
	JComponent comp = super.getOptionsComponent(index);
	if (comp != null) {
		lastPlotterComponentIndex = index;
		return comp;
	} else {
		if (index == lastPlotterComponentIndex + 1) {
			JLabel label = new JLabel("Transparency");
			label.setToolTipText("Select level of transparency");
			return label;
		} else if (index == lastPlotterComponentIndex + 2) {
			String toolTip = "Select level of transparency";
			final JSlider alphaSlider = new JSlider(0, 100, 50);
			alphaSlider.setToolTipText(toolTip);
			alphaSlider.addChangeListener(new ChangeListener() {

				@Override
				public void stateChanged(ChangeEvent e) {
					setAlphaLevel(((double) alphaSlider.getValue()) / 100);
				}
			});
			return alphaSlider;
		}
	}
	return null;
}
 
Example 13
Project: rapidminer   File: SimilarityKDistanceVisualization.java   View Source Code Vote up 5 votes
@Override
public JComponent getOptionsComponent(int index) {
	JLabel label = new JLabel("K:");
	label.setToolTipText("Set the k which should be displayed.");
	return label;

}
 
Example 14
Project: gate-core   File: LuceneDataStoreSearchGUI.java   View Source Code Vote up 5 votes
@Override
public void mouseEntered(MouseEvent e) {
  Component component = e.getComponent();
  if(!isTooltipSet && component instanceof JLabel) {
    isTooltipSet = true;
    JLabel label = (JLabel)component;
    Pattern result =
            (Pattern)results.get(resultTable.rowViewToModel(resultTable
                    .getSelectionModel().getLeadSelectionIndex()));
    label.setToolTipText("The query that matched this "
            + "expression was: " + result.getQueryString() + ".");
  }
}
 
Example 15
Project: SER316-Dresden   File: NotesList.java   View Source Code Vote up 5 votes
public ListCellRenderer getCellRenderer() {
       return new DefaultListCellRenderer()  {

    public Component getListCellRendererComponent(
      JList list,
      Object value,            // value to display
      int index,               // cell index
      boolean isSelected,      // is the cell selected
      boolean cellHasFocus)    // the list and the cell have the focus
    {
        JLabel label = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        String s = value.toString();
        label.setText(s);
        //Note currentNote = CurrentProject.getNoteList().getActiveNote();
        Note currentNote = CurrentNote.get();
        if (currentNote != null) {
           if (getNote(index).getId().equals(currentNote.getId()))
               label.setFont(label.getFont().deriveFont(Font.BOLD));
        }
        if (getNote(index).isMarked())
           label.setIcon(IconFontSwing.buildIcon(GoogleMaterialDesignIcons.STAR, 8, ColorMap.ICON));
        //setIcon();
      /*if (isSelected) {
            setBackground(list.getSelectionBackground());
          setForeground(list.getSelectionForeground());
      }
        else {
          setBackground(list.getBackground());
          setForeground(list.getForeground());
      }
      setEnabled(list.isEnabled());
      setFont(list.getFont());
        setOpaque(true);*/
        label.setToolTipText(s);
        return label;
    }
   };

}
 
Example 16
Project: FreeCol   File: CompactLabourReport.java   View Source Code Vote up 4 votes
private void addLocationSummary(LabourData.LocationData data, int row) {
    int rows = data.getRowCount();

    JLabel colonistsLabel = createNumberLabel(data.getTotalColonists(), null);
    if (data.getUnitData().isSummary()) {
        if (isOverview()) {
            reportPanel.add(createEmptyLabel(), "cell " + UNIT_TYPE_COLUMN + " " + row + " 1 " + rows);
        }
    } else {
        Utility.localizeToolTip(colonistsLabel, StringTemplate
            .template("report.labour.unitTotal.tooltip")
            .addName("%unit%", data.getUnitData().getUnitName()));
    }

    reportPanel.add(colonistsLabel, "cell " + COLONIST_SUMMARY_COLUMN + " " + row + " 1 " + data.getRowCount());

    if (showProduction && !data.getUnitData().showProduction()) {
        reportPanel.add(createEmptyLabel(), "cell " + PRODUCTION_SYMBOL_COLUMN + " " + row + " 4 " + rows);
        return;
    }

    if (showProduction) {
        JLabel productionLabel = createNumberLabel(data.getTotalProduction(), "report.labour.potentialProduction.tooltip");
        if (!data.isTotal() && data.getTotalProduction() == 0) {
            productionLabel.setText("");
        }

        reportPanel.add(productionLabel, "cell " + PRODUCTION_SUMMARY_COLUMN + " " + row + " 1 " + rows);
    }

    if (showNetProduction) {
        int net = data.getNetProduction();
        JLabel netProductionLabel = createNumberLabel(net, "report.labour.netProduction.tooltip");

        if (!data.getUnitData().showNetProduction() || (!data.isTotal() && net == 0)) {
            netProductionLabel.setText("");
            netProductionLabel.setToolTipText("");
        } else if (net >= 0) {
            netProductionLabel.setText("+" + net);
        } else {
            netProductionLabel.setForeground(Color.RED);
        }
        reportPanel.add(netProductionLabel, "cell " + NETPRODUCTION_SUMMARY_COLUMN + " " + row + " 1 " + rows);
    }

    if (showProductionSymbols) {
        JLabel icon = new JLabel();
        icon.setBorder(Utility.CELLBORDER);
        GoodsType goods = data.getUnitData().getExpertProduction();
        if (goods != null) {
            icon.setIcon(new ImageIcon(getImageLibrary().getIconImage(goods)));
        }
        reportPanel.add(icon, "cell " + PRODUCTION_SYMBOL_COLUMN + " " + row + " 1 " + rows);
    }
}
 
Example 17
Project: incubator-netbeans   File: BookmarkKeyChooser.java   View Source Code Vote up 4 votes
private void addCells(JPanel cellPanel, int cellCount, char... startToLastPairs) {
    Color foreColor = UIManager.getColor("Table.foreground");
    Color backColor = UIManager.getColor("Table.background");
    Color selForeColor = UIManager.getColor("Table.selectionForeground");
    Color selBackColor = UIManager.getColor("Table.selectionBackground");
    Border cellBorder = new LineBorder(Color.BLACK, 1, true);
    int cellId = 0;
    for (int i = 0; i < startToLastPairs.length;) {
        char start = startToLastPairs[i++];
        char last = startToLastPairs[i++];
        while (start <= last) {
            JLabel cell = new JLabel(" " + start + " ", SwingConstants.CENTER) {
                @Override
                public void paintComponent(Graphics g) {
                    Rectangle clip = g.getClipBounds();
                    Color origColor = g.getColor();
                    g.setColor(getBackground());
                    g.fillRect(clip.x, clip.y, clip.width, clip.height);
                    g.setColor(origColor);
                    super.paintComponent(g);
                }
            };
            final BookmarkInfo bookmark = key2bookmark.get(start);
            if (bookmark != null) {
                cell.setForeground(selForeColor);
                cell.setBackground(selBackColor);
                cell.setToolTipText(bookmark.getDescription(true, false, false));
                cell.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent e) {
                        if (e.getClickCount() == 1) {
                            result = bookmark;
                            dispose();
                        }
                    }
                });
            } else {
                cell.setForeground(foreColor);
                cell.setBackground(backColor);
                cell.setToolTipText(NbBundle.getMessage(BookmarkKeyChooser.class,
                        "CTL_keyChooserUnoccupiedBookmarkKey")); // NOI18N
            }
            cell.setBorder(cellBorder);
            cellPanel.add(cell);
            cellId++;
            start++;
        }
    }
    // Fill in remaining cells (otherwise only would be 9x4)
    while (cellId < cellCount) {
        cellPanel.add(new JPanel());
        cellId++;
    }
}
 
Example 18
Project: gate-core   File: LuceneDataStoreSearchGUI.java   View Source Code Vote up 4 votes
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
        boolean isSelected, boolean hasFocus, int row, int column) {
  String text = (String)value;
  if(text == null) {
    text = "";
  }
  int colModel = resultTable.convertColumnIndexToModel(column);
  // cut text in the middle if too long
  switch(colModel) {
    case ResultTableModel.RESULT_COLUMN:
    case ResultTableModel.FEATURES_COLUMN:
      if(text.length() > ResultTableModel.MAX_COL_WIDTH) {
        text =
                text.substring(0, ResultTableModel.MAX_COL_WIDTH / 2)
                        + "..."
                        + text.substring(text.length()
                                - (ResultTableModel.MAX_COL_WIDTH / 2));
      }
      text = text.replaceAll("(?:\r?\n)|\r", " ");
      text = text.replaceAll("\t", " ");
      break;
    default:
      // do nothing
      break;
  }
  Component component =
          super.getTableCellRendererComponent(table, text, isSelected,
                  hasFocus, row, column);
  if(!(component instanceof JLabel)) {
    return component;
  }
  JLabel label = (JLabel)component;
  label.setHorizontalAlignment(SwingConstants.LEFT);
  String tip = null;
  // add tooltips
  switch(colModel) {
    case ResultTableModel.LEFT_CONTEXT_COLUMN:
      label.setHorizontalAlignment(SwingConstants.RIGHT);
      break;
    case ResultTableModel.RESULT_COLUMN:
    case ResultTableModel.FEATURES_COLUMN:
      tip = value != null ? (String)value : "";
      if(tip.length() > ResultTableModel.MAX_COL_WIDTH) {            
        if(tip.length() > 1000) {
          tip =
                  tip.substring(0, 1000 / 2) + "<br>...<br>"
                          + tip.substring(tip.length() - (1000 / 2));
        }
        tip = tip.replaceAll("\\s*\n\\s*", "<br>");
        tip = tip.replaceAll("\\s+", " ");
        tip =
                "<html><table width=\""
                        + (tip.length() > 150 ? "500" : "100%")
                        + "\" border=\"0\" cellspacing=\"0\">" + "<tr><td>"
                        + tip + "</td></tr>" + "</table></html>";
      }
      if(colModel == ResultTableModel.RESULT_COLUMN) {
        label.setHorizontalAlignment(SwingConstants.CENTER);
      }
      break;
    default:
      // do nothing
      break;
  }
  label.setToolTipText(tip);
  return label;
}
 
Example 19
Project: Dahlem_SER316   File: NotesList.java   View Source Code Vote up 4 votes
public ListCellRenderer getCellRenderer() {
       return new DefaultListCellRenderer()  {

    public Component getListCellRendererComponent(
      JList list,
      Object value,            // value to display
      int index,               // cell index
      boolean isSelected,      // is the cell selected
      boolean cellHasFocus)    // the list and the cell have the focus
    {
        JLabel label = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        
        //Possible future use, allows user to click on star to add bookmark 
        //Not fully functional.
        /*list.addMouseListener(new MouseAdapter() {
     	    @Override
     	    public void mousePressed(MouseEvent e) {
     	         Point p = e.getPoint();
     	         int pointIndex = list.locationToIndex(p);
     	         Note currentNote = getNote(pointIndex);
     	         //NotesControlPanel ncp = new NotesControlPanel();
     	         
     	         if(p.getX() < 10){
     	        	 if(currentNote.isMarked()){
     	        		 currentNote.setMark(false);
     	        		 //ncp.ppRemoveBkmrk_actionPerformed(currentNote);
     	        		 //list.updateUI();
     	        		 list.repaint();
                      }
                      else{
                    	  currentNote.setMark(true);
                    	  //ncp.ppAddBkmrk_actionPerformed(currentNote);
                    	  //list.updateUI();
                    	  list.repaint();
                      }
     	         }
     	    }
     	});*/
        
        String s = value.toString();
        label.setText(s);
        //Note currentNote = CurrentProject.getNoteList().getActiveNote();
	 Note currentNote = CurrentNote.get();
        if (currentNote != null) {
           if (getNote(index).getId().equals(currentNote.getId()))
               label.setFont(label.getFont().deriveFont(Font.BOLD));
        }
        if (getNote(index).isMarked()){
            label.setIcon(bookmarkIcon);
         }
         else{
       	 //All new notes will be initialized with an empty star.
        	 label.setIcon(emptyStar);
         }
        //setIcon();
      /*if (isSelected) {
            setBackground(list.getSelectionBackground());
          setForeground(list.getSelectionForeground());
      }
        else {
          setBackground(list.getBackground());
          setForeground(list.getForeground());
      }
      setEnabled(list.isEnabled());
      setFont(list.getFont());
        setOpaque(true);*/
        label.setToolTipText(s);
        return label;
    }
   };

}
 
Example 20
Project: freecol   File: CompactLabourReport.java   View Source Code Vote up 4 votes
private void addLocationSummary(LabourData.LocationData data, int row) {
    int rows = data.getRowCount();

    JLabel colonistsLabel = createNumberLabel(data.getTotalColonists(), null);
    if (data.getUnitData().isSummary()) {
        if (isOverview()) {
            reportPanel.add(createEmptyLabel(), "cell " + UNIT_TYPE_COLUMN + " " + row + " 1 " + rows);
        }
    } else {
        Utility.localizeToolTip(colonistsLabel, StringTemplate
            .template("report.labour.unitTotal.tooltip")
            .addName("%unit%", data.getUnitData().getUnitName()));
    }

    reportPanel.add(colonistsLabel, "cell " + COLONIST_SUMMARY_COLUMN + " " + row + " 1 " + data.getRowCount());

    if (showProduction && !data.getUnitData().showProduction()) {
        reportPanel.add(createEmptyLabel(), "cell " + PRODUCTION_SYMBOL_COLUMN + " " + row + " 4 " + rows);
        return;
    }

    if (showProduction) {
        JLabel productionLabel = createNumberLabel(data.getTotalProduction(), "report.labour.potentialProduction.tooltip");
        if (!data.isTotal() && data.getTotalProduction() == 0) {
            productionLabel.setText("");
        }

        reportPanel.add(productionLabel, "cell " + PRODUCTION_SUMMARY_COLUMN + " " + row + " 1 " + rows);
    }

    if (showNetProduction) {
        int net = data.getNetProduction();
        JLabel netProductionLabel = createNumberLabel(net, "report.labour.netProduction.tooltip");

        if (!data.getUnitData().showNetProduction() || (!data.isTotal() && net == 0)) {
            netProductionLabel.setText("");
            netProductionLabel.setToolTipText("");
        } else if (net >= 0) {
            netProductionLabel.setText("+" + net);
        } else {
            netProductionLabel.setForeground(Color.RED);
        }
        reportPanel.add(netProductionLabel, "cell " + NETPRODUCTION_SUMMARY_COLUMN + " " + row + " 1 " + rows);
    }

    if (showProductionSymbols) {
        JLabel icon = new JLabel();
        icon.setBorder(Utility.CELLBORDER);
        GoodsType goods = data.getUnitData().getExpertProduction();
        if (goods != null) {
            icon.setIcon(new ImageIcon(getImageLibrary().getIconImage(goods)));
        }
        reportPanel.add(icon, "cell " + PRODUCTION_SYMBOL_COLUMN + " " + row + " 1 " + rows);
    }
}