Announcement

Collapse
No announcement yet.

Anfänger aus Berlin

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Anfänger aus Berlin

    Ich benötige wieder mal Hilfe, Meine App Klasse(s. Quelltext 1.) öffnet JWindow Fenster(s. Quelltext 2.) bis da funktioniert alles.
    Ich möchte aber weiter, und ab hier brauche ich Eure Hilfe, das aus Window Klasse eine andere Klasse(zb. Test.class) im Hintergrund geladen wird, danach sollte die Window Klasse geschlossen werden und Test Klasse aktiviert.

    <B>1. App.java </B>

    import java.awt.*;

    public class App {<BR>
    public App() {<BR>
    Window window = new Window();<BR>
    window.setVisible(true); <BR>
    }<BR>

    public static void main(String[] args) <BR>
    { new App(); }<BR>
    }

    <B>2. Window.java</B>

    import java.awt.*; <BR>
    import java.awt.event.*; <BR>
    import javax.swing.*; <BR>

    public class Window extends JWindow {<BR>
    BorderLayout borderLayout1 = new BorderLayout();<BR>
    JPanel jPanel1 = new JPanel();<BR>
    JLabel jLabel1 = new JLabel();<BR>
    JButton jButton1 = new JButton();<BR>
    FlowLayout flowLayout1 = new FlowLayout();<BR>

    <I>//Frame konstruieren</I>
    public Window() {<BR>
    enableEvents(AWTEvent.WINDOW_EVENT_MASK); <BR>
    try<BR>
    { jbInit(); }<BR>
    catch(Exception e) <BR>
    { e.printStackTrace(); }<BR>
    }<BR>

    <I>//Initialisierung der Komponente<I>
    private void jbInit() throws Exception {<BR>
    this.getContentPane().setLayout(borderLayout1); <BR>
    this.setSize(new Dimension(400, 300)); <BR>
    jPanel1.setBorder(BorderFactory.createRaisedBevelB order());<BR>
    jPanel1.setLayout(flowLayout1); <BR>
    jLabel1.setText("LOADING... ");<BR>
    jButton1.setText("Abbrechen");<BR>
    jButton1.addActionListener(new java.awt.event.ActionListener() {<BR>
    public void actionPerformed(ActionEvent e) <BR>
    { jButton1_actionPerformed(e); }<BR>
    });<BR>
    this.getContentPane().add(jPanel1, BorderLayout.CENTER); <BR>
    jPanel1.add(jLabel1, "jLabel1");<BR>
    jPanel1.add(jButton1, null); <BR>
    }<BR>

    <I>//Bei Herunterfahren Programm beenden</I>
    protected void processWindowEvent(WindowEvent e) {<BR>
    super.processWindowEvent(e); <BR>
    if(e.getID() == WindowEvent.WINDOW_CLOSING) <BR>
    { System.exit(0); }<BR>
    }<BR>

    <I>//Fenster(Window) Schliessen</I>
    void jButton1_actionPerformed(ActionEvent e) <BR>
    { System.exit(0); }<BR>
    }<BR>

  • #2
    Habe selber herausgefunde

    Comment

    Working...
    X