Hi, eine Frage, in meinem folgendem Code habe ich einen Button erstellt, der, wenn man diesen drückt, sich selbst zerstört(siehe Zeile 23) und dann viele andere Dinge an das JFrame added, in dem er drin ist,
aber wenn ich auf ihn klicke, geht der Button nicht weg, und das frame wird transparent, und nichts funktioniert mehr, wieso?
Woran könnte ich arbeiten, was mache ich falsch?
aber wenn ich auf ihn klicke, geht der Button nicht weg, und das frame wird transparent, und nichts funktioniert mehr, wieso?
Woran könnte ich arbeiten, was mache ich falsch?
Java:
public class Konfig extends JFrame
{
public Konfig()
{
Toolkit tk = null;
final Dimension d = tk.getDefaultToolkit().getScreenSize();
setSize(d);
setTitle("R.a.t.r.o.t.c.p.");
setUndecorated(true);
setVisible(true);
setIconImage(new ImageIcon("F:/Rayman/Icon.jpg").getImage());
setLayout(null);
Cursor cur = getToolkit().createCustomCursor(new ImageIcon( "F:/Cursor.gif" ).getImage(),new Point(0,5), "Cursor" );
setCursor( cur );
///////
final JButton bu = new JButton("Bestätigen");
bu.setBounds(0,0,200,20);add(bu);
bu.addActionListener( new ActionListener()
{public void actionPerformed(ActionEvent evt) {b1ActionPerformed(evt);}private void b1ActionPerformed(ActionEvent evt)
{
remove(bu);
GraphicsConfiguration config111 = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas2 = new Canvas3D(config111);
canvas2.setBounds(d.width/4,1,d.width/3+d.width/3+d.width/3,d.height);
SimpleUniverse u = new SimpleUniverse(canvas2);
u.addBranchGraph(createSceneGraph());
add(canvas2);
///////
JLabel l = new JLabel("...Konfiguriere...");
l.setForeground(Color.black);l.setBounds(0,0,200,20);add(l);
JProgressBar a = new JProgressBar();a.setBackground(Color.gray); a.setForeground(Color.yellow);
a.setBounds(40,40,d.width/4,20);add(a);
JProgressBar b = new JProgressBar();b.setBackground(Color.gray); b.setForeground(Color.orange);
b.setBounds(40,80,d.width/4,20);add(b);
JProgressBar c = new JProgressBar();c.setBackground(Color.gray); c.setForeground(Color.red);
c.setBounds(40,120,d.width/4,20);add(c);
JProgressBar de = new JProgressBar();de.setBackground(Color.gray); de.setForeground(Color.green);
de.setBounds(40,160,d.width/4,20);add(de);
JProgressBar e = new JProgressBar();e.setBackground(Color.gray); e.setForeground(Color.blue);
e.setBounds(40,200,d.width/4,20);add(e);
JProgressBar f = new JProgressBar();f.setBackground(Color.gray); f.setForeground(Color.black);
f.setBounds(40,240,d.width/4,20);add(f);
//
warte(250);
a.setValue(10);
warte(250);
a.setValue(20);
warte(250);
a.setValue(30);
warte(250);
a.setValue(40);
warte(250);
a.setValue(50);
warte(250);
a.setValue(60);
warte(250);
a.setValue(70);
warte(250);
a.setValue(80);
warte(250);
a.setValue(90);
warte(250);
a.setValue(100);
//
warte(250);
b.setValue(10);
warte(250);
b.setValue(20);
warte(250);
b.setValue(30);
warte(250);
b.setValue(40);
warte(250);
b.setValue(50);
warte(250);
b.setValue(60);
warte(250);
b.setValue(70);
warte(250);
b.setValue(80);
warte(250);
b.setValue(90);
warte(250);
b.setValue(100);
//
warte(1000);
JLabel l2 = new JLabel();
l2.setText("Konfiguration beendet.");add(l2); l2.setBounds(0,d.height-d.height/4,200,20);
JButton but = new JButton("Fortfahren -->>");
but.setText("Forfahren -->>");
add(but);but.setBounds(0,d.height-40,d.width/4,20);add(but);
add(but);
but.addActionListener( new ActionListener()
{public void actionPerformed(ActionEvent evt) {b1ActionPerformed(evt);}private void b1ActionPerformed(ActionEvent evt)
{
//tu was
}});
}});
}
public static void warte(long millis){try{Thread.sleep(millis);}catch(InterruptedException e){}}
public static void main(String[]args)
{
new Konfig();
}
}
Zuletzt bearbeitet: