2011-03-29 47 views
0

dt.add(tf)聲明中的錯誤是什麼?在java中創建小程序

/*<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); 
    }  
} 
+0

dt.add語句中的錯誤是什麼 – user658427 2011-03-29 14:59:12

+0

將來,請複製/粘貼確切的編譯或運行時錯誤消息。這些消息提供了很多有用的信息。 – 2011-03-29 16:42:39

回答