Nimbus
ルックアンドフィールで発生している次のレイアウトの問題の回避策を誰かが思い付くことができるかどうか疑問に思っています。
JToolBar
問題は、レイアウトマネージャがの幅を正しく考慮していないため、ツールバーのボタンが表示されないことJTextField
です。ルックアンドフィールはこのMetal
バグを示していないようです。
import java.awt.*;
import javax.swing.*;
public class TextFieldTest extends JFrame
{
public TextFieldTest()
{
// Create the text field
JTextField textField = new JTextField( 20 )
{
@Override
public Dimension getMaximumSize()
{
return super.getPreferredSize();
}
};
// Create the tool bar
JToolBar toolBar = new JToolBar();
toolBar.add( textField );
toolBar.add( Box.createHorizontalGlue() );
toolBar.add( new JButton( "Button" ) );
// Layout the frame
getContentPane().setLayout( new BorderLayout() );
getContentPane().add( toolBar, BorderLayout.NORTH );
setPreferredSize( new Dimension( 800, 600 ) );
pack();
}
public static void main( String[] args )
{
SwingUtilities.invokeLater( new Runnable()
{
public void run()
{
TextFieldTest test = new TextFieldTest();
test.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
test.setVisible( true );
}
} );
}
}
任意の提案をいただければ幸いです。