Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling a class

 
Ariane Bogain
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a password box that will be linked to a database. Once the users enter their password they will have another panel where they can register their hobbies. It is not for the net but simply on JBuilder for the moment. I had no problem setting up the GUI for both the password and the other panel (the database link will be for later!) but as I'm a very novice programmer I don't know how to link the two so that on a user's screen there is a smooth transition between the password and the hobby panel. The password class looks like this:
import java.awt.*;
import java.awt.event.*;
class Staffpass extends Panel implements ActionListener {
private TextField name=new TextField(20);
private TextField pass=new TextField(20);

private Button submit=new Button("submit");
private Label instruction=new Label ("please enter your name and password");
public void setEchoChar(char c)
{pass.setEchoChar('#');
}
public Staffpass()
{
add(name);
add(pass);
pass.setEchoChar('#');
add(instruction);
add(submit);
submit.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == submit)
{???
}
}
}
the ??? refers to my question, how do I then invoke my hobby class so that its GUI appears instead of the password GUI?
Thank you very much!
 
Francis Siu
Ranch Hand
Posts: 867
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Ariane
humm...
(1)Your hobby class had created or
(2)you want in the actionPerform method to create the hobby class.
It is because the coding is differ when you have different design
Which type is the hobby class?(Jpanel,JFrame,or..)
And one more question is that you want to show the hobby class only?
Please reply which situation you do
 
Ariane Bogain
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Siu,
Yes my question wasn't very clear! I manage to sort it out by creating an instance of the hobby class and then calling its methods.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic