javax.swing.JButton.getToolTipText()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(244)

本文整理了Java中javax.swing.JButton.getToolTipText()方法的一些代码示例,展示了JButton.getToolTipText()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JButton.getToolTipText()方法的具体详情如下:
包路径:javax.swing.JButton
类名称:JButton
方法名:getToolTipText

JButton.getToolTipText介绍

暂无

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-awt

  1. bStop.addActionListener(browserListener);
  2. bBack.getAccessibleContext().setAccessibleName(bBack.getToolTipText());
  3. bForward.getAccessibleContext().setAccessibleName(bForward.getToolTipText());
  4. bReload.getAccessibleContext().setAccessibleName(bReload.getToolTipText());
  5. bStop.getAccessibleContext().setAccessibleName(bStop.getToolTipText());
  6. txtLocation.getAccessibleContext().setAccessibleDescription(
  7. NbBundle.getMessage(HtmlBrowser.class, "ACSD_HtmlBrowser_Location")

代码示例来源:origin: MinecraftForge/Installer

  1. @Override
  2. public void actionPerformed(ActionEvent e)
  3. {
  4. openURL(sponsorButton.getToolTipText());
  5. }
  6. });

代码示例来源:origin: datacleaner/DataCleaner

  1. @Override
  2. public String getTooltip() {
  3. return _button.getToolTipText();
  4. }

代码示例来源:origin: stackoverflow.com

  1. public void actionPerformed(ActionEvent e) {
  2. // get the button that was pressed
  3. JButton b = (JButton) e.getSource();
  4. // fire appropriate event
  5. if(b.getToolTipText().equals("Set up simulation for normal execution")) {
  6. fireSimulationEvent(SimulationEvent.NORMAL_SETUP_EVENT);
  7. }
  8. else if(b.getToolTipText().equals("Set up to test Queen Lifespan or Food Levels")) {
  9. fireSimulationEvent(SimulationEvent.QUEEN_TEST_EVENT);
  10. }
  11. else if (b.getToolTipText().equals("Set up simulation for testing the Forager ant (Scouts are included)")) {
  12. // set for testing the forager ant
  13. fireSimulationEvent(SimulationEvent.FORAGER_TEST_EVENT);
  14. } else if (b.getToolTipText().equals("Set up simulation for testing the Soldier ant (Scouts are included")) {
  15. // set for testing the soldier ant
  16. fireSimulationEvent(SimulationEvent.SOLDIER_TEST_EVENT);
  17. } else if (b.getToolTipText().equals("Run the simulation continuously")) {
  18. // run the simulation continuously
  19. fireSimulationEvent(SimulationEvent.RUN_EVENT);
  20. } else if (b.getToolTipText().equals("Step through the simulation one turn at a time")) {
  21. // run the simulation one turn at a time
  22. fireSimulationEvent(SimulationEvent.STEP_EVENT);
  23. } else if (b.getToolTipText().equals("Stop or Pause the simulation")) {
  24. //stop everything
  25. fireSimulationEvent(SimulationEvent.STOP_EVENT);
  26. }

代码示例来源:origin: com.eas.platypus/platypus-js-forms

  1. @ScriptFunction(jsDoc = TOOLTIP_TEXT_JSDOC)
  2. @Override
  3. public String getToolTipText() {
  4. return super.getToolTipText();
  5. }

代码示例来源:origin: org.jsystemtest.systemobjects/swing-so

  1. public boolean checkComponent(Component comp){
  2. if (comp instanceof JButton){
  3. String toolTipStrin = ((JButton)comp).getToolTipText();
  4. String name = ((JButton)comp).getText();
  5. if(name != null && !name.equals("")){
  6. if(name.indexOf(toFind) >= 0){
  7. return true;
  8. }
  9. }
  10. if(toolTipStrin != null){
  11. if(toolTipStrin.indexOf(toFind) >= 0){
  12. return true;
  13. }
  14. }
  15. }
  16. return false;
  17. }

代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-client

  1. @Override
  2. public void actionPerformed(ActionEvent e) {
  3. File f;
  4. if (saving) {
  5. f = DialogUtils.chooseFileForSave(button.getToolTipText(), field.getText());
  6. } else {
  7. f = DialogUtils.chooseFileForOpen(button.getToolTipText(), null, null);
  8. }
  9. if(f != null){
  10. setPath(f.getAbsolutePath());
  11. }
  12. }
  13. });

代码示例来源:origin: com.axway.ats.framework/ats-uiengine

  1. private String getProperties(
  2. Component c ) {
  3. String properties = Formatting.inEdtFormat(c);
  4. if (c instanceof JButton) {
  5. String tooltip = ((JButton) c).getToolTipText();
  6. if (!StringUtils.isNullOrEmpty(tooltip)) {
  7. int lastBrIndex = properties.lastIndexOf(']');
  8. if (lastBrIndex > 0) {
  9. properties = properties.substring(0, lastBrIndex) + ", tooltip='" + tooltip
  10. + "'" + properties.substring(lastBrIndex);
  11. } else {
  12. return c.getClass().getName() + " [tooltip='" + tooltip + "']";
  13. }
  14. }
  15. }
  16. return properties;
  17. }

代码示例来源:origin: net.sf.squirrel-sql/squirrel-sql

  1. @Override
  2. public String getToolTipText(MouseEvent event)
  3. {
  4. JButton button = getButtonAt(event.getX());
  5. if (null == button)
  6. {
  7. return super.getToolTipText(event);
  8. }
  9. else
  10. {
  11. return button.getToolTipText();
  12. }
  13. }

代码示例来源:origin: realXuJiang/bigtable-sql

  1. @Override
  2. public String getToolTipText(MouseEvent event)
  3. {
  4. JButton button = getButtonAt(event.getX());
  5. if (null == button)
  6. {
  7. return super.getToolTipText(event);
  8. }
  9. else
  10. {
  11. return button.getToolTipText();
  12. }
  13. }

代码示例来源:origin: org.gosu-lang.gosu/gosu-editor

  1. @Override
  2. public String getToolTipText()
  3. {
  4. String superText = super.getToolTipText();
  5. if( superText == null || superText.length() == 0 )
  6. {
  7. return null; // Swing will not register us with the tooltip manager unless it detects a change
  8. }
  9. if( getAction() != null )
  10. {
  11. return GosuObjectUtil.toString( getAction().getValue( Action.SHORT_DESCRIPTION ) );
  12. }
  13. else
  14. {
  15. return superText;
  16. }
  17. }

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui

  1. private JMenuItem initFrom(final JButton _bt) {
  2. if (_bt == null) {
  3. return null;
  4. }
  5. final JMenuItem it = new JMenuItem();
  6. it.setIcon(_bt.getIcon());
  7. it.setText(_bt.getText());
  8. it.setToolTipText(_bt.getToolTipText());
  9. it.setEnabled(_bt.isEnabled());
  10. it.setActionCommand(_bt.getActionCommand());
  11. it.addActionListener(this);
  12. return it;
  13. }

代码示例来源:origin: stackoverflow.com

  1. @Override
  2. public Object getValueAt(int row, int column)
  3. {
  4. JButton button = getRow(row);
  5. switch (column)
  6. {
  7. case 0: return button.getText();
  8. case 1: return button.getToolTipText();
  9. case 2: return button.isEnabled();
  10. case 3: return button.isVisible();
  11. default: return null;
  12. }
  13. }

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

  1. @Override
  2. public String getToolTipText()
  3. {
  4. if( getAction() != null )
  5. {
  6. String tip;
  7. tip = GosuObjectUtil.toString( getAction().getValue( Action.SHORT_DESCRIPTION ) );
  8. if( tip == null || tip.isEmpty() )
  9. {
  10. tip = GosuObjectUtil.toString( getAction().getValue( Action.NAME ) );
  11. }
  12. String value = (String)getAction().getValue( Action.ACCELERATOR_KEY );
  13. if( value != null && !value.isEmpty() )
  14. {
  15. tip += " (" + value + ")";
  16. }
  17. return tip;
  18. }
  19. else
  20. {
  21. return super.getToolTipText();
  22. }
  23. }
  24. }

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

  1. @Override
  2. public String getToolTipText()
  3. {
  4. if( getAction() != null )
  5. {
  6. String tip;
  7. if( _tooltip != null )
  8. {
  9. tip = _tooltip.get();
  10. }
  11. else
  12. {
  13. tip = GosuObjectUtil.toString( getAction().getValue( Action.SHORT_DESCRIPTION ) );
  14. if( tip == null || tip.isEmpty() )
  15. {
  16. tip = GosuObjectUtil.toString( getAction().getValue( Action.NAME ) );
  17. }
  18. }
  19. String value = (String)getAction().getValue( Action.ACCELERATOR_KEY );
  20. if( value != null && !value.isEmpty() )
  21. {
  22. tip += " (" + value + ")";
  23. }
  24. return tip;
  25. }
  26. else
  27. {
  28. return super.getToolTipText();
  29. }
  30. }

代码示例来源:origin: vasl-developers/vasl

  1. private void CopyActionButton(JButton objDestButton, JButton objSourceButton, boolean bAction)
  2. {
  3. objDestButton.setText(objSourceButton.getText());
  4. try
  5. {
  6. if (objSourceButton.getIcon() != null)
  7. objDestButton.setIcon(objSourceButton.getIcon());
  8. }
  9. catch (Exception ex)
  10. {
  11. }
  12. if (bAction)
  13. {
  14. if (objSourceButton.getAction() != null)
  15. objDestButton.setAction(objSourceButton.getAction());
  16. }
  17. else
  18. {
  19. for (int l_i = 0; l_i < objSourceButton.getActionListeners().length; l_i++)
  20. objDestButton.addActionListener(objSourceButton.getActionListeners()[l_i]);
  21. }
  22. objDestButton.setToolTipText(objSourceButton.getToolTipText());
  23. objSourceButton.setVisible(false);
  24. }

代码示例来源:origin: triplea-game/triplea

  1. @Test
  2. void checkActionListener() {
  3. // button action will be to add one to our integer, we'll fire the button action and verify we get the +1
  4. final AtomicInteger integer = new AtomicInteger(0);
  5. final JButton button = JButtonBuilder.builder()
  6. .title("title")
  7. .actionListener(integer::incrementAndGet)
  8. .toolTip("toolTip")
  9. .build();
  10. Arrays.stream(button.getActionListeners())
  11. .forEach(listener -> listener.actionPerformed(new ActionEvent(new Object(), 0, "")));
  12. assertThat(integer.get(), is(1));
  13. assertThat(button.getToolTipText(), is("toolTip"));
  14. }

代码示例来源:origin: io.ultreia.java4all.jaxx/jaxx-widgets-about

  1. public AboutUIBuilder(Frame parent) {
  2. Objects.requireNonNull(parent);
  3. this.ui = new AboutUI(parent, true);
  4. Action closeAction = new AbstractAction(CLOSE_ACTION) {
  5. private static final long serialVersionUID = 1L;
  6. @Override
  7. public void actionPerformed(ActionEvent e) {
  8. ui.dispose();
  9. }
  10. };
  11. closeAction.putValue(Action.NAME, null);
  12. closeAction.putValue(Action.SMALL_ICON, ui.getClose().getIcon());
  13. closeAction.putValue(Action.SHORT_DESCRIPTION, ui.getClose().getToolTipText());
  14. ui.getClose().setAction(closeAction);
  15. JRootPane rootPane = ui.getRootPane();
  16. rootPane.setDefaultButton(ui.getClose());
  17. rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), CLOSE_ACTION);
  18. rootPane.getActionMap().put(CLOSE_ACTION, closeAction);
  19. }

代码示例来源:origin: org.nuiton.jaxx/jaxx-widgets-about

  1. public AboutUIBuilder(Frame parent) {
  2. Preconditions.checkNotNull(parent);
  3. this.ui = new AboutUI(parent, true);
  4. Action closeAction = new AbstractAction(CLOSE_ACTION) {
  5. private static final long serialVersionUID = 1L;
  6. @Override
  7. public void actionPerformed(ActionEvent e) {
  8. ui.dispose();
  9. }
  10. };
  11. closeAction.putValue(Action.NAME, null);
  12. closeAction.putValue(Action.SMALL_ICON, ui.getClose().getIcon());
  13. closeAction.putValue(Action.SHORT_DESCRIPTION, ui.getClose().getToolTipText());
  14. ui.getClose().setAction(closeAction);
  15. JRootPane rootPane = ui.getRootPane();
  16. rootPane.setDefaultButton(ui.getClose());
  17. rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), CLOSE_ACTION);
  18. rootPane.getActionMap().put(CLOSE_ACTION, closeAction);
  19. }

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-debugger-common2

  1. public Component getToolbarPresenter() {
  2. JButton button = new JButton();
  3. fixButtonLF(button);
  4. if (shared.iconResource() != null)
  5. button.putClientProperty("hideActionText", Boolean.TRUE);//NOI18N
  6. // need to assign Action after setting hideActionText
  7. button.setAction(this);
  8. if (getAccelerator() != null) {
  9. String ttt = button.getToolTipText();
  10. KeyStroke ks = getAccelerator();
  11. String ksText = " ("; // NOI18N
  12. int modifiers = ks.getModifiers();
  13. if (modifiers > 0) {
  14. ksText += KeyEvent.getKeyModifiersText(modifiers);
  15. // NB buttons use +
  16. // NB menu items use - (but sometimes +)
  17. // JLF uses - always
  18. ksText += "+"; // NOI18N
  19. }
  20. ksText += KeyEvent.getKeyText(ks.getKeyCode());
  21. ksText += ")"; // NOI18N
  22. ttt += ksText;
  23. button.setToolTipText(ttt);
  24. button.setMnemonic(0);
  25. }
  26. return button;
  27. }

相关文章

JButton类方法