本文整理匯總了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();
}
示例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 ) );
}
示例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 ) );
}