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

The following examples show how to use javax.swing.JLabel#setToolTipText() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
/**
 * Returns the rendered cell.
 *
 * @param jtPolicyInformation
 *            The JTable
 * @param value
 *            The value to assign to the cell
 * @param isSelected
 *            True if cell is selected
 * @param row
 *            The row of the cell to render
 * @param col
 *            The column of the cell to render
 * @param hasFocus
 *            If true, render cell appropriately
 * @return The renderered cell
 */
@Override
public Component getTableCellRendererComponent(JTable jtPolicyInformation, Object value, boolean isSelected,
		boolean hasFocus, int row, int col) {
	JLabel cell = (JLabel) super.getTableCellRendererComponent(jtPolicyInformation, value, isSelected, hasFocus,
			row, col);

	PolicyInformation policyInformation = (PolicyInformation) value;

	try {
		String policyInformationStr = PolicyInformationUtil.toString(policyInformation);
		cell.setText(policyInformationStr);
		cell.setToolTipText(policyInformationStr);
	} catch (IOException ex) {
		throw new RuntimeException(ex); // We build this data so should not
		// happen
	}

	cell.setHorizontalAlignment(LEFT);
	cell.setBorder(new EmptyBorder(0, 5, 0, 5));

	return cell;
}
 
Example 2
/**
 * Liefert die Komponente zur Darstellung des Attributs (hier das Label mit
 * dem Text, den das Attribut in seiner toString()- Methode liefert. Ist das
 * Attribut in der Zeile nicht veränderbar, so wird für das Label
 * <code>enabled(false)</code> gesetzt.
 *
 * @return
 */
@Override
public Component getTableCellRendererComponent(
    JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {

  JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected,
                                                              hasFocus, row, column);
  label.setText(value.toString());

  if (value instanceof AbstractProperty
      && ((AbstractProperty) value).getValue() instanceof AcceptableInvalidValue) {
    AbstractProperty property = (AbstractProperty) value;
    AcceptableInvalidValue invalidValue = (AcceptableInvalidValue) property.getValue();
    label.setText(invalidValue.getDescription());
    label.setToolTipText(invalidValue.getHelptext());
  }
  else if (value instanceof Property) {
    label.setToolTipText(((Property) value).getHelptext());
  }

  decorate(table, row, column, label, value);

  return this;
}
 
Example 3
private JTextField addSettingsRow(JPanel column, int length, String name, String tip, String value) {
		JPanel panel = new JPanel();
		column.add(panel);
		panel.setLayout(new GridLayout(1,2,5,5));
		JLabel lblDisplayModuleFont = new JLabel(name);
		lblDisplayModuleFont.setToolTipText(tip);
		panel.add(lblDisplayModuleFont);
		JTextField textField = new JTextField(value);
		panel.add(textField);
		textField.setColumns(length);
		textField.addActionListener(this);
		textField.addFocusListener(this);

//		column.add(new Box.Filler(new Dimension(10,5), new Dimension(10,5), new Dimension(10,5)));

		return textField;
	
	}
 
Example 4
Source Project: ignite   File: AboutDialog.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Add name and value labels.
 *
 * @param c Component.
 * @param name Name.
 * @param val Value.
 * @param border Border.
 */
private void addAboutItem(JComponent c, String name, Object val, Border border) {
    String v = val != null ? val.toString() : "n/a";
    String tip = String.format("<html><b>%s</b> &#10159; %s</html>", name, val);

    JLabel lb = new JLabel(name);
    lb.setToolTipText(tip);

    JLabel field = new JLabel(v);
    field.setOpaque(true);
    field.setBackground(Color.WHITE);
    field.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(VALUE_BORDER_COLOR, 1),
        BorderFactory.createEmptyBorder(0, 3, 0, 3)));

    field.setToolTipText(tip);

    if (border != null)
        field.setBorder(border);

    c.add(lb, gbcLicenseLabel());
    c.add(field, gbcLicenseField());
}
 
Example 5
/**
 * Returns the rendered header cell for the supplied value and column.
 *
 * @param jtRevokedCerts
 *            The JTable
 * @param value
 *            The value to assign to the cell
 * @param isSelected
 *            True if cell is selected
 * @param row
 *            The row of the cell to render
 * @param col
 *            The column of the cell to render
 * @param hasFocus
 *            If true, render cell appropriately
 * @return The renderered cell
 */
@Override
public Component getTableCellRendererComponent(JTable jTable, Object value, boolean isSelected,
		boolean hasFocus, int row, int col) {

	Component c = delegate.getTableCellRendererComponent(jTable, value, isSelected, hasFocus, row, col);

	if (c instanceof JLabel) {
		JLabel header = (JLabel) c;

		if (col == 0) {
			header.setToolTipText(res.getString("RevokedCertsTableHeadRend.SerialNumberColumn.tooltip"));
		} else {
			header.setToolTipText(res.getString("RevokedCertsTableHeadRend.RevocationDateColumn.tooltip"));
		}
	}

	return c;
}
 
Example 6
@Override
public Component getListCellRendererComponent(JList<?> list, Object value,
		int index, boolean isSelected, boolean cellHasFocus)
{
	JLabel label = (JLabel) super.getListCellRendererComponent(list, value,
			index, isSelected, cellHasFocus);

	Message message = (Message) value;
	if (message.getCategory() != null)
	{
		if (message.getCategory().equals(MessageCategory.admin))
		{
			label.setForeground(Color.GRAY);
		} else
		{
			label.setForeground(Color.BLUE);
		}
	} else
	{
		label.setText("<html><b><font color = '#669900'>" + label.getText()
				+ "</font><b></html>");
	}

	if (isSelected)
	{
		label.setBackground(Color.LIGHT_GRAY);
		label.setToolTipText("Double-click to look-up in FIXwiki");
	}

	return label;
}
 
Example 7
public Component getListCellRendererComponent(JList<?> list, Object value,
		int index, boolean isSelected, boolean cellHasFocus) {
	Component component = super.getListCellRendererComponent(list, value,
			index, isSelected, cellHasFocus);
	if (component instanceof JLabel && value instanceof File) {
		JLabel label = (JLabel) component;
		File f = (File) value;
		label.setIcon(FileSystemView.getFileSystemView().getSystemIcon(f));
		label.setText(f.getName());
		label.setToolTipText(f.getAbsolutePath());
	}
	return component;
}
 
Example 8
Source Project: jeddict   File: TableUISupport.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    Table table = null;
    Object displayName = null;
    boolean referenced = false;
    TableClosure tableClosure = null;
    DisabledReason disabledReason = null;
    if (value instanceof Table) {
        table = (Table) value;

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

        if (list.getModel() instanceof SelectedTablesModel) {
            SelectedTablesModel model = (SelectedTablesModel) list.getModel();
            tableClosure = model.getTableClosure();
            referenced = tableClosure.getReferencedTables().contains(table);
        }
    } else {
        displayName = value;
    }

    JLabel component = (JLabel) super.getListCellRendererComponent(list, displayName, index, isSelected, cellHasFocus);
    component.setEnabled(!referenced && !(table.isDisabled()));
    String tooltip = referenced ? getTableTooltip(table, tableClosure) : null;
    if (table.isDisabled()) {
        String descr = table.getDisabledReason().getDescription();
        tooltip = tooltip == null ? descr : tooltip.concat("<br>" + descr); //NOI18N
    }
    component.setToolTipText(tooltip);

    return component;
}
 
Example 9
Source Project: zap-extensions   File: WebSocketPanel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Show textual hint for filter status.
 *
 * @param filter
 */
private void setFilterStatus() {
    WebSocketMessagesViewFilter filter = getFilterDialog().getFilter();
    JLabel status = getFilterStatus();

    status.setText(filter.toLongString());
    status.setToolTipText(filter.toLongString());
}
 
Example 10
Source Project: sc2gears   File: SharedUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a label which operates as a link.
 * The link will only be opened if the label is not disabled.
 * The target URL is set as the tool of the label.
 * @param text      text of the label (link)
 * @param targetUrl URL to be opened when the user clicks on the label
 * @return the label which operates as a link
 */
public static JLabel createLinkLabel( final String text, final String targetUrl ) {
	final JLabel label = createLinkStyledLabel( text );
	label.setIcon( APPLICATION_BROWSER );
	label.setToolTipText( targetUrl );
	
	label.addMouseListener( new MouseAdapter() {
		public void mouseClicked( final MouseEvent event ) {
			showURLInBrowser( targetUrl );
		};
	} );
	
	return label;
}
 
Example 11
public Component getTableCellRendererComponent(JTable table, Object value,
		boolean isSelected, boolean hasFocus, int row, int column) {
		JLabel l = null;
		TaskingTable t = (TaskingTable)table;
	switch (column){
		case 0://类别
			l = new AJLabel(t.getTasks().size() + "", "", color, JLabel.CENTER);
			l.setFont(FontConst.Georgia_BOLD_12);
			l.setToolTipText("漫画总数(按照阅读状态排序)");
			return l;
		case 1://名称
			l = new AJLabel(value.toString() + "", "", color, JLabel.LEFT);
			l.setToolTipText("切换排序(名称/创建时间)");
			return l;
		case 2://图片数
			l = new AJLabel(value.toString(), "", color, JLabel.LEFT);
			l.setToolTipText("按照漫画总数降序排序");
			return l;
		case 3://语言
			l =  new AJLabel(value.toString(), "", color, JLabel.LEFT);
			l.setToolTipText("按照漫画语言排序");
			return l;
		case 4://下载进度
			l =  new AJLabel(value.toString(), "", color, JLabel.CENTER);
			l.setToolTipText("按照漫画进度降序排序");
			return l;
		case 5://状态
			l = new AJLabel(value.toString(), "", color, JLabel.CENTER);
			l.setToolTipText("按照漫画下载状态排序");
			return l;
		default:
			return new AJLabel(value.toString(), color);
	}
}
 
Example 12
@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 13
Source Project: atdl4j   File: SwingTextFieldWidget.java    License: MIT License 4 votes vote down vote up
public void createWidget(JPanel parent)
{
	// tooltip
	String tooltip = control.getTooltip();
	
	// label		
	if ( control.getLabel() != null ) {
		label = new JLabel();
		label.setName(getName()+"/label");
		label.setText(control.getLabel());
		if ( tooltip != null ) label.setToolTipText( tooltip );
	}
			
	// textField
	textField = new JFormattedTextField();
	textField.setName(getName()+"/text");
	
	// init value
	if ( ControlHelper.getInitValue( control, getAtdl4jOptions() ) != null )
		textField.setText( (String) ControlHelper.getInitValue( control, getAtdl4jOptions() ) );

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

	if (label != null){
		wrapper = new JPanel(new GridBagLayout());
		GridBagConstraints c = new GridBagConstraints();
		c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 0;   
    c.gridwidth = 1;
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.insets = new Insets(0, 0, 0, 0);
    wrapper.add( label, c);
		c.gridx = 1;
    c.gridy = 0;
    c.insets = new Insets(0, 0, 0, 0);
    wrapper.add( textField, c);
		parent.add(wrapper);
	}
	else {
		parent.add(textField);
	}

	textField.setPreferredSize(new Dimension(100, textField.getPreferredSize().height));
	textField.revalidate();
}
 
Example 14
/**
 * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable,
 *      java.lang.Object, boolean, boolean, int, int)
 */
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
    boolean hasFocus, int row, int column) {

  JLabel newLabel = new JLabel();
  newLabel.setHorizontalAlignment(JLabel.LEFT);
  newLabel.setFont(defaultFont);
  newLabel.setOpaque(true);

  Color bgColor;

  if (isSelected)
    bgColor = table.getSelectionBackground();
  else
    bgColor = table.getBackground();

  newLabel.setBackground(bgColor);

  if (hasFocus) {
    Border border = null;
    if (isSelected)
      border = UIManager.getBorder("Table.focusSelectedCellHighlightBorder");
    if (border == null)
      border = UIManager.getBorder("Table.focusCellHighlightBorder");

    /*
     * The "border.getBorderInsets(newPanel) != null" is a workaround for OpenJDK 1.6.0 bug,
     * otherwise setBorder() may throw a NullPointerException
     */
    if ((border != null) && (border.getBorderInsets(newLabel) != null)) {
      newLabel.setBorder(border);
    }
  }

  if (value instanceof PeakIdentity) {

    PeakIdentity identity = (PeakIdentity) value;

    newLabel.setText(identity.getName());

    String toolTipText = identity.getDescription();

    newLabel.setToolTipText(toolTipText);

  }

  return newLabel;

}
 
Example 15
Source Project: triplea   File: UnitPanel.java    License: GNU General Public License v3.0 4 votes vote down vote up
UnitPanel(
    final UiContext uiContext, final UnitCategory category, final IntegerMap<UnitType> costs) {
  this.category = category;
  textField = new ScrollableTextField(0, 512);
  textField.setShowMaxAndMin(false);
  textField.addChangeListener(field -> notifyListeners());

  final String toolTipText =
      "<html>"
          + category.getType().getName()
          + ":  "
          + costs.getInt(category.getType())
          + " cost, <br /> &nbsp;&nbsp;&nbsp;&nbsp; "
          + TooltipProperties.getInstance().getTooltip(category.getType(), category.getOwner())
          + "</html>";
  setCount(category.getUnits().size());
  setLayout(new GridBagLayout());

  final Optional<Image> img =
      uiContext
          .getUnitImageFactory()
          .getImage(
              category.getType(),
              category.getOwner(),
              category.hasDamageOrBombingUnitDamage(),
              category.getDisabled());

  final JLabel label = img.map(image -> new JLabel(new ImageIcon(image))).orElseGet(JLabel::new);
  label.setToolTipText(toolTipText);
  add(
      label,
      new GridBagConstraints(
          0,
          0,
          1,
          1,
          0,
          0,
          GridBagConstraints.EAST,
          GridBagConstraints.NONE,
          new Insets(0, 0, 0, 10),
          0,
          0));
  add(
      textField,
      new GridBagConstraints(
          1,
          0,
          1,
          1,
          0,
          0,
          GridBagConstraints.EAST,
          GridBagConstraints.NONE,
          new Insets(0, 0, 0, 0),
          0,
          0));
}
 
Example 16
private JLabel buildThemeLabel() {
    JLabel label = new JLabel("Theme:");
    label.setToolTipText("It will be applied the next time ClassyShark is started");
    theme.applyTo(label);
    return label;
}
 
Example 17
Source Project: ChromeForensics   File: FileViewer.java    License: Apache License 2.0 4 votes vote down vote up
public void initComponents() {
    setLayout(new BorderLayout());

    fileMetadata = new JPanel(new BorderLayout());
    fileMetadata.setPreferredSize(new Dimension(getWidth(), 150));
    fileMetadata.setBackground(Color.BLACK);

    final DefaultTableModel tableModel = new DefaultTableModel() {

        @Override
        public boolean isCellEditable(int row, int column) {
            return true;
        }
    };

    metadataTable = new JTable(tableModel);

    metadataScroller = new JScrollPane(metadataTable);
    metadataScroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    metadataScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    metadataScroller.setBorder(BorderFactory.createTitledBorder(new LineBorder(Color.WHITE),
            "File Metadata Attributes", TitledBorder.CENTER, TitledBorder.TOP,
            new Font("Cambria", Font.ITALIC, 14), Color.WHITE));

    fileMetadata.add(metadataScroller, BorderLayout.CENTER);
    add(fileMetadata, BorderLayout.SOUTH);

    loadPanel = new JPanel(new FlowLayout());
    loadPanel.setBackground(new Color(0xe8e8e8));

    loadFileLabel = new JLabel("Load File: ");
    loadFileLabel.setToolTipText("Reads file as it would in a text editor.");

    loadedFileLoc = new JTextField("Click browse to choose the file.", 60);
    loadedFileLoc.setForeground(Color.GRAY);
    loadedFileLoc.setFont(new Font("Times New Roman", Font.ITALIC, 13));
    loadedFileLoc.setEditable(false);

    textArea = new JTextArea(10, 20);
    textArea.setLineWrap(false);
    textArea.setEditable(false);

    scrollPane = new JScrollPane(textArea);
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);

    lastFolderLocation = new File(Utils.getUserHome());
    fc = new JFileChooser(lastFolderLocation);

    browseDb = new JButton("Browse");
    browseDb.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            int retVal = fc.showOpenDialog(FileViewer.this);
            if (retVal == JFileChooser.APPROVE_OPTION) {

                final File fileLoc = fc.getSelectedFile();
                loadedFileLoc.setText(fileLoc.toString());
                lastFolderLocation = fc.getCurrentDirectory();

                new SwingWorker<Void, Void>() {

                    @Override
                    protected Void doInBackground() throws Exception {
                        String line;
                        try (BufferedReader reader = Files.newBufferedReader(fileLoc.toPath(),
                                StandardCharsets.ISO_8859_1)) {
                            textArea.setText("");
                            //reader.lines().map(s -> s + "\n").forEach(textArea::append);
                            while ((line = reader.readLine()) != null) {
                                textArea.append(line);
                                textArea.append("\n");
                            }
                            Object[][] dataVector = Utils.to2DObjectArray(Utils.getFileMetadata(fileLoc.toPath()));
                            tableModel.setDataVector(dataVector, new Object[]{"Attribute Name", "Value"});
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                        return null;
                    }
                }.execute();
            }
        }
    });

    loadPanel.add(loadFileLabel);
    loadPanel.add(loadedFileLoc);
    loadPanel.add(browseDb);

    add(loadPanel, BorderLayout.NORTH);
    add(scrollPane, BorderLayout.CENTER);
}
 
Example 18
private Box getPDBFilePanel(int pos ,JTextField f, JTextField c, JTextField r){

		//JPanel panel = new JPanel();
		//panel.setBorder(BorderFactory.createLineBorder(Color.black));

		JLabel l01 = new JLabel("PDB code ");

		//panel.add(l01);
		Box hBox = Box.createHorizontalBox();
		hBox.add(Box.createGlue());
		hBox.add(l01);

		JLabel l11 = new JLabel(pos + ":");
		f.setMaximumSize(new Dimension(Short.MAX_VALUE,30));
		f.setToolTipText("Provide 4-character PDB code here. Example: 4hhb");
		hBox.add(l11);
		hBox.add(Box.createVerticalGlue());
		hBox.add(f, BorderLayout.CENTER);
		hBox.add(Box.createGlue());

		//panel.add(hBox11);

		//Box hBox21 = Box.createHorizontalBox();
		JLabel l21 = new JLabel("Chain" + pos + ":");
		hBox.add(l21);

		c.setMaximumSize(new Dimension(Short.MAX_VALUE,30));
		//hBox.add(Box.createGlue());
		hBox.add(c, BorderLayout.CENTER);

		String msg1 = "Both chainID and range specification are optional. If both are provided, range has preference.";
		l21.setToolTipText(msg1);
		c.setToolTipText(msg1);

		JLabel rangeL = new JLabel(" Range " + pos + ":");
		hBox.add(Box.createGlue());
		hBox.add(rangeL);
		r.setMaximumSize(new Dimension(Short.MAX_VALUE,30));

		// set help text:
		String msg ="Syntax example: A:407-495,A:582-686";
		rangeL.setToolTipText(msg);
		r.setToolTipText(msg);

		//hBox.add(Box.createGlue());
		hBox.add(r,BorderLayout.CENTER);

		//hBox21.add(Box.createGlue());

		//panel.add(hBox21);



		return hBox;
	}
 
Example 19
private JLabel getIconLabel(MagicIcon magicIcon, String text, String tooltip) {
    final JLabel lbl = new JLabel(text);
    lbl.setIcon(MagicImages.getIcon(magicIcon));
    lbl.setToolTipText(tooltip);
    return lbl;
}
 
Example 20
private JLabel makeLabel() {
    JLabel label = new JLabel(makeLabelString(true));
    label.setToolTipText(description);
    return label;
}