解决方案 »
- 图片更新时的定时器(timer)?
- RE:关于BufferedInputStream读取网络流的问题
- java的des加密解密 求助
- JDK1.5环境变量配置出现异常.奇怪奇怪。。。 5 5
- 请教优化java swing程序运行速度的方法和建议
- 是否可以通过applet向html传参数?
- 如何获取存储过程返回的结果?
- 有人说java高手都去看国外论坛了,我看不假,问了个问题,快一个月了没人给看看
- 改写基类方法后的调用问题.下面是代码,问题时代码中的两个paintComponent(Graphics g)方法是何时被调用的?谁调用的?
- 谁有IO方面的书??
- 线程简单问题
- JLayeredPane 不同层的控件重叠显示的问题,急!
import java.awt.*;
import java.awt.event.*;public class Test extends JApplet {
Icon dukeStanding = new ImageIcon("duke_standing.gif"),
dukeWaving = new ImageIcon("duke_waving.gif"),
dukeStandingSmall = new ImageIcon("duke_standing_small.gif"),
dukeWavingSmall = new ImageIcon("duke_waving_small.gif"); public void init() {
Container contentPane = getContentPane();
Action[] actions = { new NewAction(), new OpenAction(),
new CutAction(), new CopyAction(), new PasteAction(),
new ExitAction() };
JToolBar toolbar = new JToolBar();
JMenuBar menubar = new JMenuBar();
JMenu fileMenu = new JMenu("File");
JRadioButton menubarDuke = new JRadioButton(dukeStandingSmall), menuDuke = new JRadioButton(
dukeStandingSmall), toolbarDuke = new JRadioButton(dukeStanding); menuDuke.setRolloverIcon(dukeWavingSmall);
menubarDuke.setRolloverIcon(dukeWavingSmall);
toolbarDuke.setRolloverIcon(dukeWaving);
menubar.add(menubarDuke);
toolbar.add(toolbarDuke);
fileMenu.add(menuDuke);
for (int i = 0; i < actions.length; ++i) {
fileMenu.add(actions[i]);
if (i != actions.length - 1)
toolbar.add(actions[i]);
if (i == 2 || i == actions.length - 2) {
toolbar.addSeparator();
fileMenu.addSeparator();
}
}
menubar.add(fileMenu);
contentPane.add(toolbar, BorderLayout.NORTH);
getRootPane().setJMenuBar(menubar);
System.out.println(contentPane.getClass().getName());
LayoutManager lm = contentPane.getLayout();
System.out.println(lm.getClass());
} class NewAction extends AbstractAction {
public NewAction() {
super("New ...", new ImageIcon("new.gif"));
} public void actionPerformed(ActionEvent event) {
showStatus("new");
}
} class OpenAction extends AbstractAction {
public OpenAction() {
super("Open ...", new ImageIcon("open.gif"));
} public void actionPerformed(ActionEvent event) {
showStatus("open");
}
} class CutAction extends AbstractAction {
public CutAction() {
super("Cut", new ImageIcon("cut.gif"));
} public void actionPerformed(ActionEvent event) {
showStatus("cut");
}
} class CopyAction extends AbstractAction {
public CopyAction() {
super("Copy", new ImageIcon("copy.gif"));
} public void actionPerformed(ActionEvent event) {
showStatus("copy");
}
} class PasteAction extends AbstractAction {
public PasteAction() {
super("Paste", new ImageIcon("paste.gif"));
} public void actionPerformed(ActionEvent event) {
showStatus("paste");
}
} class ExitAction extends AbstractAction {
public ExitAction() {
super("Exit");
putValue(Action.SMALL_ICON, dukeWavingSmall);
} public void actionPerformed(ActionEvent event) {
System.exit(0);
}
}
}