2015-10-06 163 views
2

如何创建从右到左的jframe?!从右到左jframe

这是java的原始的JFrame enter image description here

,这是结果时使用:

JFrame.setDefaultLookAndFeelDecorated(true); 

enter image description here

,但我需要这样的

enter image description here

回答

0
一些事情

我知道怎么做的唯一方法是使用与金属LAF未修饰的框架:

import java.awt.*; 
import java.awt.event.*; 
import javax.swing.*; 

public class SSCCE5 
{ 
    private static void createAndShowGUI() 
    { 
     JFrame frame = new JFrame("SSCCE5"); 

     frame.setUndecorated(true); 
     frame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME); 
     frame.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); 

     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
     frame.setLocationByPlatform(true); 
     frame.setSize(200, 200); 
     frame.setVisible(true); 
    } 

    public static void main(String[] args) 
    { 
     EventQueue.invokeLater(new Runnable() 
     { 
      public void run() 
      { 
       createAndShowGUI(); 
      } 
     }); 
    } 
} 
+0

结果有些东西一样 http://i.stack.imgur.com/rF4Zt.png 我需要一些像 http://i.stack.imgur.com/huWJC.png – Anas

+0

我知道。我说它只适用于Metal LAF,而不是使用WIndows默认装饰的默认LAF。 Swing无法控制框架上标题栏的外观,因为这是平台的框架。 Swing可以控制金属LAF装饰,因为它可以自己绘制标题栏。 – camickr

相关问题