当前位置: 首页>>代码示例>>Java>>正文


Java JLabel.setToolTipText方法代码示例

本文整理汇总了Java中javax.swing.JLabel.setToolTipText方法的典型用法代码示例。如果您正苦于以下问题:Java JLabel.setToolTipText方法的具体用法?Java JLabel.setToolTipText怎么用?Java JLabel.setToolTipText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JLabel的用法示例。


在下文中一共展示了JLabel.setToolTipText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getListCellRendererComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:TableUISupport.java

示例2: mouseEntered

import javax.swing.JLabel; //导入方法依赖的package包/类
@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);
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:24,代码来源:LuceneDataStoreSearchGUI.java

示例3: getCellRenderer

import javax.swing.JLabel; //导入方法依赖的package包/类
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;
    }
   };

}
 
开发者ID:ser316asu,项目名称:Neukoelln_SER316,代码行数:40,代码来源:NotesList.java

示例4: IOObjectCacheEntryPanel

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:51,代码来源:IOObjectCacheEntryPanel.java

示例5: setText

import javax.swing.JLabel; //导入方法依赖的package包/类
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);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:StatusBar.java

示例6: createField

import javax.swing.JLabel; //导入方法依赖的package包/类
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);
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:10,代码来源:BaseDialogGUI.java

示例7: labelModFile

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * 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));
    }
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:14,代码来源:ModOptionUI.java

示例8: GuiPayloadField

import javax.swing.JLabel; //导入方法依赖的package包/类
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);
			}
		}
 
开发者ID:adelbs,项目名称:ISO8583,代码行数:81,代码来源:PayloadMessageConfig.java

示例9: setToolTip

import javax.swing.JLabel; //导入方法依赖的package包/类
/** 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);
    }
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:11,代码来源:Query.java

示例10: addURL

import javax.swing.JLabel; //导入方法依赖的package包/类
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);
}
 
开发者ID:mvetsch,项目名称:JWT4B,代码行数:8,代码来源:JLabelLink.java

示例11: getTreeCellRendererComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:Renderers.java

示例12: getOptionsComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
@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;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:28,代码来源:SOMModelPlotter.java

示例13: getOptionsComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
@Override
public JComponent getOptionsComponent(int index) {
	JLabel label = new JLabel("K:");
	label.setToolTipText("Set the k which should be displayed.");
	return label;

}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:8,代码来源:SimilarityKDistanceVisualization.java

示例14: getCellRenderer

import javax.swing.JLabel; //导入方法依赖的package包/类
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;
    }
   };

}
 
开发者ID:ser316asu,项目名称:SER316-Dresden,代码行数:40,代码来源:NotesList.java

示例15: addLocationSummary

import javax.swing.JLabel; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:56,代码来源:CompactLabourReport.java


注:本文中的javax.swing.JLabel.setToolTipText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。