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


Java JFormattedTextField.setBorder方法代碼示例

本文整理匯總了Java中javax.swing.JFormattedTextField.setBorder方法的典型用法代碼示例。如果您正苦於以下問題:Java JFormattedTextField.setBorder方法的具體用法?Java JFormattedTextField.setBorder怎麽用?Java JFormattedTextField.setBorder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JFormattedTextField的用法示例。


在下文中一共展示了JFormattedTextField.setBorder方法的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.setBorder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。