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

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

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

JButton.getClientProperty介绍

暂无

代码示例

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

  1. public int getDisclosureStateCount() {
  2. Integer value = (Integer) disclosureButton.getClientProperty(DisclosureIcon.STATE_COUNT_PROPERTY);
  3. return (value == null) ? 2 : value;
  4. }

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

  1. public int getDisclosureState() {
  2. Integer value = (Integer) disclosureButton.getClientProperty(DisclosureIcon.CURRENT_STATE_PROPERTY);
  3. return (value == null) ? 1 : value;
  4. }

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

  1. JButton button = (JButton)e.getSource();
  2. Color color = (Color)button.getClientProperty("color");
  3. panel.setBackground( color );

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

  1. JButton button = (JButton) actionEvent.getSource();
  2. Integer firstIndex = button.getClientProperty( "firstIndex" );
  3. Integer secondIndex = button.getClientProperty( "secondIndex" );

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

  1. JButton button = ae.getSource();
  2. int value = button.getClientProperty("Which").intValue();

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

  1. public class MyActionListener implements ActionListener {
  2. @Override
  3. public void actionPerformed(ActionEvent e) {
  4. JButton btn = (JButton) e.getSource();
  5. System.out.println("clicked column " + btn.getClientProperty("column")
  6. + ", row " + btn.getClientProperty("row"));
  7. }

代码示例来源:origin: Revivius/nb-darcula

  1. public static boolean isSquare(Component c) {
  2. if (c instanceof JButton) {
  3. JButton b = (JButton) c;
  4. return "square".equals(b.getClientProperty("JButton.buttonType"));
  5. }
  6. return false;
  7. }

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

  1. public class MyActionListener implements ActionListener {
  2. @Override
  3. public void actionPerformed(ActionEvent e) {
  4. JButton btn = (JButton) e.getSource();
  5. System.out.println("clicked column " + btn.getClientProperty("column")
  6. + ", row " + btn.getClientProperty("row"));
  7. }

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

  1. public class MyActionListener implements ActionListener {
  2. @Override
  3. public void actionPerformed(ActionEvent e) {
  4. JButton btn = (JButton) e.getSource();
  5. System.out.println("clicked column " + btn.getClientProperty("column")
  6. + ", row " + btn.getClientProperty("row"));
  7. }

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

  1. public class MyActionListener implements ActionListener {
  2. @Override
  3. public void actionPerformed(ActionEvent e) {
  4. JButton btn = (JButton) e.getSource();
  5. System.out.println("clicked column " + btn.getClientProperty("column")
  6. + ", row " + btn.getClientProperty("row"));
  7. }

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

  1. btn.putClientProperty("value", 1);
  2. public void actionPerformed(ActionEvent e) {
  3. Object source = e.getSource();
  4. if (source instanceof JButton) {
  5. JButton btn = (JButton)source;
  6. value = (Integer)btn.getClientProperty("value");

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

  1. public class MyActionListener implements ActionListener {
  2. @Override
  3. public void actionPerformed(ActionEvent e) {
  4. JButton btn = (JButton) e.getSource();
  5. System.out.println("clicked column " + btn.getClientProperty("column")
  6. + ", row " + btn.getClientProperty("row"));
  7. }

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

  1. private static final String EVENT_TYPE = "event_type";
  2. // button creation
  3. normalSetupButton = new JButton();
  4. // set appropriate event for this button
  5. normalSetupButton.putClientProperty(EVENT_TYPE, SimulationEvent.NORMAL_SETUP_EVENT);
  6. // other init button routine
  7. //next button
  8. queenTestButton = new JButton();
  9. queenTestButton.putClientProperty(EVENT_TYPE, SimulationEvent.QUEEN_TEST_EVENT);
  10. // other init button routine
  11. // same way for other buttons
  12. public void actionPerformed(ActionEvent e) {
  13. // get the button that was pressed
  14. JButton b = (JButton) e.getSource();
  15. SimulationEvent evt = (SimulationEvent) b.getClientProperty(EVENT_TYPE);
  16. fireSimulationEvent(evt);
  17. }

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

  1. @Override
  2. public void actionPerformed(ActionEvent e) {
  3. int newState = ((Integer) disclosureButton.getClientProperty(DisclosureIcon.CURRENT_STATE_PROPERTY) + 1) %
  4. (Integer) disclosureButton.getClientProperty(DisclosureIcon.STATE_COUNT_PROPERTY);
  5. setDisclosureState(newState);
  6. }
  7. });

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

  1. JButton j = new JButton("click here");
  2. j.putClientProperty("id", "employee1");
  3. j.addActionListener(new ActionListener() {
  4. @Override
  5. public void actionPerformed(ActionEvent ae) {
  6. JButton source = (JButton)ae.getSource();
  7. String id = (String) source.getClientProperty("id");
  8. System.out.print(id);
  9. }
  10. });

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

  1. @Override
  2. public void actionPerformed(ActionEvent ae) {
  3. if (ae.getSource() instanceof JButton) {
  4. JButton button = (JButton) ae.getSource();
  5. Solution solution = (Solution) button.getClientProperty("Solution"); // NOI18N
  6. solution.resolve().run();
  7. button.setEnabled(false);
  8. }
  9. }
  10. }

代码示例来源:origin: lbalazscs/Pixelitor

  1. /** This takes a set of buttons and gives them all the width/height
  2. * of the largest button among them.
  3. * <P>(More specifically, this sets the <code>preferredSize</code>
  4. * of each button to the largest preferred size in the list of buttons.
  5. *
  6. * @param buttons an array of buttons.
  7. */
  8. public static void normalizeButtons(JButton[] buttons) {
  9. int maxWidth = 0;
  10. int maxHeight = 0;
  11. for(int a = 0; a<buttons.length; a++) {
  12. buttons[a].setPreferredSize(null);
  13. Dimension d = buttons[a].getPreferredSize();
  14. Number n = (Number)buttons[a].getClientProperty( DialogFooter.PROPERTY_OPTION );
  15. if( (n!=null && n.intValue()==DialogFooter.DONT_SAVE_OPTION) ||
  16. d.width>80 ) {
  17. buttons[a] = null;
  18. }
  19. if(buttons[a]!=null) {
  20. maxWidth = Math.max(d.width, maxWidth);
  21. maxHeight = Math.max(d.height, maxHeight);
  22. }
  23. }
  24. for(int a = 0; a<buttons.length; a++) {
  25. if(buttons[a]!=null)
  26. buttons[a].setPreferredSize(new Dimension(maxWidth,maxHeight));
  27. }
  28. }

代码示例来源:origin: lbalazscs/Pixelitor

  1. /** Finds a certain type of button, if it is available.
  2. *
  3. * @param buttonType of the options in this class (such as YES_OPTION or CANCEL_OPTION)
  4. * @return the button that maps to that option, or null if no such button was found.
  5. */
  6. public JButton getButton(int buttonType) {
  7. for(int a = 0; a<getComponentCount(); a++) {
  8. if(getComponent(a) instanceof JButton) {
  9. JButton button = (JButton)getComponent(a);
  10. Object value = button.getClientProperty(PROPERTY_OPTION);
  11. int intValue = -1;
  12. if(value instanceof Number)
  13. intValue = ((Number)value).intValue();
  14. if(intValue==buttonType)
  15. return button;
  16. }
  17. }
  18. return null;
  19. }

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

  1. final Action deleteAction = new AbstractAction("Delete") {
  2. @Override
  3. public void actionPerformed(ActionEvent e) {
  4. JButton button = (JButton)e.getSource();
  5. JTextField textField = (JTextField)button.getClientProperty("AssociatedTextField");
  6. if (textField != null) {
  7. JComponent parentContainer = (JComponent)button.getParent();
  8. parentContainer.remove(button);
  9. parentContainer.remove(textField);
  10. parentContainer.revalidate();
  11. parentContainer.repaint();
  12. SwingUtilities.windowForComponent(parentContainer).pack();
  13. }
  14. }
  15. };

代码示例来源:origin: lbalazscs/Pixelitor

  1. private void setRootPaneContainer(JButton button,RootPaneContainer c) {
  2. RootPaneContainer lastContainer = (RootPaneContainer)button.getClientProperty("bric.footer.rpc");
  3. if(lastContainer==c) return;
  4. if(lastContainer!=null) {
  5. lastContainer.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).remove(escapeKey);
  6. lastContainer.getRootPane().getActionMap().remove(escapeKey);
  7. if(JVM.isMac)
  8. lastContainer.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).remove(commandPeriodKey);
  9. }
  10. if(c!=null) {
  11. c.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(escapeKey, escapeKey);
  12. c.getRootPane().getActionMap().put(escapeKey, new ClickAction(button));
  13. if(JVM.isMac)
  14. c.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(commandPeriodKey, escapeKey);
  15. }
  16. button.putClientProperty("bric.footer.rpc", c);
  17. }

相关文章

JButton类方法