List of usage examples for javax.swing JButton setToolTipText
@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.") public void setToolTipText(String text)
From source file:MainClass.java
public static void main(String args[]) { JFrame frame = new JFrame("Tooltip"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(); panel.setToolTipText("<HtMl>Tooltip<br>Message"); frame.add(panel, BorderLayout.CENTER); JButton button = new JButton("Hello, World") { public JToolTip createToolTip() { JToolTip tip = super.createToolTip(); tip.setBackground(Color.YELLOW); tip.setForeground(Color.RED); return tip; }/*from w w w . jav a 2s .c o m*/ public boolean contains(int x, int y) { if (x < 100) { setToolTipText("x < 100"); } else { setToolTipText("else"); } return super.contains(x, y); } }; button.setToolTipText("Hello, World"); frame.add(button, BorderLayout.NORTH); frame.setSize(300, 150); frame.setVisible(true); }
From source file:Main.java
/** * Convenience method for creating a JButton * @param text the text of the button/*from ww w. jav a2 s. c om*/ * @param tooltip the tooltip for the button * @param onClick the ActionListener to add * @return a button with the given text and ActionListener */ public static JButton button(String text, String tooltip, ActionListener onClick) { final JButton result = new JButton(text); result.setToolTipText(tooltip); result.addActionListener(onClick); return result; }
From source file:Main.java
/*************************************************************************** * Creates a {@link JButton} with settings that are common for toolbars. * /*from w w w . j a va 2s. co m*/ * @param tooltip * @param icon * @return **************************************************************************/ public static JButton createToolbarButton(String tooltip, Icon icon) { JButton button = new JButton("", icon); button.setFocusable(false); button.setBorderPainted(false); button.setToolTipText(tooltip); return button; }
From source file:Main.java
/** * @param label//from www .j ava 2 s.c om * @param icon * @return createb JButton used in toolbar */ public static JButton createToolbarButton(String label, Icon icon) { JButton button = new JButton(icon); button.setFocusPainted(false); button.setMargin(new Insets(0, 0, 0, 0)); button.setToolTipText(label); button.setActionCommand(label); return button; }
From source file:org.drugis.addis.gui.GUIFactory.java
public static JButton createIconButton(final String iconName, final String toolTipText) { suppressErrors(true);//from w ww .j a va 2s . com Icon icon = Main.IMAGELOADER.getIcon(iconName); if (icon == null) { suppressErrors(false); icon = MainWindow.IMAGELOADER.getIcon(iconName); // Fallback to MTC ImageLoader } JButton button = new JButton(icon); button.setToolTipText(toolTipText); return button; }
From source file:Main.java
/** * @param label/*from ww w . ja va2 s. c o m*/ * @param iconFileName * @return createb JButton used in toolbar */ public static JButton createToolbarButton(String label, String iconFileName) { JButton button = new JButton(new ImageIcon(iconFileName)); button.setFocusPainted(false); button.setMargin(new Insets(0, 0, 0, 0)); button.setToolTipText(label); button.setActionCommand(label); return button; }
From source file:de.fhg.iais.asc.ui.i18n.LocalizedUI.java
public static JButton createButton(String key, ActionListener listener) { key = "Button." + key; String tooltipText = Messages.getString("Tooltip." + key, ""); JButton button = new JButton(Messages.getString(key)); if (!StringUtils.isEmpty(tooltipText)) { button.setToolTipText(tooltipText); }//from w ww. ja v a 2 s . c om if (listener != null) { button.addActionListener(listener); } return button; }
From source file:org.drugis.mtc.gui.results.ResultsComponentFactory.java
/** * @param labelText Descriptive label for this memory usage entry * @param parent Parent for "save samples" dialog *//*www. j av a 2s .c o m*/ public static int buildMemoryUsage(final MTCModelWrapper<?> model, final String labelText, final PanelBuilder builder, final FormLayout layout, final int row, final JFrame parent) { final CellConstraints cc = new CellConstraints(); if (model.isSaved()) { LayoutUtil.addRow(layout); builder.add(new JLabel(labelText), cc.xy(1, row)); builder.add(new JLabel("N/A"), cc.xyw(3, row, 7)); return row + 2; } else { final MixedTreatmentComparison mtc = model.getModel(); final MCMCResultsMemoryUsageModel memoryModel = new MCMCResultsMemoryUsageModel(mtc.getResults()); final JLabel memory = BasicComponentFactory.createLabel(new ToStringValueModel(memoryModel)); final MCMCResultsAvailableModel resultsAvailableModel = new MCMCResultsAvailableModel(mtc.getResults()); final TaskTerminatedModel modelTerminated = new TaskTerminatedModel(mtc.getActivityTask()); final JButton clearButton = new JButton(MainWindow.IMAGELOADER.getIcon(FileNames.ICON_DELETE)); clearButton.setToolTipText("Clear results"); final BooleanAndModel modelFinishedAndResults = new BooleanAndModel( Arrays.<ValueModel>asList(modelTerminated, resultsAvailableModel)); Bindings.bind(clearButton, "enabled", modelFinishedAndResults); final JButton saveButton = new JButton(MainWindow.IMAGELOADER.getIcon(FileNames.ICON_SAVEFILE)); saveButton.setToolTipText("Save to R-file"); Bindings.bind(saveButton, "enabled", modelFinishedAndResults); saveButton.addActionListener(buildRButtonActionListener(mtc, parent)); clearButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { mtc.getResults().clear(); // FIXME: change MCMC contract so clear fires a MCMCResultsClearedEvent memoryModel.resultsEvent(new MCMCResultsEvent(mtc.getResults())); resultsAvailableModel.resultsEvent(new MCMCResultsEvent(mtc.getResults())); } }); LayoutUtil.addRow(layout); builder.add(new JLabel(labelText), cc.xy(1, row)); builder.add(memory, cc.xy(3, row)); builder.add(clearButton, cc.xy(5, row)); builder.add(saveButton, cc.xy(7, row)); return row + 2; } }
From source file:Main.java
/** * Returns a styled JButton./*from w ww . j ava2s . c o m*/ * * @param style button type * @return a styled button */ public static JButton creaStyledButton(int style) { JButton jb = new JButton(); jb.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); jb.setMargin(new Insets(0, 5, 1, 5)); switch (style) { case STYLE_EDIT: { jb.setText("edit"); jb.setToolTipText("edit"); jb.setPreferredSize(new Dimension(60, 30)); return jb; } case STYLE_OK: { jb.setText("ok"); jb.setToolTipText("confirm changes"); jb.setPreferredSize(new Dimension(60, 30)); return jb; } case STYLE_CANCEL: { jb.setText("cancel"); jb.setToolTipText("discard changes"); jb.setPreferredSize(new Dimension(60, 30)); return jb; } case STYLE_INSBEFOREROW: { jb.setIcon(ICON_INSBEFOREROW); jb.setToolTipText("insert row before"); jb.setName("INSBEFOREROW"); return jb; } case STYLE_INSAFTERROW: { jb.setIcon(ICON_INSAFTERROW); jb.setToolTipText("insert row after"); jb.setName("INSAFTERROW"); return jb; } case STYLE_DELETEROW: { jb.setIcon(ICON_DELETEROW); jb.setToolTipText("delete row"); jb.setName("DELETEROW"); return jb; } case STYLE_CLONEBEFOREROW: { jb.setIcon(ICON_CLONEBEFOREROW); jb.setToolTipText("clone row before"); jb.setName("CLONEBEFOREROW"); return jb; } case STYLE_CLONEAFTERROW: { jb.setIcon(ICON_CLONEAFTERROW); jb.setToolTipText("clone row after"); jb.setName("CLONEAFTERROW"); return jb; } case STYLE_DEFAULTROWS: { jb.setIcon(ICON_DEFAULTROWS); jb.setToolTipText("set default values"); jb.setName("DEFAULTROWS"); return jb; } default: { return null; } } }
From source file:de.ipk_gatersleben.ag_nw.graffiti.services.GUIhelper.java
public static JComponent getWebsiteButton(String title, final String url, final String opt_local_folder, final String optIntroText, final String optIntroDialogTitle) { JButton res = new JButton(title); res.setToolTipText("<html>Click button to open URL:<br><code><b>" + url); res.addActionListener(getDialogAction(url, opt_local_folder, optIntroText, optIntroDialogTitle)); return res;/*from w ww. j a v a 2s . co m*/ }