java:143: cannot find symbol

D

Danny

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);
}

}
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top