Wednesday, February 27, 2008
Swing Tutorials : Swing Toolbar Example
import javax.swing.*;
import java.awt.*;
public class ToolbarExample{
public static void main(String[] args) {
JFrame frame = new JFrame("Toolbar Example Using Java Swing");
JToolBar toolbar = new JToolBar("toolBar", JToolBar.HORIZONTAL);
JButton cutbutton = new JButton(new ImageIcon("cut.gif"));
toolbar.add(cutbutton);
JButton copybutton = new JButton(new ImageIcon("copy.gif"));
toolbar.add(copybutton);
JButton pastebutton = new JButton(new ImageIcon("paste.gif"));
toolbar.add(pastebutton);
frame.getContentPane().add(toolbar,BorderLayout.NORTH);
frame.setUndecorated(true);
frame.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500,400);
frame.setVisible(true);
}
}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment