Hallo,
zu aller erst : Ich bin kein Profi.
Habe mit Eclipse und dem Plugin WindowBuilder (bitte nicht schimpfen) ein Design gebaut.
Das wird mir auch Prima in diesen Testfenster angezeigt, aber wenn ich das Applet compiliere zeigt er mir das Jpanel komplett leer an.
Hier der code: (Viele Imports sind überflüssig)
Ich bin mir sicher, dass jemand, der sich mit Applets auskennt sofort den Fehler sieht. Aber mir bleibt das Licht der Erkenntnis seit 2 Tagen aus.
lG
zu aller erst : Ich bin kein Profi.
Habe mit Eclipse und dem Plugin WindowBuilder (bitte nicht schimpfen) ein Design gebaut.
Das wird mir auch Prima in diesen Testfenster angezeigt, aber wenn ich das Applet compiliere zeigt er mir das Jpanel komplett leer an.
Hier der code: (Viele Imports sind überflüssig)
Java:
package HSFulda;
import java.applet.*;
import java.awt.*;
import javax.swing.JApplet;
import net.sourceforge.jFuzzyLogic.FIS;
import javax.swing.JPanel;
import java.awt.Container;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Image;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.Insets;
import javax.swing.JSlider;
import javax.swing.SwingConstants;
import javax.swing.JButton;
import javax.swing.event.ChangeListener;
import javax.swing.event.ChangeEvent;
import javax.swing.ImageIcon;
import javax.swing.border.LineBorder;
import javax.swing.DebugGraphics;
public class Helikoptergui extends JApplet{
/**
*
*/
static JSlider WindvonLinks = new JSlider();
static JSlider WindvonRechts = new JSlider();
static JSlider HelikopterHoehe = new JSlider();
static JPanel Feld = new JPanel();
public void init(){
setSize(800,600);
GridBagLayout gridBagLayout = new GridBagLayout();
gridBagLayout.columnWidths = new int[]{33, 84, 32, 500, 33, 98, 20, 0};
gridBagLayout.rowHeights = new int[]{24, 15, 27, 450, 48, 18, 0};
gridBagLayout.columnWeights = new double[]{0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, Double.MIN_VALUE};
gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 1.0, 1.0, 0.0, Double.MIN_VALUE};
getContentPane().setLayout(gridBagLayout);
JLabel lblHelikopter = new JLabel(" Helikopter Landung");
lblHelikopter.setFont(new Font("Tahoma", Font.PLAIN, 23));
GridBagConstraints gbc_lblHelikopter = new GridBagConstraints();
gbc_lblHelikopter.anchor = GridBagConstraints.WEST;
gbc_lblHelikopter.insets = new Insets(0, 0, 5, 5);
gbc_lblHelikopter.gridx = 3;
gbc_lblHelikopter.gridy = 0;
getContentPane().add(lblHelikopter, gbc_lblHelikopter);
JLabel lblBylabel = new JLabel("by me");
GridBagConstraints gbc_lblBylabel = new GridBagConstraints();
gbc_lblBylabel.insets = new Insets(0, 0, 5, 5);
gbc_lblBylabel.gridx = 3;
gbc_lblBylabel.gridy = 1;
getContentPane().add(lblBylabel, gbc_lblBylabel);
JLabel lblWindVonLinks = new JLabel("Wind von Links");
GridBagConstraints gbc_lblWindVonLinks = new GridBagConstraints();
gbc_lblWindVonLinks.insets = new Insets(0, 0, 5, 5);
gbc_lblWindVonLinks.gridx = 1;
gbc_lblWindVonLinks.gridy = 2;
getContentPane().add(lblWindVonLinks, gbc_lblWindVonLinks);
JLabel lblWindVonRechts = new JLabel("Wind von Rechts");
GridBagConstraints gbc_lblWindVonRechts = new GridBagConstraints();
gbc_lblWindVonRechts.insets = new Insets(0, 0, 5, 5);
gbc_lblWindVonRechts.gridx = 5;
gbc_lblWindVonRechts.gridy = 2;
getContentPane().add(lblWindVonRechts, gbc_lblWindVonRechts);
WindvonLinks.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
checkWind(false);
}
});
WindvonLinks.setMajorTickSpacing(10);
WindvonLinks.setToolTipText("Wind kann nur von einer Richtung kommen");
WindvonLinks.setPaintLabels(true);
WindvonLinks.setPaintTicks(true);
WindvonLinks.setValue(100);
WindvonLinks.setMaximum(200);
WindvonLinks.setSnapToTicks(true);
WindvonLinks.setOrientation(SwingConstants.VERTICAL);
GridBagConstraints gbc_WindvonLinks = new GridBagConstraints();
gbc_WindvonLinks.fill = GridBagConstraints.BOTH;
gbc_WindvonLinks.insets = new Insets(0, 0, 5, 5);
gbc_WindvonLinks.gridx = 1;
gbc_WindvonLinks.gridy = 3;
getContentPane().add(WindvonLinks, gbc_WindvonLinks);
WindvonRechts.setValue(0);
WindvonRechts.setToolTipText("Wind kann nur von einer Richtung kommen");
WindvonRechts.setMajorTickSpacing(10);
WindvonRechts.setMaximum(200);
WindvonRechts.setOrientation(SwingConstants.VERTICAL);
WindvonRechts.setSnapToTicks(true);
WindvonRechts.setPaintTicks(true);
WindvonRechts.setPaintLabels(true);
GridBagConstraints gbc_WindvonRechts = new GridBagConstraints();
gbc_WindvonRechts.fill = GridBagConstraints.BOTH;
gbc_WindvonRechts.insets = new Insets(0, 0, 5, 5);
gbc_WindvonRechts.gridx = 5;
gbc_WindvonRechts.gridy = 3;
getContentPane().add(WindvonRechts, gbc_WindvonRechts);
WindvonRechts.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
checkWind(true);
}
});
HelikopterHoehe.setValue(450);
HelikopterHoehe.setMajorTickSpacing(50);
HelikopterHoehe.setMaximum(450);
HelikopterHoehe.setSnapToTicks(true);
HelikopterHoehe.setPaintTicks(true);
HelikopterHoehe.setPaintLabels(true);
GridBagConstraints gbc_HelikopterHoehe = new GridBagConstraints();
gbc_HelikopterHoehe.fill = GridBagConstraints.BOTH;
gbc_HelikopterHoehe.insets = new Insets(0, 0, 5, 5);
gbc_HelikopterHoehe.gridx = 3;
gbc_HelikopterHoehe.gridy = 4;
getContentPane().add(HelikopterHoehe, gbc_HelikopterHoehe);
JButton btnStart = new JButton("START!");
GridBagConstraints gbc_btnStart = new GridBagConstraints();
gbc_btnStart.insets = new Insets(0, 0, 5, 5);
gbc_btnStart.gridx = 5;
gbc_btnStart.gridy = 4;
getContentPane().add(btnStart, gbc_btnStart);
JLabel lblHelikopterHoehe = new JLabel("Helikopter Hoehe");
GridBagConstraints gbc_lblHelikopterHoehe = new GridBagConstraints();
gbc_lblHelikopterHoehe.insets = new Insets(0, 0, 0, 5);
gbc_lblHelikopterHoehe.gridx = 3;
gbc_lblHelikopterHoehe.gridy = 5;
getContentPane().add(lblHelikopterHoehe, gbc_lblHelikopterHoehe);
GridBagConstraints gbc_Feld = new GridBagConstraints();
gbc_Feld.fill = GridBagConstraints.BOTH;
gbc_Feld.insets = new Insets(0, 0, 5, 5);
gbc_Feld.gridx = 3;
gbc_Feld.gridy = 3;
JPanel Feld = new JPanel();
Feld.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
Feld.setBorder(new LineBorder(new Color(0, 0, 0), 2, true));
Feld.setLayout(null);
Feld.setBackground(new Color(153, 255, 255));
getContentPane().add(Feld, gbc_Feld);
JLabel Helikopter = new JLabel("");
Helikopter.setSize(111, 46);
Helikopter.setLocation(183, 0);
Helikopter.setIcon(new ImageIcon("PFAD ZUM BILD"));
Feld.add(Helikopter);
JLabel bg = new JLabel("");
bg.setIcon(new ImageIcon("PFAD ZUM BILD"));
bg.setBounds(0, 346, 492, 100);
Feld.add(bg);
}
public void checkWind(boolean i){
if(i){WindvonLinks.setValue(0);}
else{WindvonRechts.setValue(0); }
}
public void paint(Graphics g){
}
}
Ich bin mir sicher, dass jemand, der sich mit Applets auskennt sofort den Fehler sieht. Aber mir bleibt das Licht der Erkenntnis seit 2 Tagen aus.
lG