// 更新背景图片的方法
private void updateBackImage() {
if (backLabel != null) {
int backw = JXCFrame.this.frame.getWidth();
int backh = JXCFrame.this.frame.getHeight();
backLabel.setSize(backw, backh);
backLabel.setText("<html><body><image width='" + backw
+ "' height='" + (backh - 110) + "' src="
+ JXCFrame.this.getClass().getResource("/welcome.jpg")
+ "'></img></body></html>");
}
}
/**
* 为内部窗体添加Action的方法
*/
public JButton createFrameButton(String fName, String cname) {
String imgUrl = "res/ActionIcon/" + fName + ".png";
String imgUrl_roll = "res/ActionIcon/" + fName + "_roll.png";
String imgUrl_down = "res/ActionIcon/" + fName + "_down.png";
Icon icon = new ImageIcon(imgUrl); Icon icon_roll = null;
if (imgUrl_roll != null)
icon_roll = new ImageIcon(imgUrl_roll);
Icon icon_down = null;
if (imgUrl_down != null)
icon_down = new ImageIcon(imgUrl_down);
Action action = new openFrameAction(fName, cname, icon);
JButton button = new JButton(action);
button.setMargin(new Insets(0, 0, 0, 0));
button.setHideActionText(true);
button.setFocusPainted(false);
button.setBorderPainted(false);
button.setContentAreaFilled(false);
if (icon_roll != null)
button.setRolloverIcon(icon_roll);
if (icon_down != null)
button.setPressedIcon(icon_down); return button; }
// 窗体监听器
private final class FrameListener extends ComponentAdapter {
public void componentResized(final ComponentEvent e) {
updateBackImage();
}
} // 主窗体菜单项的单击事件监听器
protected final class openFrameAction extends AbstractAction {
private String frameName = null; private openFrameAction() {
} public openFrameAction(String cname, String frameName, Icon icon) {
this.frameName = frameName;
putValue(Action.NAME, cname); // 设置Action名称
putValue(Action.SHORT_DESCRIPTION, cname); // 设置Action的提示文本信息
putValue(Action.SMALL_ICON, icon); // 设置Action的图标
} public void actionPerformed(final ActionEvent e) {
JInternalFrame jf = getIFrame(frameName); // 调用getFrame()方法
// 在内部窗体闭关时,从内部窗体容器ifs对象中清除该窗体。
jf.addInternalFrameListener(new InternalFrameAdapter() {
public void internalFrameClosed(InternalFrameEvent e) {
ifs.remove(frameName);
}
});
if (jf.getDesktopPane() == null) {
desktopPane.add(jf); // 讲窗体添加到主窗体中
jf.setVisible(true); // 显示窗体
}
try {
jf.setSelected(true); // 使窗体处于被选择状态
} catch (PropertyVetoException e1) {
e1.printStackTrace();
}
}
}
private void updateBackImage() {
if (backLabel != null) {
int backw = JXCFrame.this.frame.getWidth();
int backh = JXCFrame.this.frame.getHeight();
backLabel.setSize(backw, backh);
backLabel.setText("<html><body><image width='" + backw
+ "' height='" + (backh - 110) + "' src="
+ JXCFrame.this.getClass().getResource("/welcome.jpg")
+ "'></img></body></html>");
}
}
/**
* 为内部窗体添加Action的方法
*/
public JButton createFrameButton(String fName, String cname) {
String imgUrl = "res/ActionIcon/" + fName + ".png";
String imgUrl_roll = "res/ActionIcon/" + fName + "_roll.png";
String imgUrl_down = "res/ActionIcon/" + fName + "_down.png";
Icon icon = new ImageIcon(imgUrl); Icon icon_roll = null;
if (imgUrl_roll != null)
icon_roll = new ImageIcon(imgUrl_roll);
Icon icon_down = null;
if (imgUrl_down != null)
icon_down = new ImageIcon(imgUrl_down);
Action action = new openFrameAction(fName, cname, icon);
JButton button = new JButton(action);
button.setMargin(new Insets(0, 0, 0, 0));
button.setHideActionText(true);
button.setFocusPainted(false);
button.setBorderPainted(false);
button.setContentAreaFilled(false);
if (icon_roll != null)
button.setRolloverIcon(icon_roll);
if (icon_down != null)
button.setPressedIcon(icon_down); return button; }
// 窗体监听器
private final class FrameListener extends ComponentAdapter {
public void componentResized(final ComponentEvent e) {
updateBackImage();
}
} // 主窗体菜单项的单击事件监听器
protected final class openFrameAction extends AbstractAction {
private String frameName = null; private openFrameAction() {
} public openFrameAction(String cname, String frameName, Icon icon) {
this.frameName = frameName;
putValue(Action.NAME, cname); // 设置Action名称
putValue(Action.SHORT_DESCRIPTION, cname); // 设置Action的提示文本信息
putValue(Action.SMALL_ICON, icon); // 设置Action的图标
} public void actionPerformed(final ActionEvent e) {
JInternalFrame jf = getIFrame(frameName); // 调用getFrame()方法
// 在内部窗体闭关时,从内部窗体容器ifs对象中清除该窗体。
jf.addInternalFrameListener(new InternalFrameAdapter() {
public void internalFrameClosed(InternalFrameEvent e) {
ifs.remove(frameName);
}
});
if (jf.getDesktopPane() == null) {
desktopPane.add(jf); // 讲窗体添加到主窗体中
jf.setVisible(true); // 显示窗体
}
try {
jf.setSelected(true); // 使窗体处于被选择状态
} catch (PropertyVetoException e1) {
e1.printStackTrace();
}
}
}
解决方案 »
- java的问题
- 急问,请帮忙,谢谢各位大侠!请问http_request.readyState一直为1,到不了4,是什么原因呢?该如何解决呢?谢谢!
- xmpp协议三个顶层xml元素的区别
- 这是一个内部类问题吗?
- 如何监听程序中的一个变量值是否被改变
- 菜鸟级问题,我怎么对一个数组进行初始化操作,紧急情况
- java与c的socket的传输问题
- 如何得到一个客户机的mac地址,request对象是否有这样的方法
- 对CSDN关于修改密码的建议一点点,尽管CSDN对我进行了信誉上的剥夺
- 帮忙看一下,急!!!100分
- 关于printStackTrace的困惑///
- Java基础 List 的简单操作,寻求高效率的解答。。。。在线-----昨天发过此帖,问题描述错误,所以今天重发
唉这代码太痛苦了