當前位置: 首頁>>代碼示例>>Java>>正文


Java ButtonModel.setPressed方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:22,代碼來源:BasicButtonListener.java

示例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();
        }
    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:23,代碼來源:BasicButtonListener.java

示例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);
        }
    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:22,代碼來源:BasicButtonListener.java

示例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);
    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:14,代碼來源:BasicRootPaneUI.java

示例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);
        }
    }
}
 
開發者ID:nmldiegues,項目名稱:jvm-stm,代碼行數:22,代碼來源:BasicButtonListener.java

示例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();
}
 
開發者ID:metasfresh,項目名稱:metasfresh,代碼行數:9,代碼來源:SwingTerminalButtonWrapper.java

示例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();
}
 
開發者ID:chhh,項目名稱:batmass,代碼行數:12,代碼來源:DnDButton.java


注:本文中的javax.swing.ButtonModel.setPressed方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。