0
import javax.swing.*;
import java.awt.*;

public class CreateToolbar{
	public static void main(String[] args) {
		JFrame frame = new JFrame("Create a toolbar Which have three buttons Such as: Cut, Copy, Paste");
		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);
	}
}

After I execute the above code, there was no build problem. When I run it, everything fine except, the icons was not displayed. Please advice. Thanks.

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by lordx78
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.