Hallo, ich bin gerade dabei einen kleinen Launcher für mein Programm zu schreiben, doch leider wird nichts angezeigt, nur die Hintergrundfarbe des JPanels.
Ich verwende Java 1.7 und Eclipse.
Hier ist ein Teil meines Codes. Diese Methode wird über eine andere Klasse aufgerufen und dies funktioniert auch soweit, nur leider wird danach nur noch das JFrame mit Titel, Icon usw. angezeigt aber nicht der Inhalt. Dort wird nur die Hintergrundfarbe angezeigt und auch ohne diese wird nichts angezeigt.
Code:
Den einzigen Fehler den ich bekomme ist dieser hier:
Dieser Fehler wird nur beim Start des Programms angezeigt und auch nur so kurz, das ich nichts lesen kann. Ich kann nur kurz einen roten Text in der Console aufblinken sehen und dann ist dieser wieder weg und das Programm wird angezeigt. (Dieser Fehler wird nur unter den Breakpoints im Debug Mode angezeigt (da wird nur das hier angezeigt: "ArrayIndexOutOfBoundsException: caught and uncaught" und davor ein Kästchen mit Haken drin, mehr nicht.)
Ich hoffe ihr könnt mir hierbei helfen.
JavaGamer
Ich verwende Java 1.7 und Eclipse.
Hier ist ein Teil meines Codes. Diese Methode wird über eine andere Klasse aufgerufen und dies funktioniert auch soweit, nur leider wird danach nur noch das JFrame mit Titel, Icon usw. angezeigt aber nicht der Inhalt. Dort wird nur die Hintergrundfarbe angezeigt und auch ohne diese wird nichts angezeigt.
Code:
Java:
// creates the layout with boxes
private Box options, menue, packs, info, play;
//private static int widthSize = width * scale;
//private static int heightSize = height * scale;
public Launcher()
{
super();
// creates the icon Image and the resource path
ImageIcon icon = null;
try
{
icon = new ImageIcon(getClass().getResource("SLE.png"));
}
catch (Exception e)
{
JOptionPane.showMessageDialog(null, e, "Error", JOptionPane.ERROR_MESSAGE);
}
//Image icon = Toolkit.getDefaultToolkit().getImage("resources/textures/SLE.png");
// creates the new window
JFrame frames = new JFrame();
// sets the title of the window
frames.setTitle(Launcher.title + versions);
// creates the JPanel (the basics for the graphical interface)
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
// sets the Icon for the window
System.out.println(icon.getClass().getName());
frames.setIconImage(icon.getImage());
// removes the windows minimize, maximize and close operation
//frames.setUndecorated(true);
// sets the size of the window
frames.setSize(868, 568);
// sets the default close operation of the window
frames.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frames.setLocationRelativeTo(null);
// sets the layout for the window
frames.setLayout(new BorderLayout());
// sets the background color of the window
//frames.getContentPane().setBackground(Color.DARK_GRAY);
// adds the boxes to the window
options = Box.createHorizontalBox();
menue = Box.createHorizontalBox();
packs = Box.createVerticalBox();
info = Box.createVerticalBox();
play = Box.createHorizontalBox();
// adds everything to the JPanel
panel.add(options, BorderLayout.NORTH);
panel.add(menue, BorderLayout.AFTER_LINE_ENDS);
panel.add(packs, BorderLayout.EAST);
panel.add(info, BorderLayout.WEST);
panel.add(play, BorderLayout.SOUTH);
panel.validate();
// sets the background color of the graphical interface
panel.setBackground(Color.DARK_GRAY);
// adds the JPanel to the JFrame
//frames.getContentPane().add(panel);
frames.setContentPane(panel);
// the window will set the size to the size of all components, so that everything
// is visible in the window
/**frames.pack();*/
// sets the postion from the window (same as frames.setLocation(500, 500); )
frames.setLocationRelativeTo(null);
// if this is "true", then the window is visible
// if not, then the window is invisible
frames.setVisible(true);
}
Code:
ArrayIndexOutOfBoundsException: caught and uncaught
Ich hoffe ihr könnt mir hierbei helfen.
JavaGamer
Zuletzt bearbeitet: