@Override protected void query(CompletionResultSet completionResultSet, Document document, int i) { JToolTip toolTip = new JToolTip(); toolTip.setTipText("Press Enter to insert \"" + getText() + "\""); completionResultSet.setToolTip(toolTip); completionResultSet.finish(); } });
/** * Gets the text displayed as a tooltip. * * @return Displayed text. */ public String getText() { return toolTip.getTipText(); }
@Override public Point getToolTipLocation(MouseEvent event) { JToolTip tip = createToolTip(); tip.setTipText(getToolTipText()); Dimension d = tip.getPreferredSize(); Point retValue = new Point(getWidth() - d.width, -d.height); return retValue; }
public class CButton extends JButton { public CButton(String text, Icon icon) { super(text, icon); } @Override public JToolTip createToolTip() { JToolTip toolTip = super.createToolTip(); toolTip.setForeground(Color.BLACK); toolTip.setBackground(Color.WHITE); toolTip.setFont(new Font("Arial", Font.PLAIN, 12)); return toolTip; } };
@Override public JToolTip createToolTip() { JToolTip tooltip = super.createToolTip(); tooltip.setBorder(BorderFactory.createLineBorder(new Color(76,79,83))); tooltip.setBackground(new Color(255, 247, 200)); return tooltip; }
private JToolTip prepareTooltip(JComponent content) { JToolTip toolTip = new JToolTip(); toolTip.setLayout(new BorderLayout()); toolTip.add(content); toolTip.setPreferredSize(content.getPreferredSize()); toolTip.setFocusable(false); toolTip.setComponent(this); ToolTipManager.sharedInstance().setDismissDelay(TOOL_TIP_DISMISS_DELAY); return toolTip; }
private void hintLabelMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_hintLabelMousePressed JToolTip tooltip = new JToolTip(); tooltip.setTipText(NbBundle.getMessage(ResourcePanelImpl.class, "ResourcePanelImpl_ToolTip")); // NOI18N if (tooltip.getPreferredSize().width > size.width) { // force the tooltip to wrap text View v = (View) tooltip.getClientProperty("html"); // NOI18N if (v != null) { v.setSize(size.width, 0); tooltip.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent ev) {
/** * Creates a new tooltip. If overlapping is true then the tooltip will take on the foreground/background color and * font of the specified component (if the component isspecifiedd) * * @param c the component the tooltip describes * @param overlapping whether the tooltip is for a normal or overlapping tooltip * @return the new tooltip object */ public JToolTip createToolTip(JComponent c, boolean overlapping) { JToolTip tt = new JToolTip(); if (c != null) { tt.setComponent(c); if (overlapping) { if (c.getBackground() != null) { Color bg = c.getBackground(); if (bg.getAlpha() != 255) { bg = new Color(bg.getRed(), bg.getGreen(), bg.getBlue()); } tt.setBackground(bg); } if (c.getForeground() != null) { tt.setForeground(c.getForeground()); } if (c.getFont() != null) { tt.setFont(c.getFont()); } } } return tt; }
private void applyToolTipText() { JComponent tt = getToolTip(); if (tt != null) { if (tt instanceof JLabel) { ((JLabel)tt).setText(toolTipText); } else if (tt instanceof JTextComponent) { ((JTextComponent)tt).setText(toolTipText); } else if (tt instanceof javax.swing.JToolTip) { ((javax.swing.JToolTip)tt).setTipText(toolTipText); } else { try { java.lang.reflect.Method m = tt.getClass().getMethod("setText", // NOI18N new Class[] { String.class }); if (m != null) { m.invoke(toolTip, new Object[] { toolTipText }); } } catch (NoSuchMethodException e) { } catch (IllegalAccessException e) { } catch (java.lang.reflect.InvocationTargetException e) { } } } }
public void setText(final String text) { // Only change if different if (!ValueUtils.areEqual(text, toolTip.getTipText())) { final boolean wasVisible = isVisible(); if (wasVisible) { setVisible(false); } toolTip.setTipText(text); if (wasVisible) { setVisible(wasVisible); } } }
public final Point getToolTipLocation(MouseEvent _evt) { Point r = super.getToolTipLocation(_evt); if (r == null) { JToolTip tt = new JToolTip(); tt.setToolTipText(getToolTipText()); r = new Point(0, -tt.getPreferredSize().height - 1); } return r; }
/** * @see JWindow#setVisible(boolean) */ @Override public void setVisible(boolean visible) { setSize(toolTip.getPreferredSize()); followOwner(); if ((toolTip.getTipText() != null) && (!toolTip.getTipText().isEmpty())) { super.setVisible(visible); } }
/** * Paints the specified component. * * @param context * context for the component being painted * @param g * the {@code Graphics} object used for painting * @see #update(Graphics,JComponent) */ protected void paint(SynthContext context, Graphics g) { JToolTip tip = (JToolTip) context.getComponent(); Insets insets = tip.getInsets(); View v = (View) tip.getClientProperty(BasicHTML.propertyKey); if (v != null) { Rectangle paintTextR = new Rectangle(insets.left, insets.top, tip.getWidth() - (insets.left + insets.right), tip.getHeight() - (insets.top + insets.bottom)); v.paint(g, paintTextR); } else { g.setColor(context.getStyle().getColor(context, ColorType.TEXT_FOREGROUND)); g.setFont(style.getFont(context)); context.getStyle().getGraphicsUtils(context).paintText(context, g, tip.getTipText(), insets.left, insets.top, -1); } }
public void actionPerformed(final ActionEvent _ae) { if ("VALID".equals(_ae.getActionCommand())) { final boolean isValidValue = isValideValue(); final JToolTip tp = createToolTip(); tp.setTipText(isValidValue ? CtuluLib.getS("Valide") : CtuluLib.getS("Non valide")); tp.setSize(tp.getPreferredSize()); final Point l = CtuluExprTextField.this.getLocationOnScreen(); final Popup popup = PopupFactory.getSharedInstance().getPopup(CtuluExprTextField.this, tp, (int) l.getX(), (int) l.getY()); popup.show(); final Timer t = new Timer(750, new ActionListener() { public void actionPerformed(ActionEvent _evt) { popup.hide(); } }); t.setRepeats(false); t.start(); } // boite de dialogue pour l'editeur d'expression. else if ("EDIT".equals(_ae.getActionCommand())) { editFormula(); } } });
protected JToolTip createCellTip() { return new JToolTip(); }
/** * @see java.awt.Component#getPreferredSize() */ public Dimension getPreferredSize() { if ( getComponentCount() > 0 ) { Dimension d = getComponent(0).getPreferredSize(); Insets ins = getInsets(); return new Dimension(d.width+ins.left+ins.right, d.height+ins.top+ins.bottom); } else { return super.getPreferredSize(); } }
JButton btn = new JButton("SAVE"){ public JToolTip createToolTip() { JToolTip tip_for_button = new JToolTip(){ public String getTipText() { return "blah blah"; } }; tip_for_button.setComponent(this); return tip_for_button; } }; btn.setToolTipText("notnull");
/** Creates a new instance of JExtendedTree */ public JExtendedTree() { addMouseListener(componentListener); addMouseMotionListener(componentListener); setRowHeight(UIUtils.getDefaultRowHeight()); // celltips require to have row height initialized! // --- CellTip support ------------------ cellTip = createCellTip(); cellTip.setBackground(getBackground()); cellTip.setBorder(BorderFactory.createLineBorder(UIConstants.TABLE_VERTICAL_GRID_COLOR)); cellTip.setLayout(new BorderLayout()); CellTipManager.sharedInstance().registerComponent(this); }
private void showToolTip(MouseEvent e) { Track s = player.getTrack(); if (s != null) { toolTip.setTipText(Util.samplesToTime(progressSlider.getValue() - progressSlider.getMinimum(), s.getTrackData().getSampleRate(), 1)); int x = e.getXOnScreen(); x = Math.max(x, progressSlider.getLocationOnScreen().x); x = Math.min(x, progressSlider.getLocationOnScreen().x + progressSlider.getWidth() - toolTip.getWidth()); popup = popupFactory.getPopup(progressSlider, toolTip, x, progressSlider.getLocationOnScreen().y + 25); popup.show(); } }