1. 在JFrame中设置Layout为BorderLayout,把JToolBar加在BorderLayout.NORTH,JToolBar上的图标用16*16的
2. 在BorderLayout.SOUTH中自己的StatusBar,
3. 在BorderLayout.Center中加一个Edit Area,并可以滚动问题是:
1. 但是实际显示的效果是工具栏的高度很高,工具栏的图标只显示在工具栏的中间,而不是像windows中的那样图标正好撑满工具栏
2. 在手动拖动JFrame的四个角时,JFrame的扩大和JToolBar,StatusBar的扩大不是同步的怎样解决上述问题呢
2. 在BorderLayout.SOUTH中自己的StatusBar,
3. 在BorderLayout.Center中加一个Edit Area,并可以滚动问题是:
1. 但是实际显示的效果是工具栏的高度很高,工具栏的图标只显示在工具栏的中间,而不是像windows中的那样图标正好撑满工具栏
2. 在手动拖动JFrame的四个角时,JFrame的扩大和JToolBar,StatusBar的扩大不是同步的怎样解决上述问题呢
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
Toolkit.getDefaultToolkit().setDynamicLayout(true); //***// JToolBar toolbar = new JToolBar();
toolbar.setRollover(true);
JButton button = new JButton(new ImageIcon(T.class.getResource("/imgs/mycomputer.png")));
JButton button2 = new JButton(new ImageIcon(T.class.getResource("/imgs/cancelIcon.png")));
JButton button3 = new JButton(new ImageIcon(T.class.getResource("/imgs/titleIcon.png"))); button.setMargin(new Insets(0,0,0,0)); //***//
button2.setMargin(new Insets(0,0,0,0)); //***//
button3.setMargin(new Insets(0,0,0,0)); //***//
toolbar.add(button);
toolbar.add(button2);
toolbar.add(button3);
JLabel statusBar = new JLabel(" ");
JTextArea ta = new JTextArea();
JScrollPane sp = new JScrollPane(ta);
JFrame f = new JFrame("Test");
f.getContentPane().add(toolbar, BorderLayout.NORTH);
f.getContentPane().add(sp, BorderLayout.CENTER);
f.getContentPane().add(statusBar, BorderLayout.SOUTH);
f.setSize(500, 500);
f.setLocationRelativeTo(null);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
}