Home > Back-end >  Why is The a type must implement The inherited abstract method CaretLi
Why is The a type must implement The inherited abstract method CaretLi

Time:10-27

//amount of Chinese capital form 
Package GUI;
Import the Java. The awt. *;
Import the Java. The awt. Event. KeyEvent;

The import javax.mail. Swing. *;
The import javax.mail. Swing. Event. *;

Public class MoneyJFrame extends JFrame implements CaretListener
{
Private JTextField text_money text_str;
Private MessageJDialog jdialog;

Public MoneyJFrame ()
{
Super (" amount of Chinese capital form ");
Enclosing setBounds (300240360, living);
Enclosing setResizable (false);
Enclosing setBackground (Java awt. Color. LightGray);
Enclosing setDefaultCloseOperation (EXIT_ON_CLOSE);
Enclosing getContentPane (). SetLayout (new FlowLayout (FlowLayout. RIGHT));

Enclosing getContentPane (). The add (new Label (" value "));
Text_money=new JTextField (" 12345678.90 ", 22);
Enclosing getContentPane (). The add (text_money);
Text_money. AddCaretListener (this);

Enclosing getContentPane (). The add (new Label (" Chinese uppercase "));
Text_str=new JTextField (22);
Text_str. SetHorizontalAlignment (JTextField. RIGHT);
Text_str. SetEditable (false);
Enclosing getContentPane (). The add (text_str);
CaretUpdate (null);
Enclosing setVisible (true);
Jdialog=new MessageJDialog ();

}

Private class MessageJDialog extends JDialog
{
/* *
*
*/
private static final long serialVersionUID=1L;
Private JLabel JLabel;
Public MessageJDialog ()
{
Super (MoneyJFrame. This, "tip", true);
Enclosing setSize (300);;
Jlabel=new jlabel (" ", jlabel. CENTER);
Enclosing getContentPane (). The add (jlabel);
Enclosing setDefaultCloseOperation (HIDE_ON_CLOSE);
}

Private void show (String message)
{
Jlabel. SetText (message);
Enclosing setLocation (MoneyJFrame. Enclosing getX () + 100, MoneyJFrame. Enclosing getY () + 100);
Enclosing setVisible (true);
}
}

Public void caretUpade CaretEvent (ev)
{
Try
{
Double x=double. ParseDouble (text_money getText ());
Text_str. SetText (RMBtoString (x));
}
The catch (a NumberFormatException nfex)
{
Jdialog. Show (" \ "" + text_money. GetText () +" \ "can't convert ChengFu TV, please input again!" );
}
The finally {}
}

Public static String RMBtoString (double x)
{
String yuan="0.1 billion ten 10000 ten yuan Angle points".
String digit="zero remark 3 boss wu lu and pure nine";
The String result="";
Int y=(int) (x * 100);
For (int I=yuan. The length () - 1; Y> 0 & amp; & i> 0; I -- y/=100)
Result="" + digit. CharAt (10) y % + yuan. The charAt (I) + result;
return result;
}
Public static void main (String [] args)
{
New MoneyJFrame ();
}
}

CodePudding user response:

The mouse didn't put up with prompt implementation method???????

CodePudding user response:

You realized CaretListener interface, but you didn't realize the inside of the caretUpdate abstract method, so the error,

CodePudding user response:

The
refer to the original poster Liang Liang deleterious response:
/
/amount of Chinese capital formPackage GUI;
Import the Java. The awt. *;
Import the Java. The awt. Event. KeyEvent;

The import javax.mail. Swing. *;
The import javax.mail. Swing. Event. *;

Public class MoneyJFrame extends JFrame implements CaretListener
{
Private JTextField text_money text_str;
Private MessageJDialog jdialog;

Public MoneyJFrame ()
{
Super (" amount of Chinese capital form ");
Enclosing setBounds (300240360, living);
Enclosing setResizable (false);
Enclosing setBackground (Java awt. Color. LightGray);
Enclosing setDefaultCloseOperation (EXIT_ON_CLOSE);
Enclosing getContentPane (). SetLayout (new FlowLayout (FlowLayout. RIGHT));

Enclosing getContentPane (). The add (new Label (" value "));
Text_money=new JTextField (" 12345678.90 ", 22);
Enclosing getContentPane (). The add (text_money);
Text_money. AddCaretListener (this);

Enclosing getContentPane (). The add (new Label (" Chinese uppercase "));
Text_str=new JTextField (22);
Text_str. SetHorizontalAlignment (JTextField. RIGHT);
Text_str. SetEditable (false);
Enclosing getContentPane (). The add (text_str);
CaretUpdate (null);
Enclosing setVisible (true);
Jdialog=new MessageJDialog ();

}

Private class MessageJDialog extends JDialog
{
/* *
*
*/
private static final long serialVersionUID=1L;
Private JLabel JLabel;
Public MessageJDialog ()
{
Super (MoneyJFrame. This, "tip", true);
Enclosing setSize (300);;
Jlabel=new jlabel (" ", jlabel. CENTER);
Enclosing getContentPane (). The add (jlabel);
Enclosing setDefaultCloseOperation (HIDE_ON_CLOSE);
}

Private void show (String message)
{
Jlabel. SetText (message);
Enclosing setLocation (MoneyJFrame. Enclosing getX () + 100, MoneyJFrame. Enclosing getY () + 100);
Enclosing setVisible (true);
}
}

Public void caretUpade CaretEvent (ev)
{
Try
{
Double x=double. ParseDouble (text_money getText ());
Text_str. SetText (RMBtoString (x));
}
The catch (a NumberFormatException nfex)
{
Jdialog. Show (" \ "" + text_money. GetText () +" \ "can't convert ChengFu TV, please input again!" );
}
The finally {}
}

Public static String RMBtoString (double x)
{
String yuan="0.1 billion ten 10000 ten yuan Angle points".
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related