2011-08-28 9 views
8

私はいくつかのコードをオンラインで見つけました。少し編集しました。 JInternalFrameのタイトルバーを非表示にしたいJInternalFrameのタイトルバーを隠していますか? -java

JInternalFrame frame = new JInternalFrame(); 
    // Get the title bar and set it to null 
    setRootPaneCheckingEnabled(false); 
    javax.swing.plaf.InternalFrameUI ifu= frame.getUI(); 
    ((javax.swing.plaf.basic.BasicInternalFrameUI)ifu).setNorthPane(null);  

    frame.setLocation(i*50+10, i*50+10); 
    frame.setSize(200, 150); 
    //frame.setBackground(Color.white);  

    frame.setVisible(true); 
    desktop.add(frame); 

問題は、何らかの理由でタイトルバーが非表示になっていないことです。おかげさまで

答えて

11

まず、内部フレームをbasic内部フレームに変換します。これはあなたのタイトルバーが見えなくなります後

BasicInternalFrameUI bi = (BasicInternalFrameUI)your_internalframe_object.getUI(); 
bi.setNorthPane(null); 

- :

はこのようにそれを行います。

10

私はこの問題を次のように解決しました。JInternalFrameをサブクラス化し、そのコンストラクタに次のコードを追加します。

putClientProperty("JInternalFrame.isPalette", Boolean.TRUE); 
    getRootPane().setWindowDecorationStyle(JRootPane.NONE); 
    ((BasicInternalFrameUI) this.getUI()).setNorthPane(null); 
    this.setBorder(null); 

おかげ:あなたのケースで

((javax.swing.plaf.basic.BasicInternalFrameUI)this.getUI()).setNorthPane(null); 

(私はNetBeansのGUIビルダーを使用しているため、私は自由のためのサブクラスを取得します)私は、これは非常にうまく機能し、私のため

+0

これは正しいです。これは.setUI(null)とは異なります。私はまた、特定のイベント(ウィンドウを最小化するような)の後でこれをやり直す必要があるかもしれないと読んでいます。 –

+0

これは正解です。 [frame.setBorder(null); 'と組み合わせて[' JInternalFrame'](https://docs.oracle.com/javase/8/docs/api/javax/swing/JInternalFrame.html)を使うと便利です。 )をトップレベルの['JFrame'](http://docs.oracle.com/javase/8/docs/api/javax/swing/JFrame.html)内のソロコンポーネントとして[' JPanel '](http://docs.oracle.com/javase/8/docs/api/javax/swing/JPanel.html)を参照してください。 – vallismortis

+0

私のために働いた。私も試していないが、魅力のように働く。ありがとうございました。 – George

0

を考えます。

関連する問題