Applet外观在转换为可执行文件时会发生变化

时间:2014-12-08 08:29:42

标签: java applet

applet转换为可执行文件时,我遇到了问题。 applet有三个带文字的按钮,如下图pic_1所示,当它转换为可执行文件时,三个按钮的文字消失,按钮变小,如下图pic_2所示。

我下载了一些从.jar文件生成可执行文件的应用程序,使用这些应用程序后的结果是相同的,applet运行但没有按钮。

请提供解决此问题的任何建议。

code_init()方法_

public void init () {
    frame = new JFrame ();
    frame.setSize(600, 600);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);


    /* Erzeuge MenuBar*/
    menubar = new JMenuBar();
    frame.setJMenuBar(menubar);
    einstellungen = new JMenu ("Einstellungen");

    datei = new JMenuItem ("Datei");
    datei.addActionListener(this);
    communication = new JMenuItem ("Kommunikation");
    communication.addActionListener(this);
    simulation = new JMenuItem ("Simulation");
    simulation.addActionListener(this);

    menubar.add(einstellungen);
    einstellungen.add(datei);
    einstellungen.add(communication);
    einstellungen.add(simulation);

    /*Erzeuge Layout */
    panel1 = new JPanel ();
    top = new JPanel ();
    center = new JPanel ();
    down  = new JPanel ();
    bottom  = new JPanel ();

    frame.add(panel1); //general Panel
    panel1.setLayout(new BorderLayout ()); //Separate areas in BorderLayout
    panel1.add(top, BorderLayout.NORTH);
    panel1.add(center, BorderLayout.CENTER);
    panel1.add(bottom, BorderLayout.SOUTH);

    Lspeed = new JLabel ("Geschwindigkeit: ");
    Lspeedanzeige = new JLabel ("             ");
    LineBorder lBorder = new LineBorder(new Color(100, 100, 100)); 
    Lspeedanzeige.setBorder(lBorder); 
    JLabel Lfueller = new JLabel ("         ");
    Ldrive = new JLabel ("Motordrehzahl: ");
    Ldriveanzeige = new JLabel ("              ");
    LineBorder rBorder = new LineBorder(new Color(100, 100, 100));
    Ldriveanzeige.setBorder(rBorder);

    top.setLayout(new FlowLayout ()); //add FlowLayout to Panel top
    top.add(Lspeed);
    top.add(Lspeedanzeige);
    top.add(Lfueller);
    top.add(Ldrive);
    top.add(Ldriveanzeige);

    simulationarea = new JTextArea ("Gesendete Daten:");
    JScrollPane scrollPane = new JScrollPane(simulationarea);
    simulationarea.setPreferredSize(new Dimension(5, 100));
    simulationarea.setLineWrap(true);
    simulationarea.setWrapStyleWord(true);

    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setPreferredSize(new Dimension(5, 100));
    scrollPane.setVisible(true);
    simulationarea.setEditable(true);
    simulationarea.setEnabled(true);
    int pos = simulationarea.getCaretPosition();
    simulationarea.insert("file logs", pos+17);

    center.setLayout(new BorderLayout ());
    center.add(simulationarea, BorderLayout.NORTH); //add JTextfield simulationarea to Panel center
    center.add(down, BorderLayout.SOUTH);           //add Panel down zu Panel Center

    Bplay = new JButton ("Play");
    Bplay.setPreferredSize(new Dimension(60, 50));
    Bplay.addActionListener(this);

    Bbreak = new JButton ("Pause");
    Bbreak.addActionListener(this);

    Bstop = new JButton ("Stop");
    Bstop.addActionListener(this);

    down.setLayout(new FlowLayout ()); //add FlowLayout to Panel down
    down.add(Bplay);
    down.add(Bbreak);
    down.add(Bstop);

    statusarea = new JTextArea ("Nicht verbunden");
    statusarea.setForeground(Color.RED);
    statusarea.setPreferredSize(new Dimension(550, 50));
    bottom.add(statusarea);

    frame.setVisible(true);
    System.out.println("init");

}//init

PIC_1

enter image description here

PIC_2

enter image description here

0 个答案:

没有答案