I am writing the code for a primitive address book for one of my classes, and it is required that we use a class for the address book itself, and then another class for putting in new entries. I understand this, but when I call the class method for entering new contacts, I want to change the GUI. I am using JFrame, and so for my GUI base i am using the contentPane
. In my first class I created my contentPane
with a basic GUI:
public class Address extends JFrame implements ActionListener
{
Container contentPane;
public Address()
{
super();
contentPane = getContentPane();
contentPane.setLayout(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setTitle("Address Book");
setSize(775,775);
setLocation(0,0);
setBackground(Color.BLUE);
}
}
And now in my second class, the input one, I want to clear the contentPane
with contentPane.removeAll()
.
class Entries
{
public void newContact()
{
contentPane.removeAll();
}
}
Unfortunately, nothing in my class Entries is recognizing contentPane
and other variables i am attempting to modify. Is there a special way to name the contentPane
and other variables in class Address so that they are usable in Entries, or do i need to recreate the variable?