| |

VerySource

 Forgot password?
 Register
Search
View: 736|Reply: 0

app graph in out.Java

[Copy link]

2

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-5-11 21:01:23
| Show all posts |Read mode
import java.awt. *;
import Java.awt.event. *;
import java.swing. *;

public class AppGraphInOut
{
public static void main (String args [])
{
new AppFrame ();
}
}
The
class AppFrame extends JFrame
{
JTextField in = new JTextField (10);
JButton btn = new JButton ("Squaring");
JLabel out = new JLabel ("Label for displaying results");
The
public AppFrame ()
{
setLayout (new FlowLayout ());
getContentPane (). add (in);
getContentPane (). add (btn);
getContentpane (). add (out);
btn.addActionListener (new BtnActionAdapter ());
setSize (400,100);
setDefaultCloseOperatorion (DISPOSE_ON_CLOSE);
setVisible (ture);
}
The
class BtnActionAdapter implements ActionListener
{
public void actionPerformed (ActionEvent e)
{
String s = in.getText ();
double d = Double.parseDouble (s);
double sq = d * d;
The square of out.setText (d + "is:" + sq);
}
}
}
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list