关于JButton的问题 在actionPerformed()中加上b=new Frame();b.show();a.setVisible(false);a=null;a.dispose(); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //********************************************************************************//* UI²¿·Ö*//********************************************************************************/** * MyInternalFrameTitlePane */class MyInternalFrameTitlePane extends BasicInternalFrameTitlePane { JInter jIF = null; public MyInternalFrameTitlePane(JInternalFrame f) { super(f); jIF = (JInter)f; } protected void createActions() { maximizeAction = new MaximizeAction(); iconifyAction = new IconifyAction(); closeAction = new CloseAction(); restoreAction = new RestoreAction(); moveAction = new MoveAction(); sizeAction = new SizeAction(); } public class MaximizeAction extends AbstractAction { public MaximizeAction() { super(MAXIMIZE_CMD); } public void actionPerformed(ActionEvent se) { JDesktopPane desktop = jIF.getDesk(); JInternalFrame[] it =desktop.getAllFrames(); for (int i = 0 ; i < it.length ;i++ ){ try{ it[i].setMaximum(true); }catch(Exception e){} it[i].setUI(new MyInternalFrameUI(jIF)); } try{ jIF.setSelected(true); jIF.getJFrame().makeOperation(); }catch(Exception ef){} jIF.setUI(new MyInternalFrameUI(jIF)); } } public class CloseAction extends AbstractAction { public CloseAction() { super(CLOSE_CMD); } public void actionPerformed(ActionEvent se) { if (!jIF.getJFrame().getIsSaved()){ String[] d = new String[]{"<html><font size=3>±£´æ</font>","<html><font size=3>²»±£´æ</font>","<html><font size=3>È¡Ïû</font>"}; JLabel saveJlabel = new JLabel("±£´æ¸Ä±äµ½ "+jIF.getTitle() + " £¿"); int result = JOptionPane.showOptionDialog(jIF.getJFrame(), saveJlabel, "EditBoy", JOptionPane.DEFAULT_OPTION, // option type JOptionPane.INFORMATION_MESSAGE, // message type new ImageIcon("image/saveJOption.gif"), d, d[0] ); switch(result){ case 0: jIF.getJFrame().setSaveing(); closeOperation(); break; case 1: closeOperation(); break; case 2: break; default: break; } }else{ closeOperation(); } } } public void closeOperation(){ JPanel panel = jIF.getPanel(); ButtonGroup bg = jIF.getButtonGroup(); JToggleButton jtb = jIF.getToggleButton(); JSeparator h = jIF.getJSeparator(); try{ jIF.setClosed(true); jIF.dispose(); }catch(Exception e){} if (jIF.getJFrame().getJInternalFrame() == null){ jIF.getJFrame().setTitle("EditBoy"); jIF.getJFrame().setJMenuItemEdit(false); }else{ String title = jIF.getJFrame().getJInternalFrame().getTitle(); jIF.getJFrame().setTitle("EditBoy - [ " + title + " ]"); } bg.remove(jtb); panel.remove(jtb); panel.remove(h); panel.validate(); panel.repaint(); }}/** * MyInternalFrameUI */ class MyInternalFrameUI extends BasicInternalFrameUI { public MyInternalFrameUI(JInternalFrame f) { super(f); } protected JComponent createNorthPane(JInternalFrame jif) { jif.setBackground(Color.white); jif.setBorder(BorderFactory.createEmptyBorder()); jif.setFrameIcon(new ImageIcon("image/editboy.gif")); return null; }}/** * YourInternalFrameUI */ class YourInternalFrameUI extends BasicInternalFrameUI { public YourInternalFrameUI(JInternalFrame f) { super(f); } protected JComponent createNorthPane(JInternalFrame jif) { titlePane = new MyInternalFrameTitlePane(jif); jif.setBackground(Color.white); try{ jif.setMaximum(false); }catch(Exception e){} return titlePane; }}我写的很乱,你可以看看,用的时候setUI(..),不用了uninstallUI或者updateUI就可以了 看错你的题目了,那就很好做了DefaultDesktopManager desktopManager = new DefaultDesktopManager ();在button的监听器中加入desktopManager.closeFrame(interFramea);interFrameb.setSelected(true); 实现用户登录时信息验证 求教,用java写出马克劳林公式计算过程,大侠帮帮忙 UltraEditor如何设置 字符串对象的问题 再问eclipse编写junit的问题? 代码解答 有关多线程和异常处理 我彻底凌乱了 一个初学者的自白求助帖 question? 如何把JTable里面显示的内容的文字色,用红色表示? jbuilder编译时老是将class下的文件删掉 Java编程中的鼠标问题! 请问,如何用一个存在的文件a初始化一个新建文件b,需要调用什么方法?
//* UI²¿·Ö*
//********************************************************************************
/**
* MyInternalFrameTitlePane
*/
class MyInternalFrameTitlePane extends BasicInternalFrameTitlePane {
JInter jIF = null;
public MyInternalFrameTitlePane(JInternalFrame f) {
super(f);
jIF = (JInter)f;
}
protected void createActions() {
maximizeAction = new MaximizeAction();
iconifyAction = new IconifyAction();
closeAction = new CloseAction();
restoreAction = new RestoreAction();
moveAction = new MoveAction();
sizeAction = new SizeAction();
} public class MaximizeAction extends AbstractAction {
public MaximizeAction() {
super(MAXIMIZE_CMD);
} public void actionPerformed(ActionEvent se) {
JDesktopPane desktop = jIF.getDesk();
JInternalFrame[] it =desktop.getAllFrames();
for (int i = 0 ; i < it.length ;i++ ){
try{
it[i].setMaximum(true);
}catch(Exception e){}
it[i].setUI(new MyInternalFrameUI(jIF));
}
try{
jIF.setSelected(true);
jIF.getJFrame().makeOperation();
}catch(Exception ef){}
jIF.setUI(new MyInternalFrameUI(jIF));
}
} public class CloseAction extends AbstractAction {
public CloseAction() {
super(CLOSE_CMD);
} public void actionPerformed(ActionEvent se) {
if (!jIF.getJFrame().getIsSaved()){
String[] d = new String[]{"<html><font size=3>±£´æ</font>","<html><font size=3>²»±£´æ</font>","<html><font size=3>È¡Ïû</font>"};
JLabel saveJlabel = new JLabel("±£´æ¸Ä±äµ½ "+jIF.getTitle() + " £¿");
int result = JOptionPane.showOptionDialog(jIF.getJFrame(),
saveJlabel,
"EditBoy",
JOptionPane.DEFAULT_OPTION, // option type
JOptionPane.INFORMATION_MESSAGE, // message type
new ImageIcon("image/saveJOption.gif"),
d,
d[0]
);
switch(result){
case 0:
jIF.getJFrame().setSaveing();
closeOperation();
break;
case 1:
closeOperation();
break;
case 2:
break;
default:
break;
}
}else{
closeOperation();
}
}
} public void closeOperation(){
JPanel panel = jIF.getPanel();
ButtonGroup bg = jIF.getButtonGroup();
JToggleButton jtb = jIF.getToggleButton();
JSeparator h = jIF.getJSeparator();
try{
jIF.setClosed(true);
jIF.dispose();
}catch(Exception e){} if (jIF.getJFrame().getJInternalFrame() == null){
jIF.getJFrame().setTitle("EditBoy");
jIF.getJFrame().setJMenuItemEdit(false);
}else{
String title = jIF.getJFrame().getJInternalFrame().getTitle();
jIF.getJFrame().setTitle("EditBoy - [ " + title + " ]");
} bg.remove(jtb);
panel.remove(jtb);
panel.remove(h);
panel.validate();
panel.repaint();
}
}/**
* MyInternalFrameUI
*/
class MyInternalFrameUI extends BasicInternalFrameUI { public MyInternalFrameUI(JInternalFrame f) {
super(f);
}
protected JComponent createNorthPane(JInternalFrame jif) {
jif.setBackground(Color.white);
jif.setBorder(BorderFactory.createEmptyBorder());
jif.setFrameIcon(new ImageIcon("image/editboy.gif"));
return null;
}
}/**
* YourInternalFrameUI
*/
class YourInternalFrameUI extends BasicInternalFrameUI { public YourInternalFrameUI(JInternalFrame f) {
super(f);
}
protected JComponent createNorthPane(JInternalFrame jif) {
titlePane = new MyInternalFrameTitlePane(jif);
jif.setBackground(Color.white);
try{
jif.setMaximum(false);
}catch(Exception e){}
return titlePane;
}
}
我写的很乱,你可以看看,用的时候setUI(..),不用了uninstallUI或者updateUI就可以了
DefaultDesktopManager desktopManager = new DefaultDesktopManager ();
在button的监听器中加入
desktopManager.closeFrame(interFramea);
interFrameb.setSelected(true);