S
Sid
Hi All.
To begin with i am pretty new at swing. I have a application wherein
i want to render forms from a MenuBAR, meaning user clicks on Add
record the add form shows up, search.. edit so forth.
What i am doing is i have a single container and in that container i
draw the menubar and set up listeners on the items to render respective
forms. whenever a item is clicked i clear the container and add the
new formpanel.
1. I read that listeners should not be doing too much work as it slows
down the response time, so is there any better way to render these
individual forms.
2. Going with the same design i needed a Scrollpane to my container and
in turn to the forms, I want to add the Scrollpane to all forms so it
makes sense to add it to the container but when i do the forms dont
clear out anymore and the same welcome form is on the screen.
Pseudo code
Class A
{
private container c;
FormInterface formInterface;
Panel panel;
JScrollpane ps;
public A() {
c = getContentPane();
createMenuBar() // heres where the menu comes and action listeners
called.
formInterface = new CompanyInfoForm();
panel = formInterface.renderForm();
ps = new JScrollPane(panel,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
c.add(ps);
}
Sample action listener
public void AddRecordListener()
{
System.out.println("Add record called");
if (panel != null)
{
FormPanel.removeFromParent(panel);
c.remove(ps);
System.out.println("removing panel ...");
}
// Create a new form
formInterface = new RegistrationForm(connection);
panel = formInterface.renderForm();
// Add to Scrollpane
ps.add(panel)
c.add(ps) ;
}
The problem here is w/o the scrollpane i can switch between forms just
fine its only with the pane i cannot render forms, any help/pointers
be greatly appreciated..
Thanks much
Sid.
To begin with i am pretty new at swing. I have a application wherein
i want to render forms from a MenuBAR, meaning user clicks on Add
record the add form shows up, search.. edit so forth.
What i am doing is i have a single container and in that container i
draw the menubar and set up listeners on the items to render respective
forms. whenever a item is clicked i clear the container and add the
new formpanel.
1. I read that listeners should not be doing too much work as it slows
down the response time, so is there any better way to render these
individual forms.
2. Going with the same design i needed a Scrollpane to my container and
in turn to the forms, I want to add the Scrollpane to all forms so it
makes sense to add it to the container but when i do the forms dont
clear out anymore and the same welcome form is on the screen.
Pseudo code
Class A
{
private container c;
FormInterface formInterface;
Panel panel;
JScrollpane ps;
public A() {
c = getContentPane();
createMenuBar() // heres where the menu comes and action listeners
called.
formInterface = new CompanyInfoForm();
panel = formInterface.renderForm();
ps = new JScrollPane(panel,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
c.add(ps);
}
Sample action listener
public void AddRecordListener()
{
System.out.println("Add record called");
if (panel != null)
{
FormPanel.removeFromParent(panel);
c.remove(ps);
System.out.println("removing panel ...");
}
// Create a new form
formInterface = new RegistrationForm(connection);
panel = formInterface.renderForm();
// Add to Scrollpane
ps.add(panel)
c.add(ps) ;
}
The problem here is w/o the scrollpane i can switch between forms just
fine its only with the pane i cannot render forms, any help/pointers
be greatly appreciated..
Thanks much
Sid.