Charles Bell
Posts: 519
Nickname: charles
Registered: Feb, 2002
|
|
Re: How to set the icon of the frame create by float JToolbar
|
Posted: Jul 1, 2002 9:48 AM
|
|
/* FloatingToolBar.java * @author: Charles Bell * @version: July 1, 2002 */
import java.awt.*; import javax.swing.*;
/* */ public class FloatingToolBar extends JFrame{ public FloatingToolBar(){ super("FloatingToolBar"); init(); } public static void main(String[] args){ new FloatingToolBar(); } public void init(){ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setIconImage(new ImageIcon("earth.jpg").getImage()); JToolBar toolbar = new JToolBar("Floating Tool Bar", SwingConstants.HORIZONTAL); toolbar.setFloatable(true); toolbar.add(new JLabel(new ImageIcon(getIconImage().getScaledInstance(25,25,Image.SCALE_DEFAULT)))); toolbar.add(new JButton("Dummy")); getContentPane().add(toolbar,BorderLayout.NORTH); JTextArea display = new JTextArea(20,50); JScrollPane scrollpane = new JScrollPane(display); getContentPane().add(scrollpane,BorderLayout.CENTER); pack(); setLocationRelativeTo(null); show(); } }
|
|