Mehrere Klassen verbinden?

also wie gesagt es sind halt 2 Programme

Splashscreen:

Code:
import javax.swing.*;  
import javax.swing.border.*;  
import java.awt.*;  
import java.awt.event.*;    

public class SplashScreen  
extends JWindow  
{
    public SplashScreen(String image, String text)
    {      JPanel contentPane = new JPanel(); 
           ContentPane.setLayout(new BorderLayout());        
           
           Border bd1 = BorderFactory.createBevelBorder( BevelBorder.RAISED      );
     Border bd2 = BorderFactory.createEtchedBorder();
     Border bd3 = BorderFactory.

     createCompoundBorder(bd1, bd2);
      ((JPanel)contentPane).
      setBorder(bd3);      
    ImageIcon icon = new ImageIcon(image);      
    contentPane.add("North",  new JLabel(" ", JLabel.CENTER));      
    contentPane.add("Center", new JLabel(icon, JLabel.CENTER));      
    contentPane.add("South",  new JLabel(text, JLabel.CENTER));      
    setContentPane(contentPane);     }      

public void showFor(int millis)   
 {
      Dimension dim = Toolkit.getDefaultToolkit().
      getScreenSize();
      setLocation(dim.width / 4, dim.height / 4);      
      setSize(dim.width / 2, dim.height / 2);
      setVisible(true);
      try {        Thread.sleep(millis);      } catch (InterruptedException e) {      }
      setVisible(false);    }
      public static void main(String[] args)    {      
      SplashScreen intro = new SplashScreen(        
          "Bra01.JPG",
         "Photoviewer"      );
         intro.showFor(5000);      System.exit(0);    }  }


Beispielprogramm:

Code:
import javax.swing.*;  
import javax.swing.border.*;  
import java.awt.*;  
import java.awt.event.*;      

public class MouseMotionEvents
  extends Frame
  {
          public static void main(String[] args)    {      
         MouseMotionEvents wnd = new MouseMotionEvents();
      wnd.setLocation(200,200);
      wnd.setSize(400,300);
      wnd.setVisible(true);
    }
      public MouseMotionEvents()
    {
      super("Rechteck zeichnen");      
      addWindowListener(new MyWindowListener());      
      addMouseListener(new MyMouseListener());    }      

      class MyMouseListener
         extends MouseAdapter
           {
              public void mousePressed(MouseEvent event)                {
              Graphics g = getGraphics();
               int x = event.getX();
               int y = event.getY(); 
                g.drawRect(x,y,200,100); 
                }
      }
      class MyWindowListener
       extends WindowAdapter
        {
          public void windowClosing(WindowEvent event)              {
              setVisible(false);
              dispose();
              System.exit(0);
           }
     }
  }

danke :)

ps: ganz schön aufwendig den Code hier leserlich darzustellen, hoffe man kann es einigermaßen gut lesen.
 
Tach,
das hier:
Code:
public static void main(String[] args)
{ 
      SplashScreen intro = new SplashScreen(        
          "Bra01.JPG",
         "Photoviewer"      );
intro.showFor(5000);
System.exit(0);
}

sollte an der Stelle aufgerufen werden, wo der SplashScreen angezeigt werden soll. Also nur der Inhalt:
Code:
SplashScreen intro = new SplashScreen( "Bra01.JPG","Photoviewer");
intro.showFor(5000);
System.exit(0);

Die public static void main aus SplashScreen kannst Du dann entfernen.
 
danke für den Hinweis, hat geklappt. hab es dann einfach da rein getan:

Code:
  public static void main(String[] args)
    {
      SplashScreen intro = new SplashScreen(
      "Bra01.JPG",
      "Photoviewer");
      intro.showFor(5000);
      MouseMotionEvents wnd = new MouseMotionEvents();
      wnd.setLocation(200,200);
      wnd.setSize(400,300);
      wnd.setVisible(true);
    }

an solchen Kleinigkeiten hänge ich oft Stunden, aber nun habe ich zum Glück das Forum gefunden wo einem auch sofort geholfen wird :) weiter so!
 
Zurück