Forum Sementara Putera.com

Would you like to react to this message? Create an account in a few clicks or log in to continue.
Forum Sementara Putera.com

Bersama kita perkemaskan forum ini sementara forum asal dalam pemulihan.

Forum putera dah kembali. Masalah sudah berjaya diselesaikan. Sila lawati http://forum.putera.com/tanya


2 posters

    minta bantuan :: wat coding event tp error

    avatar
    wawa_dee
    Ahli Baharu
    Ahli Baharu


    Number of posts : 3
    Registration date : 12/08/2009

    minta bantuan :: wat coding event tp error Empty minta bantuan :: wat coding event tp error

    Post by wawa_dee Sat Oct 17, 2009 9:41 pm

    error "cannot find simbol method parseInt();
    biasanya dlm application boleh guna, tukar kepada double pun xjadi gak..
    minta tolong yer...

    import java.awt.*;
    import java.awt.event.*;
    import java.applet.Applet;
    import javax.swing.*;

    public class GUI2 extends JApplet implements ActionListener
    {

    private JTextField xfield,yfield,answer;
    private JLabel x,y,nilai;
    private JPanel area1;
    private int j=0, k=0;
    String xS,yS;

    public void init()
    {
    Container pane=getContentPane();//create workspace
    pane.setBackground(Color.white);//set workspace background color
    pane.setLayout(new BorderLayout());//set layout ti border layout

    area1=new JPanel();//create new panel
    area1.setLayout(new GridLayout(3,2));//set gridlayout in panel

    x=new JLabel("Masukkan Integer 1 : ");//create label
    area1.add(x);//add label in panel
    xfield=new JTextField(5);//create text field
    area1.add(xfield);//add text field in panel

    y=new JLabel("Masukkan Integer 2 : ");
    area1.add(y);
    yfield=new JTextField(5);
    area1.add(yfield);

    nilai=new JLabel("Hasil Tambah Integer : ");
    area1.add(nilai);
    answer=new JTextField("0",SwingConstants.CENTER);//create label & set it to center
    answer.addActionListener(this);
    area1.add(answer);

    pane.add(area1, "Center");//add panel in workspace
    }

    public void actionPerformed(ActionEvent e)
    {
    int j=0,k=0;

    String xS=xfield.getText();
    j=Integer.parseInt();

    String yS=yfield.getText();
    k=Integer.parseInt();

    int ans=j+k;

    answer.setText(answer.getText() +ans); scratch
    avatar
    apis_ff
    Ahli Baharu
    Ahli Baharu


    Gender : Male Number of posts : 16
    Location : Ipoh
    Registration date : 22/03/2009

    minta bantuan :: wat coding event tp error Empty Re: minta bantuan :: wat coding event tp error

    Post by apis_ff Mon Oct 19, 2009 8:04 pm

    method Integer.parseInt() tu bukan ke dalam package IO? jadi kena tambah command import java.io.*; kat bahagian import package atas sekali.. try la.

      Current date/time is Mon Nov 18, 2024 8:28 am