java:143: cannot find symbol

Discussion in 'Java' started by Danny, May 26, 2004.

  1. Danny

    Danny Guest

    Hi,
    I have a problem that about Extend and Inheritance,The following
    variable can not be found (textServername) when the variable in
    "ButtonListener Class" what is my wrong?, please help me .......thx a lot!
    Danny

    ------------------------------------------------------------------------
    import java.awt.*;
    import javax.swing.*;
    import java.io.*;
    import java.util.*;
    import java.lang.*;
    import java.awt.event.*;
    import java.sql.*;

    class MyFrame extends JFrame
    {
    JFrame frame;
    JButton buttonStart;
    JButton buttonExit;
    String userInput;
    String serverName;
    String userName;
    String password;

    public static void main(String args[])
    {
    MyFrame f = new MyFrame();
    }

    public MyFrame()
    {
    super("Window Title");

    JLabel labelSpace;
    JLabel labelTitle;
    JLabel labelServername;
    JLabel labelPortNo;
    JLabel labelUsername;
    JLabel labelPassword;


    BufferedReader bfreader;

    labelSpace = new JLabel(" ");
    labelTitle = new JLabel("Java Reatil System - Server (Version 0.1 -
    Develop)");
    labelServername = new JLabel("MS-SQL Hostname / IP: ");
    labelUsername = new JLabel("Username: ");
    labelPassword = new JLabel("Password: ");

    JTextField textServername;
    JTextField textUsername;
    JPasswordField textPassword;

    textServername = new JTextField(16);
    textUsername = new JTextField(8);
    textPassword = new JPasswordField(8);


    buttonStart= new JButton("Start");
    buttonExit= new JButton("Exit");

    frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(new GridBagLayout());
    GridBagConstraints theGBC=new GridBagConstraints();
    theGBC=new GridBagConstraints();

    theGBC.anchor=GridBagConstraints.NORTHWEST;
    theGBC.gridwidth = 2;
    theGBC.gridx=1;
    theGBC.gridy=0;
    frame.getContentPane().add(labelTitle,theGBC);

    theGBC.anchor=GridBagConstraints.NORTHWEST;
    theGBC.gridwidth = 1;
    theGBC.gridx=1;
    theGBC.gridy=2;
    frame.getContentPane().add(labelServername,theGBC);

    theGBC.anchor=GridBagConstraints.NORTHWEST;
    theGBC.gridwidth = 1;
    theGBC.gridx=2;
    theGBC.gridy=2;
    frame.getContentPane().add(textServername,theGBC);

    theGBC.anchor=GridBagConstraints.NORTHWEST;
    theGBC.gridwidth = 1;
    theGBC.gridx=1;
    theGBC.gridy=3;
    frame.getContentPane().add(labelUsername,theGBC);

    theGBC.anchor=GridBagConstraints.NORTHWEST;
    theGBC.gridwidth = 1;
    theGBC.gridx=2;
    theGBC.gridy=3;
    frame.getContentPane().add(textUsername,theGBC);

    theGBC.anchor=GridBagConstraints.NORTHWEST;
    theGBC.gridwidth = 1;
    theGBC.gridx=1;
    theGBC.gridy=4;
    frame.getContentPane().add(labelPassword,theGBC);

    theGBC.anchor=GridBagConstraints.NORTHWEST;
    theGBC.gridwidth = 1;
    theGBC.gridx=2;
    theGBC.gridy=4;
    frame.getContentPane().add(textPassword,theGBC);

    theGBC.anchor=GridBagConstraints.NORTHWEST;
    theGBC.gridwidth = 1;
    theGBC.gridx=1;
    theGBC.gridy=5;
    frame.getContentPane().add(labelSpace,theGBC);

    theGBC.anchor=GridBagConstraints.NORTHWEST;
    theGBC.gridwidth = 1;
    theGBC.gridx=2;
    theGBC.gridy=5;
    frame.getContentPane().add(labelSpace,theGBC);

    theGBC.anchor=GridBagConstraints.SOUTH;
    theGBC.gridwidth = 1;
    theGBC.gridx=1;
    theGBC.gridy=6;
    frame.getContentPane().add(buttonStart,theGBC);

    theGBC.anchor=GridBagConstraints.SOUTH;
    theGBC.gridwidth = 1;
    theGBC.gridx=2;
    theGBC.gridy=6;
    frame.getContentPane().add(buttonExit,theGBC);

    ButtonListener blisten = new ButtonListener();
    buttonStart.addActionListener(blisten);


    frame.setSize(new Dimension(400,300));
    frame.show();
    }

    class ButtonListener implements ActionListener
    {

    public void actionPerformed(ActionEvent evt)
    {
    JButton source = (JButton)evt.getSource();
    serverName = textServername.getText();
    System.out.println(serverName);
    }

    }
    }
     
    Danny, May 26, 2004
    #1
    1. Advertising

  2. On Wed, 26 May 2004 16:07:49 +0800, Danny wrote:

    > Hi,


    Well.. Hi again!

    Hi, see my answer to the post you
    multi-posted on c.l.j.gui
    <http://www.physci.org/codes/javafaq.jsp#xpost>
     
    Andrew Thompson, May 26, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Taria
    Replies:
    14
    Views:
    1,683
    Taria
    Oct 2, 2007
  2. nalbertini

    Java - cannot find symbol

    nalbertini, Feb 12, 2011, in forum: Java
    Replies:
    1
    Views:
    787
    nalbertini
    Feb 12, 2011
  3. Ruby Quiz
    Replies:
    3
    Views:
    135
    Jesús Gabriel y Galán
    Oct 16, 2007
  4. Ruby Quiz
    Replies:
    0
    Views:
    113
    Ruby Quiz
    Oct 18, 2007
  5. Replies:
    6
    Views:
    1,817
Loading...

Share This Page