2015-10-06 184 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