在java中创建applet

时间:2011-03-29 14:58:42

标签: swing jinternalframe

dt.add(tf)声明中的错误是什么?

/*<applet code="applicant" height=300 width=300></applet>*/
import javax.swing.*;
public class applicant extends JApplet
{
  static JPanel panel;
  JLabel labelAppID;
  JLabel labelAppName;
  JLabel labelAppAddress;
  JLabel labelAppPosition;
  JTextField textAppID;
  JTextField textAppName;
  JTextField textAppAddress;
  JComboBox comboAppPosition;
  public void init()
  {
    panel = new JPanel();
    getContentPane().add(panel);
    labelAppID=new JLabel("Applicant ID");
    labelAppName=new JLabel("Name");
    labelAppAddress=new JLabel("Address");
    labelAppPosition=new JLabel("Position");
    textAppID=new JTextField(5);
    textAppName=new JTextField(30);
    textAppAddress=new JTextField(30);
    String positions[]={"Manager", "Executive", "Associate"};
    comboAppPosition=new JComboBox(positions);
    panel.add(labelAppID);
    panel.add(textAppID);
    panel.add(labelAppName);
    panel.add(textAppName);
    panel.add(labelAppAddress);
    panel.add(textAppAddress);
    panel.add(labelAppPosition);
    panel.add(comboAppPosition);
       setTitle("JToolBar as a Tool Palette - Example");
      JPanel jp=(JPanel)getContentPane();
      jp.setLayout(new BorderLayout());
      JDesktopPane dt=new JDesktopPane();
      dt.setBackground(jp.getBackground());
      jp.add("center",dt);
      JFrame tf=new JFrame("Tools");
      dt.add(tf);
    }    
 }

1 个答案:

答案 0 :(得分:0)

可以将JInternalFrame添加到JDesktopPane,而JFrame则不能。

有关详细信息,请参阅Java教程中的How to Use Internal Frames