本文整理了Java中javax.swing.JButton.getClientProperty()
方法的一些代码示例,展示了JButton.getClientProperty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JButton.getClientProperty()
方法的具体详情如下:
包路径:javax.swing.JButton
类名称:JButton
方法名:getClientProperty
暂无
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
public int getDisclosureStateCount() {
Integer value = (Integer) disclosureButton.getClientProperty(DisclosureIcon.STATE_COUNT_PROPERTY);
return (value == null) ? 2 : value;
}
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
public int getDisclosureState() {
Integer value = (Integer) disclosureButton.getClientProperty(DisclosureIcon.CURRENT_STATE_PROPERTY);
return (value == null) ? 1 : value;
}
代码示例来源:origin: stackoverflow.com
JButton button = (JButton)e.getSource();
Color color = (Color)button.getClientProperty("color");
panel.setBackground( color );
代码示例来源:origin: stackoverflow.com
JButton button = (JButton) actionEvent.getSource();
Integer firstIndex = button.getClientProperty( "firstIndex" );
Integer secondIndex = button.getClientProperty( "secondIndex" );
代码示例来源:origin: stackoverflow.com
JButton button = ae.getSource();
int value = button.getClientProperty("Which").intValue();
代码示例来源:origin: stackoverflow.com
public class MyActionListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
JButton btn = (JButton) e.getSource();
System.out.println("clicked column " + btn.getClientProperty("column")
+ ", row " + btn.getClientProperty("row"));
}
代码示例来源:origin: Revivius/nb-darcula
public static boolean isSquare(Component c) {
if (c instanceof JButton) {
JButton b = (JButton) c;
return "square".equals(b.getClientProperty("JButton.buttonType"));
}
return false;
}
代码示例来源:origin: stackoverflow.com
public class MyActionListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
JButton btn = (JButton) e.getSource();
System.out.println("clicked column " + btn.getClientProperty("column")
+ ", row " + btn.getClientProperty("row"));
}
代码示例来源:origin: stackoverflow.com
public class MyActionListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
JButton btn = (JButton) e.getSource();
System.out.println("clicked column " + btn.getClientProperty("column")
+ ", row " + btn.getClientProperty("row"));
}
代码示例来源:origin: stackoverflow.com
public class MyActionListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
JButton btn = (JButton) e.getSource();
System.out.println("clicked column " + btn.getClientProperty("column")
+ ", row " + btn.getClientProperty("row"));
}
代码示例来源:origin: stackoverflow.com
btn.putClientProperty("value", 1);
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if (source instanceof JButton) {
JButton btn = (JButton)source;
value = (Integer)btn.getClientProperty("value");
代码示例来源:origin: stackoverflow.com
public class MyActionListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
JButton btn = (JButton) e.getSource();
System.out.println("clicked column " + btn.getClientProperty("column")
+ ", row " + btn.getClientProperty("row"));
}
代码示例来源:origin: stackoverflow.com
private static final String EVENT_TYPE = "event_type";
// button creation
normalSetupButton = new JButton();
// set appropriate event for this button
normalSetupButton.putClientProperty(EVENT_TYPE, SimulationEvent.NORMAL_SETUP_EVENT);
// other init button routine
//next button
queenTestButton = new JButton();
queenTestButton.putClientProperty(EVENT_TYPE, SimulationEvent.QUEEN_TEST_EVENT);
// other init button routine
// same way for other buttons
public void actionPerformed(ActionEvent e) {
// get the button that was pressed
JButton b = (JButton) e.getSource();
SimulationEvent evt = (SimulationEvent) b.getClientProperty(EVENT_TYPE);
fireSimulationEvent(evt);
}
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
@Override
public void actionPerformed(ActionEvent e) {
int newState = ((Integer) disclosureButton.getClientProperty(DisclosureIcon.CURRENT_STATE_PROPERTY) + 1) %
(Integer) disclosureButton.getClientProperty(DisclosureIcon.STATE_COUNT_PROPERTY);
setDisclosureState(newState);
}
});
代码示例来源:origin: stackoverflow.com
JButton j = new JButton("click here");
j.putClientProperty("id", "employee1");
j.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
JButton source = (JButton)ae.getSource();
String id = (String) source.getClientProperty("id");
System.out.print(id);
}
});
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-makeproject
@Override
public void actionPerformed(ActionEvent ae) {
if (ae.getSource() instanceof JButton) {
JButton button = (JButton) ae.getSource();
Solution solution = (Solution) button.getClientProperty("Solution"); // NOI18N
solution.resolve().run();
button.setEnabled(false);
}
}
}
代码示例来源:origin: lbalazscs/Pixelitor
/** This takes a set of buttons and gives them all the width/height
* of the largest button among them.
* <P>(More specifically, this sets the <code>preferredSize</code>
* of each button to the largest preferred size in the list of buttons.
*
* @param buttons an array of buttons.
*/
public static void normalizeButtons(JButton[] buttons) {
int maxWidth = 0;
int maxHeight = 0;
for(int a = 0; a<buttons.length; a++) {
buttons[a].setPreferredSize(null);
Dimension d = buttons[a].getPreferredSize();
Number n = (Number)buttons[a].getClientProperty( DialogFooter.PROPERTY_OPTION );
if( (n!=null && n.intValue()==DialogFooter.DONT_SAVE_OPTION) ||
d.width>80 ) {
buttons[a] = null;
}
if(buttons[a]!=null) {
maxWidth = Math.max(d.width, maxWidth);
maxHeight = Math.max(d.height, maxHeight);
}
}
for(int a = 0; a<buttons.length; a++) {
if(buttons[a]!=null)
buttons[a].setPreferredSize(new Dimension(maxWidth,maxHeight));
}
}
代码示例来源:origin: lbalazscs/Pixelitor
/** Finds a certain type of button, if it is available.
*
* @param buttonType of the options in this class (such as YES_OPTION or CANCEL_OPTION)
* @return the button that maps to that option, or null if no such button was found.
*/
public JButton getButton(int buttonType) {
for(int a = 0; a<getComponentCount(); a++) {
if(getComponent(a) instanceof JButton) {
JButton button = (JButton)getComponent(a);
Object value = button.getClientProperty(PROPERTY_OPTION);
int intValue = -1;
if(value instanceof Number)
intValue = ((Number)value).intValue();
if(intValue==buttonType)
return button;
}
}
return null;
}
代码示例来源:origin: stackoverflow.com
final Action deleteAction = new AbstractAction("Delete") {
@Override
public void actionPerformed(ActionEvent e) {
JButton button = (JButton)e.getSource();
JTextField textField = (JTextField)button.getClientProperty("AssociatedTextField");
if (textField != null) {
JComponent parentContainer = (JComponent)button.getParent();
parentContainer.remove(button);
parentContainer.remove(textField);
parentContainer.revalidate();
parentContainer.repaint();
SwingUtilities.windowForComponent(parentContainer).pack();
}
}
};
代码示例来源:origin: lbalazscs/Pixelitor
private void setRootPaneContainer(JButton button,RootPaneContainer c) {
RootPaneContainer lastContainer = (RootPaneContainer)button.getClientProperty("bric.footer.rpc");
if(lastContainer==c) return;
if(lastContainer!=null) {
lastContainer.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).remove(escapeKey);
lastContainer.getRootPane().getActionMap().remove(escapeKey);
if(JVM.isMac)
lastContainer.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).remove(commandPeriodKey);
}
if(c!=null) {
c.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(escapeKey, escapeKey);
c.getRootPane().getActionMap().put(escapeKey, new ClickAction(button));
if(JVM.isMac)
c.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(commandPeriodKey, escapeKey);
}
button.putClientProperty("bric.footer.rpc", c);
}
内容来源于网络,如有侵权,请联系作者删除!