当前位置: 代码迷 >> J2SE >> 高手请入!有个小有关问题
  详细解决方案

高手请入!有个小有关问题

热度:221   发布时间:2016-04-24 15:20:34.0
高手请入!有个小问题!
[code]
import   javax.swing.*;
import   java.awt.*;
import   java.text.*;
import   java.awt.event.*;
public   class   WageCalculator   extends   JFrame
{
    private   JLabel   hourlyWageJLabel;
    private   JTextField   hourlyWageJTextField;
   
    private   JLabel   hoursWorkedJLabel;
    private   JTextField   hoursWorkedJTextField;
   
    private   JLabel   grossWagesJLabel;
    private   JTextField   grossWagesJTextField;
   
    private   JButton   calculateJButton;
   
    double   hourlyWage;
    double   hoursWorked;
    double   wages;
    final   double   HOUR_LIMIT=40.0;
    DecimalFormat   dollars;
   
    public   WageCalculator()
    {
        createUserInterface();
    }
    public   void   createUserInterface()
    {
        Container   contentPane=this.getContentPane();
        contentPane.setLayout(null);
       
        hourlyWageJLabel=new   JLabel();
        hourlyWageJLabel.setBounds(16,16,90,21);
        hourlyWageJLabel.setText( "Hourly   wage ");
        contentPane.add(hourlyWageJLabel);
       
        hourlyWageJTextField=new   JTextField();
        hourlyWageJTextField.setBounds(115,16,90,21);
        hourlyWageJTextField.setHorizontalAlignment(JTextField.RIGHT);
        contentPane.add(hourlyWageJTextField);
        hourlyWageJTextField.addKeyListener(  
            new   KeyAdapter()
            {
                public   void   keyPressed(KeyEvent   Event)
                {
                    hourlyWageJTextFieldKeyPressed(Event);
                }
            });
       
        hoursWorkedJLabel=new   JLabel();
        hoursWorkedJLabel.setBounds(16,57,90,21);
        hoursWorkedJLabel.setText( "Hours   worked ");
        contentPane.add(hoursWorkedJLabel);
       
        hoursWorkedJTextField=new   JTextField();
        hoursWorkedJTextField.setBounds(115,57,90,21);
        hoursWorkedJTextField.setHorizontalAlignment(JTextField.RIGHT);
        contentPane.add(hoursWorkedJTextField);
        hoursWorkedJTextField.addKeyListener(
            new   KeyAdapter()
            {
                public   void   KeyPressed(KeyEvent   Event)
  相关解决方案