你看帮助啊!!哎,给你段代码吧!
package internalframe;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import javax.swing.event.*;
//import javax.swing.JInternalFrame.*;
import java.beans.*;
import java.net.*;
import java.io.*;
import java.util.*;
public class InternalFrame extends JApplet
{
boolean isStandalone = false;
String filename;
JInternalFrame IF1;
JPanel jPanel2;
JSplitPane jSplitPane1;
BorderLayout borderLayout2;
JPanel jPanel1;
JPanel jPanel3;
JButton jButton1;
JPanel jPanel4;
BorderLayout borderLayout1;
JSplitPane jSplitPane2;
JScrollPane jScrollPane1;
JTextArea jTextArea1;
JList jList1;
JScrollPane jScrollPane2;
ImageIcon imageico,ico1;
/**Get a parameter value*/
public String getParameter(String key, String def)
{
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
/**Construct the applet*/
public InternalFrame()
{
filename="1.htm";
}
/**Initialize the applet*/
public void init()
{
try
{
jbInit();
}
catch(Exception e)
{
e.printStackTrace();
}
}
/**Component initialization*/
private void jbInit() throws Exception
{
String[] LD={"1","2","3"};
//ListData
IF1 = (JInternalFrame) Beans.instantiate(getClass().getClassLoader(), JInternalFrame.class.getName());
jPanel2 = (JPanel) Beans.instantiate(getClass().getClassLoader(), JPanel.class.getName());
jSplitPane1 = (JSplitPane) Beans.instantiate(getClass().getClassLoader(), JSplitPane.class.getName());
borderLayout2 = (BorderLayout) Beans.instantiate(getClass().getClassLoader(), BorderLayout.class.getName());
jPanel1 = (JPanel) Beans.instantiate(getClass().getClassLoader(), JPanel.class.getName());
jPanel3 = (JPanel) Beans.instantiate(getClass().getClassLoader(), JPanel.class.getName());
jButton1 = (JButton) Beans.instantiate(getClass().getClassLoader(), JButton.class.getName());
jPanel4 = (JPanel) Beans.instantiate(getClass().getClassLoader(), JPanel.class.getName());
borderLayout1 = (BorderLayout) Beans.instantiate(getClass().getClassLoader(), BorderLayout.class.getName());
jSplitPane2 = (JSplitPane) Beans.instantiate(getClass().getClassLoader(), JSplitPane.class.getName());
jScrollPane1 = (JScrollPane) Beans.instantiate(getClass().getClassLoader(), JScrollPane.class.getName());
jTextArea1 = (JTextArea) Beans.instantiate(getClass().getClassLoader(), JTextArea.class.getName());
jList1 = (JList) Beans.instantiate(getClass().getClassLoader(), JList.class.getName());
jScrollPane2 = (JScrollPane) Beans.instantiate(getClass().getClassLoader(), JScrollPane.class.getName());
Properties props = new Properties();
FileInputStream fos = new FileInputStream(filename);
props.load(fos);
System.out.println(props.getProperty("1.htm"));
//URL url=new URL(props.getProperty("1.htm"));
//props.remove("c:/111.txt");
//String r=doPost(url,props);
//System.out.println(r);
this.setSize(new Dimension(458, 353));
IF1.show();//一定要有,不然看不见InternalFrame
jPanel2.setLayout(borderLayout2);
jPanel1.setLayout(null);
jPanel3.setLayout(null);
jButton1.setText("jButton1");
jButton1.setBounds(new Rectangle(130, 92, 94, 45));
jButton1.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
{
jButton1_actionPerformed(e);
}
});
IF1.setClosable(true);
IF1.setIconifiable(true);
IF1.setMaximizable(true);
IF1.setResizable(true);
IF1.setTitle("奇妙的窗口");
IF1.setBorder(BorderFactory.createLineBorder(Color.black));
jPanel4.setLayout(borderLayout1);
jSplitPane2.setOrientation(JSplitPane.VERTICAL_SPLIT);
jTextArea1.setToolTipText("");
jScrollPane2.setToolTipText("");
jScrollPane2.setBounds(new Rectangle(0, 0, 3, 3));
jList1.addListSelectionListener(new ListSelectionListener()
{
public void valueChanged(ListSelectionEvent e)
{
jList1_valueChanged(e);
}
});
IF1.getContentPane().add(jPanel2, BorderLayout.CENTER);
jPanel2.add(jSplitPane2, BorderLayout.CENTER);
jSplitPane1.add(jPanel1, JSplitPane.LEFT);
jSplitPane1.add(jPanel3, JSplitPane.RIGHT);
jPanel1.add(jScrollPane2, null);
jPanel3.add(jButton1, null);
jSplitPane2.add(jSplitPane1, JSplitPane.LEFT);
jSplitPane2.add(jScrollPane1, JSplitPane.RIGHT);
jList1.setListData(LD);
this.getContentPane().add(jPanel4, BorderLayout.CENTER);
jSplitPane1.setOneTouchExpandable(true);
jSplitPane1.setContinuousLayout(true);
jSplitPane2.setOneTouchExpandable(true);
jSplitPane2.setContinuousLayout(true);
jPanel4.add(IF1);
jScrollPane2.setBounds(new Rectangle(78, 18, 156, 174));
jScrollPane2.getViewport().add(jList1,null);
imageico=new ImageIcon(internalframe.InternalFrame.class.getResource("t_al.gif"));
ico1=new ImageIcon(internalframe.InternalFrame.class.getResource("wave sound.jpg"));
jButton1.setIcon(imageico);
jScrollPane1.getViewport().add(jTextArea1,null);
IF1.setFrameIcon(ico1);
IF1.addVetoableChangeListener(new VetoableChangeListener()
{
public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException
{
if (e.getPropertyName()=="closed")
{
if (JOptionPane.showInternalConfirmDialog(IF1,"关闭吗?","激活的Frame的属性",1)==JOptionPane.OK_OPTION)
{
throw new PropertyVetoException("Cancel Closed!",e);
//取消用户的关闭操作
}
}
}
});
}
/**Get Applet information*/
/**Get parameter info*/
public String[][] getParameterInfo()
{
return null;
}
public JInternalFrame getIF1()
{
return IF1;
}
public JButton getjButton1()
{
return jButton1;
}
//static initializer for setting look &
feel
static
{
try
{
//UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
//UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
}
catch(Exception e){}
}
void jButton1_actionPerformed(ActionEvent e)
{
System.out.println("XXXXXX");
if (JOptionPane.showInternalConfirmDialog(IF1,"你出错了!...","error",1,1)==0)
{
System.exit(0);
}
}
public boolean isIsStandalone()
{
return isStandalone;
}
public static Stringdo
Post(URL url,Properties pro) throws IOException
{//静态方法不用void关键字,这里的String代表返回的类型
URLConnection urlconn=url.openConnection();
//得到一个URLConnection对象
urlconn.setDoInput(true);
//建立连接
PrintWriter out=new PrintWriter(urlconn.getOutputStream());
//获得一个输出流
Enumeration enum=pro.keys();
while (enum.hasMoreElements())
{
String name=(String)enum.nextElement();
//可能是htm传递的参数名及参数值
String value=pro.getProperty(name);
char ch;
if (enum.hasMoreElements()) ch='&' ;else
ch='/n';
out.println(name+"="+URLEncoder.encode(value)+ch);
}
out.close();
BufferedReader in;
try
{
in=new BufferedReader(new InputStreamReader(urlconn.getInputStream()));
}
catch (FileNotFoundException ex)
{
InputStream err=((HttpURLConnection)urlconn).getErrorStream();
if (err==null) throw ex;
in=new BufferedReader(new InputStreamReader(err));
}
StringBuffer response=new StringBuffer();
String line;
while ((line=in.readLine()) != null)
response.append(line+"/n");
in.close();
return response.toString();
//静态方法一定要这样的返回值
}
void jList1_valueChanged(ListSelectionEvent e)
{
if (jList1.getSelectedValue()!=null)
{
JOptionPane.showMessageDialog(this,jList1.getSelectedValue(),"您选择的项目值",1);
}
}
}