Y
yat
Unregistered / Unconfirmed
GUEST, unregistred user!
前几天照书抄的,编译运行得到一个空白的Applet why?
我的环境Forte+jdk1.3,效果来自Forte的运行窗口,应该是调用AppletViewer.
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Frame1 extends javax.swing.JApplet {
/** Creates new form Frame1 */
Container c;
public void init() {
c=getContentPane();
c.setLayout(new BorderLayout());
JLayeredPane desktop=new JLayeredPane();
desktop.setOpaque(false);
c.add(desktop,BorderLayout.CENTER);
desktop.add(createLayer("One"),JLayeredPane.POPUP_LAYER);
desktop.add(createLayer("Two"),JLayeredPane.DEFAULT_LAYER);
desktop.add(createLayer("Third"),JLayeredPane.PALETTE_LAYER);
desktop.setVisible(true);
}
public JInternalFrame createLayer(String label){
return new SelfInternalFrame(label);
}
class SelfInternalFrame extends JInternalFrame{
public SelfInternalFrame(String s){
getContentPane().add(new JLabel(s),BorderLayout.CENTER);
System.out.println("create "+s);
//setBounds(50,50,100,100);
setResizable(true);
setClosable(true);
setMaximizable(true);
setIconifiable(true);
setTitle(s);
}
}
private void initComponents() {//GEN-begin
:initComponents
}//GEN-END:initComponents
}
我的环境Forte+jdk1.3,效果来自Forte的运行窗口,应该是调用AppletViewer.
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Frame1 extends javax.swing.JApplet {
/** Creates new form Frame1 */
Container c;
public void init() {
c=getContentPane();
c.setLayout(new BorderLayout());
JLayeredPane desktop=new JLayeredPane();
desktop.setOpaque(false);
c.add(desktop,BorderLayout.CENTER);
desktop.add(createLayer("One"),JLayeredPane.POPUP_LAYER);
desktop.add(createLayer("Two"),JLayeredPane.DEFAULT_LAYER);
desktop.add(createLayer("Third"),JLayeredPane.PALETTE_LAYER);
desktop.setVisible(true);
}
public JInternalFrame createLayer(String label){
return new SelfInternalFrame(label);
}
class SelfInternalFrame extends JInternalFrame{
public SelfInternalFrame(String s){
getContentPane().add(new JLabel(s),BorderLayout.CENTER);
System.out.println("create "+s);
//setBounds(50,50,100,100);
setResizable(true);
setClosable(true);
setMaximizable(true);
setIconifiable(true);
setTitle(s);
}
}
private void initComponents() {//GEN-begin
:initComponents
}//GEN-END:initComponents
}