java – 最小化Jinternal框架而不单击按钮
发布时间:2020-12-15 07:37:11 所属栏目:Java 来源:网络整理
导读:有没有办法最小化/最大化JinternalFrame而不点击jinternalframe右上角的最小化/最大化按钮? 我按照这个线程programmatically minimize a JInternalFrame?,专门设置 jinterframe.setIcon(false) 但我没有工作. 谢谢. 解决方法 按照我的预期工作,你必须检查 J
有没有办法最小化/最大化JinternalFrame而不点击jinternalframe右上角的最小化/最大化按钮?
我按照这个线程programmatically minimize a JInternalFrame?,专门设置 jinterframe.setIcon(false) 但我没有工作. 谢谢. 解决方法
按照我的预期工作,你必须检查
JInternalFrame#isIconifiable()(eeerght这个Veto真的是****)
import java.awt.*; import java.awt.event.*; import java.beans.PropertyVetoException; import javax.swing.*; import javax.swing.plaf.basic.*; public class InternalFrameUnMovable extends JFrame { private static final long serialVersionUID = 1L; public JDesktopPane desktop; public InternalFrameUnMovable() { desktop = new JDesktopPane(); getContentPane().add(desktop); desktop.add(createInternalFrame(1,Color.RED)); desktop.add(createInternalFrame(2,Color.GREEN)); desktop.add(createInternalFrame(3,Color.BLUE)); } private JInternalFrame createInternalFrame(int number,Color background) { JInternalFrame internal = new JInternalFrame("Frame" + number,true,true); internal.setBackground(background); internal.setVisible(true); int location = 50 * number; internal.setBounds(location,location,300,300); return internal; } public static void main(String args[]) throws PropertyVetoException { InternalFrameUnMovable frame = new InternalFrameUnMovable(); frame.setDefaultCloSEOperation(EXIT_ON_CLOSE); frame.setSize(600,600); frame.setLocationRelativeTo(null); frame.setVisible(true); try {// Activate first internal frame JInternalFrame[] frames = frame.desktop.getAllFrames(); frames[0].setSelected(true); } catch (java.beans.PropertyVetoException e) { } JInternalFrame[] frames = frame.desktop.getAllFrames();// Make first internal frame unmovable for (int i = 0; i < frames.length; i++) { JInternalFrame f = frames[i]; if (f.isIconifiable()) { f.setIcon(true); } } /*JInternalFrame f = frames[0]; BasicInternalFrameUI ui = (BasicInternalFrameUI) f.getUI(); Component north = ui.getNorthPane(); //MouseMotionListener[] actions = (MouseMotionListener[]) north.getListeners(MouseMotionListener.class); MouseMotionListener[] actions = north.getListeners(MouseMotionListener.class); for (int i = 0; i < actions.length; i++) { north.removeMouseMotionListener(actions[i]); }*/ } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |