import java.io.*;
import java.util.*;
import java.net.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class ChildFrame extends JInternalFrame implements ActionListener
{
private JList myList;
private JTextField myEdit;
public ChildFrame(String title, JApplet applet)
{
super("Child " + title, true, true);
setIconifiable(true);
setMaximizable(true);
setBackground(Color.lightGray);
setSize(300, 200);
this.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);
getContentPane().setLayout(new BorderLayout());
JPanel Pnl = new JPanel();
Pnl.setLayout(new GridLayout(1, 2));
myEdit = new JTextField();
myEdit.addActionListener(this);
Pnl.add(new JLabel("Enter text:", new ImageIcon(NetShare.loadImage("duke.gif", applet)), JLabel.LEFT));
Pnl.add(myEdit);
getContentPane().add(Pnl, BorderLayout.NORTH);
myList = new JList();
myList.setModel(new DefaultListModel());
getContentPane().add(new JScrollPane(myList), BorderLayout.CENTER);
// pack();
}
public void actionPerformed(ActionEvent e)
{
((DefaultListModel) myList.getModel()).addElement(e.getActionCommand());
}
}
public class NetShare extends JApplet implements ActionListener
{
private JDesktopPane desk;
// private JPanel Background;
public void init()
{
desk = new JDesktopPane();
desk.setDesktopManager(new DefaultDesktopManager());
this.setContentPane(desk);
addChild(new ChildFrame("doofi", this));
// Menü initialisieren
JMenuBar mb = new JMenuBar();
JMenu menu = new JMenu("System");
JMenuItem itm = new JMenuItem("New");
itm.addActionListener(this);
menu.add(itm);
menu.addSeparator();
itm = new JMenuItem("Exit");
itm.addActionListener(this);
menu.add(itm);
mb.add(menu);
menu = new JMenu("Themes");
itm = new JMenuItem("Metal");
itm.addActionListener(this);
menu.add(itm);
itm = new JMenuItem("Motif");
itm.addActionListener(this);
menu.add(itm);
itm = new JMenuItem("Windows");
itm.addActionListener(this);
menu.add(itm);
mb.add(menu);
this.setJMenuBar(mb);
this.setLayout(new BorderLayout());
this.add(new JLabel("", new ImageIcon(loadImage("bg640x480.gif", this)),
JLabel.LEFT), BorderLayout.CENTER);
}
public void start()
{
JOptionPane.showConfirmDialog(this, getCodeBase(), "restarted",
JOptionPane.PLAIN_MESSAGE);
}
public void stop()
{
}
public void destroy()
{
}
public void addChild(JInternalFrame nChild)
{
desk.add(nChild);
nChild.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand().equals("Exit"))
{
this.setEnabled(false);
JOptionPane.showConfirmDialog(this, "Exited", "Exited",
JOptionPane.PLAIN_MESSAGE);
} else if(e.getActionCommand().equals("New"))
{
addChild(new ChildFrame("neu fenster", this));
}
String plaf = UIManager.getLookAndFeel().getName();
if(e.getActionCommand() == "Windows")
{
if(JOptionPane.showConfirmDialog(this,
"Are you sure you want to switch to Windows-style?",
"Are you sure?", JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION)
plaf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
} else if(e.getActionCommand() == "Motif")
{
plaf = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
} else if(e.getActionCommand() == "Metal")
{
plaf = "javax.swing.plaf.metal.MetalLookAndFeel";
}
try
{
UIManager.setLookAndFeel(plaf);
SwingUtilities.updateComponentTreeUI(this);
} catch(Exception ex)
{
}
}
public static Image loadImage(String FName, JApplet applet)
{
Image img = null;
try
{
img = applet.getImage(new URL(applet.getCodeBase().toString()
+ FName));
} catch(Exception e)
{
}
return img;
}
/**
* @param args
*/
public static void main(String[] args)
{
}
/**
* shows Quellcode of an Page
*
* @param ort
*/
public void showURL(String ort)
{
URL meineurl;
InputStream is = null;
try
{
meineurl = new URL(ort);
is = meineurl.openStream();
} catch(Exception e)
{
}
DataInputStream dis = new DataInputStream(is);
while(true)
{
try
{
String line = dis.readLine();
if(line == null)
break;
System.out.println(line);
} catch(IOException e)
{
}
}
}
}