import java.lang.*问题
importjavax.swing.*;importjava.awt.*;importjava.awt.event.*;importjava.net.*;import.j...
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import.java.lang.*;
public class WelcomeApplet extends JApplet
implements ActionListener
{ public void init()
{ Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
JLabel label = new JLabel(getParameter("greeting"),
SwingConstants.CENTER);
label.setFont(new Font("TimesRoman", Font.BOLD, 18));
contentPane.add(label, "Center");
JPanel panel = new JPanel();
cayButton = new JButton("Cay Horstmann");
cayButton.addActionListener(this);
panel.add(cayButton);
garyButton = new JButton("Gary Cornell");
garyButton.addActionListener(this);
panel.add(garyButton);
contentPane.add(panel, "South");
}
public void actionPerformed(ActionEvent evt)
{ Object source = evt.getSource();
String urlName;
if (source == cayButton)
urlName = "http://www.horstmann.com";
else if (source == garyButton)
urlName = "mailto:gary@thecornells.com";
else return;
try
{ URL u = new URL(urlName);
getAppletContext().showDocument(u);
}
catch(Exception e)
{ showStatus("Error " + e);
}
}
private JButton cayButton;
private JButton garyButton;
}
运行后程序提示:
D:\jdk\CoreJavaBook\v1ch2\WelcomeApplet>javac WelcomeApplet.java
WelcomeApplet.java:10: 需要 <标识符>
import.java.lang.*; 展开
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import.java.lang.*;
public class WelcomeApplet extends JApplet
implements ActionListener
{ public void init()
{ Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
JLabel label = new JLabel(getParameter("greeting"),
SwingConstants.CENTER);
label.setFont(new Font("TimesRoman", Font.BOLD, 18));
contentPane.add(label, "Center");
JPanel panel = new JPanel();
cayButton = new JButton("Cay Horstmann");
cayButton.addActionListener(this);
panel.add(cayButton);
garyButton = new JButton("Gary Cornell");
garyButton.addActionListener(this);
panel.add(garyButton);
contentPane.add(panel, "South");
}
public void actionPerformed(ActionEvent evt)
{ Object source = evt.getSource();
String urlName;
if (source == cayButton)
urlName = "http://www.horstmann.com";
else if (source == garyButton)
urlName = "mailto:gary@thecornells.com";
else return;
try
{ URL u = new URL(urlName);
getAppletContext().showDocument(u);
}
catch(Exception e)
{ showStatus("Error " + e);
}
}
private JButton cayButton;
private JButton garyButton;
}
运行后程序提示:
D:\jdk\CoreJavaBook\v1ch2\WelcomeApplet>javac WelcomeApplet.java
WelcomeApplet.java:10: 需要 <标识符>
import.java.lang.*; 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询