Moin,
ich hab das Problem, dass sich beim Start meines Programmes kein Fester öffnet so wie es eigentlich sein sollte. Es gibt keine Fehlermeldung und das Programm ist am laufen. nur sehe ich nichts. Das Fenster habe ich in Eclipse mit dem WindowBuilder erstellt.
Hier der Code:
Weiß einfach nicht woran es liegt. Vielen Dank bei möglicher Hilfe.
ich hab das Problem, dass sich beim Start meines Programmes kein Fester öffnet so wie es eigentlich sein sollte. Es gibt keine Fehlermeldung und das Programm ist am laufen. nur sehe ich nichts. Das Fenster habe ich in Eclipse mit dem WindowBuilder erstellt.
Hier der Code:
Java:
/*
* created 05.02.2019
*/
package Gui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import Roboter.*;
import System.*;
/**
* @author *****
*
*/
public class Labyrinth implements ActionListener {
private JFrame frmDasLabyrinth;
private JButton btnStart;
private JButton btnAbbruch;
private static int breite = 800;
private static int hoehe = 400;
// private static int breite = Dialog.getBreite();
// private static int hoehe = Dialog.getHoehe();
// private int wandwa = Dialog.getWandwa();
// private int anima = Dialog.getAnima();
static int feldb = (1020 / breite);
static int feldh = (530 / hoehe);
static int feldim = Math.round((feldb + feldh) / 2 * 10) / 10;
int array1 = 1020 / feldim;
int array2 = 530 / feldim;
JMenuItem roboR = new JMenuItem("RechtsRoboter hinzufügen");
JMenuItem roboL = new JMenuItem("LinksRoboter hinzufügen");
JMenuItem roboZ = new JMenuItem("ZufallRoboter hinzufügen");
public static int getFeldim() {
return feldim;
}
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
try {
Labyrinth window = new Labyrinth();
window.frmDasLabyrinth.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public Labyrinth() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frmDasLabyrinth = new JFrame();
frmDasLabyrinth.setResizable(false);
frmDasLabyrinth.getContentPane().setBackground(Color.WHITE);
frmDasLabyrinth.setTitle("Das Labyrinth");
frmDasLabyrinth.setBounds(100, 100, 1120, 630);
frmDasLabyrinth.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmDasLabyrinth.getContentPane().setLayout(null);
JPanel panel = new JPanel();
panel.setBackground(Color.WHITE);
panel.getBorder();
panel.setBounds(10, 20, 950, 560);
frmDasLabyrinth.getContentPane().add(panel);
panel.setLayout(null);
Himm[][] wand = new Himm[array1][array2];
for( int j = 20 - feldim;j<hoehe;) { // durchlaufen der spalten
j = +feldim;
for (int k = 10 - feldim; k < breite;) { // durchlaufen der zeilen
k = +feldim;
wand[k][j] = new Himm(k, j);
}
}
panel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isLeftMouseButton(e)) {
Point po = panel.getLocationOnScreen();
for (int j = 20 - feldim; j < hoehe;) { // durchlaufen der spalten
j = +feldim;
for (int k = 10 - feldim; k < breite;) { // durchlaufen der zeilen
k = +feldim;
if (po.x >= j && po.x < j + feldim) {
po.x = j;
}
if (po.y >= k && po.y < k + feldim) {
po.y = k;
}
}
}
StandartRoboter a = new StandartRoboter(po);
} else if (SwingUtilities.isRightMouseButton(e)) {
Point po = panel.getLocationOnScreen();
for (int j = 20 - feldim; j < hoehe;) { // durchlaufen der spalten
j = +feldim;
for (int k = 10 - feldim; k < breite;) { // durchlaufen der zeilen
k = +feldim;
if (po.x >= j && po.x < j + feldim) {
po.x = j;
}
if (po.y >= k && po.y < k + feldim) {
po.y = k;
}
}
}
JPopupMenu pop = new JPopupMenu();
pop.setLocation((int) po.getX(), (int) po.getY());
pop.add(roboR);
roboR.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
RechtsRoboter a = new RechtsRoboter(po);
}});
pop.add(roboL);
roboL.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
LinksRoboter a = new LinksRoboter(po);
}});
pop.add(roboZ);
roboZ.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ZufallsRoboter a = new ZufallsRoboter(po);
}});
}
}
});
btnStart = new JButton("Start");
btnStart.setBounds(991, 37, 89, 23);
frmDasLabyrinth.getContentPane().add(btnStart);
btnStart.addActionListener(this);
btnAbbruch = new JButton("Abbruch");
btnAbbruch.setBounds(991, 83, 89, 23);
frmDasLabyrinth.getContentPane().add(btnAbbruch);
btnAbbruch.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource().equals(btnAbbruch)) {
frmDasLabyrinth.setVisible(false);
new Dialog();
}
if (e.getSource().equals(btnStart)) {
}
}
}
Weiß einfach nicht woran es liegt. Vielen Dank bei möglicher Hilfe.