1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
import java.awt.BorderLayout;
import javax.swing.*;
public class TestJToolBar {
public static void main (String [] args){
try {
Manager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
JFrame frame = new JFrame();
frame.setSize(400,200);
frame.getContentPane().setLayout(new BorderLayout());
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
JToolBar bar = new JToolBar();
JButton b1 = new JButton(new ImageIcon(TestJToolBar.class.getResource("img1.gif")));
JButton b2 = new JButton(new ImageIcon(TestJToolBar.class.getResource("img2.gif")));
bar.add(b1);
bar.add(b2);
panel.add(bar, BorderLayout.EAST);
frame.getContentPane().add(panel, BorderLayout.NORTH);
frame.setVisible(true);
}
} |
Partager