Results 1 to 5 of 5

Thread: JAVA

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered 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

  2. #2
    XaMaB's Avatar
    Join Date: Nov:2001
    Location:
    Posts: 20,387
    Listener . ...?
    : XaMaB; . 0.42

    In God we Trust (all others must submit a X.509 certificate). , ()

  3. #3
    Registered User Annihilator's Avatar
    Join Date: Jun:2004
    Location: Sofia
    Posts: 1,316
    , Applet callback actionPerformed(ActionEvent ev) ot ActionListener 1 - .

  4. #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

  5. #5
    Registered User
    Join Date: Jun:2006
    Location: Sofia
    Posts: 6
    , .


    if (source == , )
    {
    , ;
    }


    public void actionPerformed(ActionEvent evt) ,
    a = Integer.parseInt (evt.getActionCommand()); ( , , ) Number Format Exception .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |