Results 1 to 5 of 5
Thread: JAVA
Hybrid View
-
21st October 2007 20:02 #1Registered User
Join Date: Jun:2006
Location: Sofia
Posts: 6
JAVA
JAVA (SDK 6) . , getSource if , . ?
import java.applet.*; //Imports the java.applet class
import java.awt.*; //Imports the java.awt class
import java.awt.event.*; //Imports the event sub class
public class Figures extends Applet implements ActionListener
{
int x,y,height,width;
int sarea;
//int radius;"????
double carea;
final double pi = 3.14;
Label prompt1;
Label prompt2;
Label prompt3;
Label prompt4;
Label prompt5;
TextField xcord;
TextField ycord;
TextField hcord;
TextField wcord;
TextField result;
Button square;
Button circle;
public void init()
{
setSize(400,400);
prompt1 = new Label ("Enter a starting point for x: ");
prompt2 = new Label ("Enter a starting point for y: ");
prompt3 = new Label ("Enter a value for the height: ");
prompt4 = new Label ("Enter a value for the width: ");
prompt5 = new Label ("The area of your figure is: ");
xcord = new TextField(10);
ycord = new TextField(10);
hcord = new TextField(10);
wcord = new TextField(10);
result = new TextField(10);
result.setEditable(false);
square = new Button ("Draw Square");
circle = new Button ("Draw Oval");
add(prompt1);
add(xcord);
add(prompt2);
add(ycord);
add(prompt3);
add(hcord);
add(prompt4);
add(wcord);
add(prompt5);
add(result);
add(square);
add(circle);
xcord.addActionListener(this);
ycord.addActionListener(this);
hcord.addActionListener(this);
wcord.addActionListener(this);
square.addActionListener(this);
square.setMnemonic(KeyEvent.VK_D);
square.setActionCommand("square");
}
public void actionPerformed(ActionEvent ev)
{
x = Integer.parseInt (ev.getActionCommand());
y = Integer.parseInt (ev.getActionCommand());
height = Integer.parseInt (ev.getActionCommand());
width = Integer.parseInt (ev.getActionCommand());
if
-
21st October 2007 22:00 #2
Listener . ...?
: XaMaB; . 0.42
In God we Trust (all others must submit a X.509 certificate). , ()
-
21st October 2007 22:53 #3
, Applet callback actionPerformed(ActionEvent ev) ot ActionListener 1 - .
-
22nd October 2007 17:43 #4
Join Date: Jun:2002
Location: 85435
Posts: 4,619
:
Object source = evt.getSource();
:
if (source == , )
{
, ;
}
, ........ frame . ( actionPerformed() )X570 Aorus Elite || R5 3600x || NH-D14 || 32GB RAM || GTX1070Ti Ultra Silent || PCE-AC56 || 850 EVO+MP510+HDDs || SSR-650RT all in Dark Base 900 || EV2736W || G29 || Obutto Ozone+Sparco R333
-
22nd October 2007 22:37 #5Registered User
Join Date: Jun:2006
Location: Sofia
Posts: 6
, .
if (source == , )
{
, ;
}
public void actionPerformed(ActionEvent evt) ,
a = Integer.parseInt (evt.getActionCommand()); ( , , ) Number Format Exception .




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in