2011-12-15 58 views
1

我有一个主框架和一个连接的可折叠面板,我从http://sourceforge.net/apps/wordpress/miasct/2009/03/29/external-collapsible-panel/获得。 问题是可折叠的面板创建扩展JFrame(实际上来自SwingX的JXFrame)的未修饰框架并且行为像一个框架。Java Swing - 使JFrame像对话框一样行为

  1. 我如何摆脱这一点:

enter image description here

  • 不要表现出来的ALT + TAB啄
  • 当我使用“最小化所有窗口“,然后最大化主框架,附加框架保持图标化。
  • 这里有一个代码为它:提前

    import com.sun.jna.platform.WindowUtils; 
    import java.awt.Point; 
    import java.awt.Shape; 
    
    import java.awt.event.ComponentAdapter; 
    import java.awt.event.ComponentEvent; 
    import java.awt.geom.Ellipse2D; 
    import java.awt.geom.RoundRectangle2D; 
    import javax.swing.JFrame; 
    
    import org.jdesktop.swingx.JXFrame; 
    import ui.MainFrame; 
    
    
    
    /** 
    * CollapsibleFrame 
    * 
    * @author Devon Bryant 
    * @since Mar 26, 2009 
    */ 
    @SuppressWarnings("serial") 
    public class CollapsibleFrame extends JXFrame implements ICollapsibleFrame 
    { 
        // The parent frame to tie this frame to 
        private JFrame parentFrame = null; 
    
        // Orientation (where the collapsible frame is located relative to the parent frame) 
        private Orientation orientation = null; 
    
        /** 
        * Constructor 
        * @param inName the frame name 
        * @param inParentFrame the parent frame to tie this frame to 
        * @param the orientation (where in respect to the parent frame to attach to) 
        */ 
        public CollapsibleFrame(String inName, JFrame inParentFrame, Orientation inOrientation) 
        { 
         super(inName); 
    
         parentFrame = inParentFrame; 
         orientation = inOrientation; 
           setUndecorated(true);   
        } 
    
        /* (non-Javadoc) 
        * @see com.mia.sct.view.panel.ICollapsibleFrame#relocate() 
        */ 
        @Override 
        public void relocate() 
        { 
         offset(0, 0); 
        } 
    
        /* (non-Javadoc) 
        * @see com.mia.sct.view.panel.ICollapsibleFrame#offset(int, int) 
        */ 
        @Override 
        public void offset(int inX, int inY) 
        { 
         if ((parentFrame != null && parentFrame.isVisible())) 
         { 
          Point p = null; 
          int x = 0; 
          int y = 0; 
    
          // Calculate the new x,y coordinates for this frame based on the parents location 
          switch (orientation) 
          { 
           case TOP: 
            p = parentFrame.getLocationOnScreen(); 
            x = p.x; 
            y = p.y - getHeight(); 
            break; 
    
           case BOTTOM: 
            p = parentFrame.getLocationOnScreen(); 
            x = p.x; 
            y = p.y + parentFrame.getHeight(); 
            break; 
    
           case LEFT: 
            p = parentFrame.getLocationOnScreen(); 
            x = p.x - getWidth(); 
            y = parentFrame.getContentPane().getLocationOnScreen().y; 
            break; 
    
           case RIGHT: 
            p = parentFrame.getLocationOnScreen(); 
            x = p.x + parentFrame.getWidth(); 
            y = parentFrame.getContentPane().getLocationOnScreen().y; 
            break; 
          } 
          x += inX; 
          y += inY; 
    
          // set the location of this frame 
          setLocation(x, y);      
         } 
        } 
    
        /* (non-Javadoc) 
        * @see com.mia.sct.view.panel.ICollapsibleFrame#setMask(java.awt.Shape) 
        */ 
        public void setMask(Shape inShape) 
        { 
         WindowUtils.setWindowMask(this, inShape); 
        } 
    
        /* (non-Javadoc) 
        * @see com.mia.sct.view.panel.ICollapsibleFrame#setAlpha(float) 
        */ 
        public void setAlpha(float inAlpha) 
        { 
         if (WindowUtils.isWindowAlphaSupported()) 
         { 
          WindowUtils.setWindowAlpha(this, inAlpha); 
         } 
        } 
    } 
    

    感谢。

    回答

    2

    不是好主意,持有两人同时JFrames(或其SwingX衍生物),你必须改变,对于取消装饰JDialogJWindow(其SwingX衍生物),该解决三个问题,你可以正确设置

    • setParent

    • setModalModalityTypes

    • 没有iconified in WinOS

    +0

    感谢回复。你看到代码来自我提供的链接。也许有使用Jframe的理由?请查看我添加的代码。谢谢。 – bunnyjesse112 2011-12-15 09:15:04