本文整理汇总了Java中javax.swing.ButtonModel.setPressed方法的典型用法代码示例。如果您正苦于以下问题:Java ButtonModel.setPressed方法的具体用法?Java ButtonModel.setPressed怎么用?Java ButtonModel.setPressed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.ButtonModel
的用法示例。
在下文中一共展示了ButtonModel.setPressed方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import javax.swing.ButtonModel; //导入方法依赖的package包/类
/**
* Performs the action.
*/
public void actionPerformed(ActionEvent event)
{
Object cmd = getValue("__command__");
AbstractButton b = (AbstractButton) event.getSource();
ButtonModel m = b.getModel();
if (PRESSED.equals(cmd))
{
m.setArmed(true);
m.setPressed(true);
if (! b.isFocusOwner())
b.requestFocus();
}
else if (RELEASED.equals(cmd))
{
m.setPressed(false);
m.setArmed(false);
}
}
示例2: mousePressed
import javax.swing.ButtonModel; //导入方法依赖的package包/类
/**
* Accept a mouse press event and arm the button.
*
* @param e The mouse press event to accept
*/
public void mousePressed(MouseEvent e)
{
if (e.getSource() instanceof AbstractButton)
{
AbstractButton button = (AbstractButton) e.getSource();
ButtonModel model = button.getModel();
if (SwingUtilities.isLeftMouseButton(e))
{
// It is important that these transitions happen in this order.
model.setArmed(true);
model.setPressed(true);
if (! button.isFocusOwner() && button.isRequestFocusEnabled())
button.requestFocus();
}
}
}
示例3: mouseReleased
import javax.swing.ButtonModel; //导入方法依赖的package包/类
/**
* Accept a mouse release event and set the button's
* "pressed" property to <code>true</code>, if the model
* is armed. If the model is not armed, ignore the event.
*
* @param e The mouse release event to accept
*/
public void mouseReleased(MouseEvent e)
{
if (e.getSource() instanceof AbstractButton)
{
AbstractButton button = (AbstractButton) e.getSource();
ButtonModel model = button.getModel();
if (e.getButton() == MouseEvent.BUTTON1)
{
// It is important that these transitions happen in this order.
model.setPressed(false);
model.setArmed(false);
}
}
}
示例4: actionPerformed
import javax.swing.ButtonModel; //导入方法依赖的package包/类
/**
* Performes the action.
*/
public void actionPerformed(ActionEvent ev)
{
JButton b = rootPane.getDefaultButton();
if (b != null)
{
ButtonModel m = b.getModel();
m.setArmed(true);
m.setPressed(true);
}
}
示例5: mouseReleased
import javax.swing.ButtonModel; //导入方法依赖的package包/类
/**
* Accept a mouse release event and set the button's
* "pressed" property to <code>true</code>, if the model
* is armed. If the model is not armed, ignore the event.
*
* @param e The mouse release event to accept
*/
public void mouseReleased(MouseEvent e)
{
if (e.getSource() instanceof AbstractButton)
{
AbstractButton button = (AbstractButton) e.getSource();
ButtonModel model = button.getModel();
if (e.getButton() == MouseEvent.BUTTON1)
{
// It is important that these transitions happen in this order.
model.setPressed(false);
model.setArmed(false);
}
}
}
示例6: setPressed
import javax.swing.ButtonModel; //导入方法依赖的package包/类
@Override
public void setPressed(final boolean pressed)
{
final AbstractButton buttonSwing = getComponent();
final ButtonModel model = buttonSwing.getModel();
model.setPressed(pressed);
buttonSwing.updateUI();
}
示例7: dragDropEnd
import javax.swing.ButtonModel; //导入方法依赖的package包/类
@Override
public void dragDropEnd(DragSourceDropEvent dsde) {
//when the drag finishes, then repaint the DnDButton
//so it doesn't look like it has still been pressed down
ButtonModel m = DnDButton.this.getModel();
m.setPressed(false);
m.setRollover(false);
m.setSelected(false);
revalidate();
repaint();
}