当前位置: 首页>>代码示例>>Java>>正文


Java JFormattedTextField.requestFocus方法代码示例

本文整理汇总了Java中javax.swing.JFormattedTextField.requestFocus方法的典型用法代码示例。如果您正苦于以下问题:Java JFormattedTextField.requestFocus方法的具体用法?Java JFormattedTextField.requestFocus怎么用?Java JFormattedTextField.requestFocus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JFormattedTextField的用法示例。


在下文中一共展示了JFormattedTextField.requestFocus方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: destacarCampo

import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
private void destacarCampo(JFormattedTextField field) {
  final int timerDelay = 500;
  final int totalTime = 2000;
  
  final int totalCount = totalTime / timerDelay;
  Timer timer = new Timer(timerDelay, new ActionListener(){
    int count = 0;

    public void actionPerformed(ActionEvent evt) {
      if (count % 2 == 0) {
        field.setBorder(new LineBorder(Color.RED, 2, true));
        field.requestFocus();
      } else {
	        field.setBorder(new LineBorder(Color.GRAY, 1, false));
        if (count >= totalCount) { 
          ((Timer)evt.getSource()).stop();
        }
      }
      count++;
    }
  });
  timer.start();
}
 
开发者ID:tglima,项目名称:CRS,代码行数:24,代码来源:ControllerPrincipal.java

示例2: MassValueEntryNode

import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
/**
 * Constructor.
 */
public MassValueEntryNode( final BalanceGameModel balanceGameModel, PCanvas canvas ) {
    this.model = balanceGameModel;
    this.canvas = canvas;

    // Add the textual prompt.
    PText prompt = new PText( BalanceAndTorqueStudyResources.Strings.MASS_EQUALS );
    prompt.setFont( TEXT_FONT );

    // Create the sub-panel that will contain the edit box for entering
    // the numerical value.
    JPanel numericalValueEntryPanel = new JPanel();
    numericalValueEntryPanel.setBackground( BACKGROUND_COLOR );
    numberEntryField = new JFormattedTextField( NumberFormat.getNumberInstance() );
    numberEntryField.setColumns( ANSWER_ENTRY_FIELD_COLUMNS );
    numberEntryField.setFont( TEXT_FONT );
    numberEntryField.setBorder( BorderFactory.createEtchedBorder() );
    numberEntryField.requestFocus();
    numericalValueEntryPanel.add( numberEntryField );

    // Add the units label.
    PText unitsLabel = new PText( BalanceAndTorqueStudyResources.Strings.KG );
    unitsLabel.setFont( TEXT_FONT );

    // Add a handler for the case where the user presses the Enter key.
    numberEntryField.addActionListener( new ActionListener() {
        public void actionPerformed( ActionEvent arg0 ) {
            submitProposedAnswer();
        }
    } );

    // Wrap the value entry panel in a PSwing.
    PSwing valueEntryPSwing = new PSwing( numericalValueEntryPanel );

    // Create the button for checking the answer.
    checkAnswerButton = new TextButtonNode( BalanceAndTorqueStudyResources.Strings.CHECK_ANSWER, new PhetFont( 20 ), Color.YELLOW );

    // Register to send the user's guess when the button is pushed.
    checkAnswerButton.addActionListener( new ActionListener() {
        public void actionPerformed( ActionEvent e ) {
            submitProposedAnswer();
        }
    } );

    // Lay out the node.
    addChild( new ControlPanelNode( new VBox( 10, new HBox( 5, prompt, valueEntryPSwing, unitsLabel ), checkAnswerButton ), BACKGROUND_COLOR ) );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:50,代码来源:MassValueEntryNode.java

示例3: MassValueEntryNode

import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
/**
 * Constructor.
 */
public MassValueEntryNode( final BalanceGameModel balanceGameModel, PCanvas canvas ) {
    this.model = balanceGameModel;
    this.canvas = canvas;

    // Add the textual prompt.
    PText prompt = new PText( BalanceAndTorqueResources.Strings.MASS_EQUALS );
    prompt.setFont( TEXT_FONT );

    // Create the sub-panel that will contain the edit box for entering
    // the numerical value.
    JPanel numericalValueEntryPanel = new JPanel();
    numericalValueEntryPanel.setBackground( BACKGROUND_COLOR );
    numberEntryField = new JFormattedTextField( NumberFormat.getNumberInstance() );
    numberEntryField.setColumns( ANSWER_ENTRY_FIELD_COLUMNS );
    numberEntryField.setFont( TEXT_FONT );
    numberEntryField.setBorder( BorderFactory.createEtchedBorder() );
    numberEntryField.requestFocus();
    numericalValueEntryPanel.add( numberEntryField );

    // Add the units label.
    PText unitsLabel = new PText( BalanceAndTorqueResources.Strings.KG );
    unitsLabel.setFont( TEXT_FONT );

    // Add a handler for the case where the user presses the Enter key.
    numberEntryField.addActionListener( new ActionListener() {
        public void actionPerformed( ActionEvent arg0 ) {
            submitProposedAnswer();
        }
    } );

    // Wrap the value entry panel in a PSwing.
    PSwing valueEntryPSwing = new PSwing( numericalValueEntryPanel );

    // Create the button for checking the answer.
    checkAnswerButton = new TextButtonNode( BalanceAndTorqueResources.Strings.CHECK_ANSWER, new PhetFont( 20 ), Color.YELLOW );

    // Register to send the user's guess when the button is pushed.
    checkAnswerButton.addActionListener( new ActionListener() {
        public void actionPerformed( ActionEvent e ) {
            submitProposedAnswer();
        }
    } );

    // Lay out the node.
    addChild( new ControlPanelNode( new VBox( 10, new HBox( 5, prompt, valueEntryPSwing, unitsLabel ), checkAnswerButton ), BACKGROUND_COLOR ) );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:50,代码来源:MassValueEntryNode.java


注:本文中的javax.swing.JFormattedTextField.requestFocus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。