Board index » jbuilder » Problem with changing panels

Problem with changing panels


2004-05-22 03:22:36 AM
jbuilder23
Hey
i m new on java. i build 2 panels with jbuilder and try to swap them
within my applet. after i changed the first to invisibly and try to
start the second my screen keeps blank in my browser - within jbuilder
it works...
cound anybody tell me what i have to do with the panels, with switch i
have to take and what i have to do to repaint my screen in the browser
(ns and ie).
thanks
Antagor
 
 

Re:Problem with changing panels

hey,
let me add a simple codesample to show what my problem is
after a klick on the ok-botton the screen of the applet went grey in the
browser, in jbuilder it works fine.
can anybody help me?
thanks
package panel;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class panelapplet extends Applet {
private boolean isStandalone = false;
Panel panel1 = new Panel();
Button button1 = new Button();
Label label1 = new Label();
BorderLayout borderLayout1 = new BorderLayout();
BorderLayout borderLayout2 = new BorderLayout();
Panel panel2 = new Panel();
Label label2 = new Label();
Button button2 = new Button();
//Parameterwert holen
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
// Das Applet konstruieren
// public panelapplet() {
// try {
// jbInit1();
// }
// catch(Exception e) {
// e.printStackTrace();
// }
// }
//Das Applet initialisieren
public void init() {
try {
jbInit1();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Initialisierung der Komponenten
private void jbInit1() throws Exception {
button1.setLabel("OK");
button1.addActionListener(new panelapplet_button1_actionAdapter(this));
label1.setText("Hallo");
this.setLayout(borderLayout1);
this.add(panel1, BorderLayout.CENTER);
panel1.add(label1, null);
panel1.add(button1, null);
}
//Das Applet starten
public void start() {
}
//Das Applet anhalten
public void stop() {
}
//Das Applet löschen
public void destroy() {
}
//Applet-Information holen
public String getAppletInfo() {
return "Applet-Information";
}
//Parameter-Infos holen
public String[][] getParameterInfo() {
return null;
}
private void jbInit2() throws Exception {
this.setLayout(borderLayout2);
label2.setText("2. Seite");
label2.setBounds(new Rectangle(131, 185, 36, 15));
button2.setLabel("OK");
button2.setBounds(new Rectangle(235, 183, 47, 23));
panel2.setLayout(null);
this.add(panel2, BorderLayout.CENTER);
panel2.add(label2, null);
panel2.add(button2, null);
}
void button1_actionPerformed(ActionEvent e) {
panel1.setVisible(false);
panel1.setEnabled(false);
repaint();
this.removeAll();
repaint();
try {
jbInit2();
}
catch(Exception e2) {
e2.printStackTrace();
}
}
}
class panelapplet_button1_actionAdapter implements
java.awt.event.ActionListener {
panelapplet adaptee;
panelapplet_button1_actionAdapter(panelapplet adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.button1_actionPerformed(e);
}
}