Results 1 to 8 of 8

Thread: Shifting components in a JToolBar?

Threaded View

  1. #4
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552
    Pardon my ignorance but what is Shift?

    edit: you mean, invert the order?
    Code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class sample extends JFrame{
        public sample(){
            setTitle("Sample");
            setSize(400,300);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
    
            getContentPane().add(new ToolBar(),BorderLayout.NORTH);
        }
    
        // ToolBar
        class ToolBar extends JToolBar{
            JButton redo=new JButton("Redo",new ImageIcon("left.gif")),
                refresh=new JButton("Refresh",new ImageIcon("middle.gif")),
                help=new JButton("Help",new ImageIcon("right.gif"));
            public ToolBar(){
                setFloatable(false);
    
                redo.setVerticalTextPosition(AbstractButton.BOTTOM);
                redo.setHorizontalTextPosition(AbstractButton.CENTER);
                redo.setToolTipText("Update Database");
    
                refresh.setVerticalTextPosition(AbstractButton.BOTTOM);
                refresh.setHorizontalTextPosition(AbstractButton.CENTER);
                refresh.setToolTipText("Refresh Table");
    
                help.setVerticalTextPosition(AbstractButton.BOTTOM);
                help.setHorizontalTextPosition(AbstractButton.CENTER);
                help.setToolTipText("Help");
    
                //add(redo);
                //add(refresh);
                //add(help);
    
                add(help);
                add(refresh);
                add(redo);
            }
        }
        public static void main(String[] args){
            new sample().show();
        }
    }
    Works fine but dunno if this is what you mean?
    Last edited by brown monkey; Sep 29th, 2004 at 11:29 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width