@SuppressWarnings("static-method") @Test public void testShowToolTip() { UtilsTest.LOGGER.info("testShowToolTip"); try { boolean show; final JWindow tip = new JWindow(); final JButton boton = new JButton(); final JLabel tipText = new JLabel(); show = true; Utils.showToolTip(show, tip, boton, tipText); Assert.assertTrue(tip.isVisible() == true); show = false; Utils.showToolTip(show, tip, boton, tipText); Assert.assertTrue(tip.isVisible() == false); } catch (final java.awt.HeadlessException e) { } }
public static void showToolTip(final boolean show, final JWindow tip, final JButton boton, final JLabel tipText){ tipText.setText(boton.getToolTipText()); tip.setBackground((Color)UIManager.get("ToolTip.background")); tipText.setBackground((Color)UIManager.get("ToolTip.background")); tipText.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK), BorderFactory.createEmptyBorder(0,3,0,3))); tipText.setFont((Font)UIManager.get("ToolTip.font")); tipText.setOpaque(true); tip.add(tipText); Point p = new Point(); try{ p = boton.getLocationOnScreen(); } catch(final IllegalComponentStateException e){ } int factor = 0; if (boton.getSize().getHeight()>34){ factor = (int)(boton.getSize().getHeight()*0.5); } tip.setLocation((int)p.getX(),(int)p.getY()+30+factor); tip.pack(); tip.setVisible(show); }
Utils { public static void showToolTip(final boolean show, final JWindow tip, final JButton boton, final JLabel tipText){ tipText.setText(boton.getToolTipText()); tip.setBackground((Color)UIManager.get("ToolTip.background")); tipText.setBackground((Color)UIManager.get("ToolTip.background")); tipText.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK), BorderFactory.createEmptyBorder(0,3,0,3))); tipText.setFont((Font)UIManager.get("ToolTip.font")); tipText.setOpaque(true); tip.add(tipText); Point p = new Point(); try{ p = boton.getLocationOnScreen(); } catch(final IllegalComponentStateException e){ } int factor = 0; if (boton.getSize().getHeight()>34){ factor = (int)(boton.getSize().getHeight()*0.5); } tip.setLocation((int)p.getX(),(int)p.getY()+30+factor); tip.pack(); tip.setVisible(show); } }
Utils { public static void showToolTip(final boolean show, final JWindow tip, final JButton boton, final JLabel tipText){ tipText.setText(boton.getToolTipText()); tip.setBackground((Color)UIManager.get("ToolTip.background")); tipText.setBackground((Color)UIManager.get("ToolTip.background")); tipText.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK), BorderFactory.createEmptyBorder(0,3,0,3))); tipText.setFont((Font)UIManager.get("ToolTip.font")); tipText.setOpaque(true); tip.add(tipText); Point p = new Point(); try{ p = boton.getLocationOnScreen(); } catch(final IllegalComponentStateException e){ } int factor = 0; if (boton.getSize().getHeight()>34){ factor = (int)(boton.getSize().getHeight()*0.5); } tip.setLocation((int)p.getX(),(int)p.getY()+30+factor); tip.pack(); tip.setVisible(show); } private  Utils(); }
Utils { public static void showToolTip(final boolean show, final JWindow tip, final JButton boton, final JLabel tipText){ tipText.setText(boton.getToolTipText()); tip.setBackground((Color)UIManager.get("ToolTip.background")); tipText.setBackground((Color)UIManager.get("ToolTip.background")); tipText.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK), BorderFactory.createEmptyBorder(0,3,0,3))); tipText.setFont((Font)UIManager.get("ToolTip.font")); tipText.setOpaque(true); tip.add(tipText); Point p = new Point(); try{ p = boton.getLocationOnScreen(); } catch(final IllegalComponentStateException e){ } int factor = 0; if (boton.getSize().getHeight()>34){ factor = (int)(boton.getSize().getHeight()*0.5); } tip.setLocation((int)p.getX(),(int)p.getY()+30+factor); tip.pack(); tip.setVisible(show); } private  Utils(); static void openFile(final String filepath); static void openFile(final File file); static char getLanguageMnemonic(final List<Character> mnemonicList, final String actualLanguage); static void remarcar(final JComponent component); static void setContrastColor(final JComponent component); static void setFontBold(final JComponent component); static String remarkMnemonic( final String text, final int key); static FileFilter getRepositoryFileFilterPkcs12(); static FileFilter getRepositoryFileFilterPkcs11(); static void showToolTip(final boolean show, final JWindow tip, final JButton boton, final JLabel tipText); }
Utils { public static void showToolTip(final boolean show, final JWindow tip, final JButton boton, final JLabel tipText){ tipText.setText(boton.getToolTipText()); tip.setBackground((Color)UIManager.get("ToolTip.background")); tipText.setBackground((Color)UIManager.get("ToolTip.background")); tipText.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK), BorderFactory.createEmptyBorder(0,3,0,3))); tipText.setFont((Font)UIManager.get("ToolTip.font")); tipText.setOpaque(true); tip.add(tipText); Point p = new Point(); try{ p = boton.getLocationOnScreen(); } catch(final IllegalComponentStateException e){ } int factor = 0; if (boton.getSize().getHeight()>34){ factor = (int)(boton.getSize().getHeight()*0.5); } tip.setLocation((int)p.getX(),(int)p.getY()+30+factor); tip.pack(); tip.setVisible(show); } private  Utils(); static void openFile(final String filepath); static void openFile(final File file); static char getLanguageMnemonic(final List<Character> mnemonicList, final String actualLanguage); static void remarcar(final JComponent component); static void setContrastColor(final JComponent component); static void setFontBold(final JComponent component); static String remarkMnemonic( final String text, final int key); static FileFilter getRepositoryFileFilterPkcs12(); static FileFilter getRepositoryFileFilterPkcs11(); static void showToolTip(final boolean show, final JWindow tip, final JButton boton, final JLabel tipText);  }