Results 1 to 7 of 7

Thread: How to create Tool Bar Buttons in Java?

  1. #1
    Join Date
    Jul 2006
    Posts
    273

    How to create Tool Bar Buttons in Java?

    Hi friends,
    I am recently started doing Java. I have done some basic programs and recently started doing the forms. I have created a tool bar somehow, but now I want to create a buttons on that tool bar. I have tried doing lot of different coding but was not successful. So please help me by telling how to create Tool Bar Buttons in Java.?? Help me as soon as possible. !!
    (\__/)
    (='.'=) This is Bunny. Copy and paste bunny into your
    (")_(") signatureto help him gain world domination

  2. #2
    Join Date
    Nov 2008
    Posts
    996

    Re: How to create Tool Bar Buttons in Java?

    You should know about the basic concepts that are needed to use create a tool bar in Java. So i thought that providing you with an information about the concepts would be useful. For creating a tool bar you can use the JToolBar. A JToolBar is a container that groups several components. The components that are grouped usually contains buttons with an icons. You can create that buttons or icons into row or a column. Tool bars are used for an easy access to functionality.

  3. #3
    Join Date
    Nov 2008
    Posts
    1,192

    Re: How to create Tool Bar Buttons in Java?

    You should know that the user can drag the tool bar to another edge of its container by default. Also when you want the drag behavior to work properly, then you must place a tool bar into a container that uses layout manager as BorderLayout. You will also keep in mind that the component should be placed at the center which affects the tool bar. Also there must be not any other component in the container except the tool bar and it must not be in the center.

  4. #4
    Join Date
    Mar 2008
    Posts
    349

    Re: How to create Tool Bar Buttons in Java?

    You can use an images in the tool bar. You can also insert the buttons in the tool bar which are the JButton instances. This instances also use an images from the Feel Graphics Repository. The following is a sample of teh coding that creates the buttons and adds them to the tool bar.
    Code:
    protected void addButtons(JToolBar toolBar) {
        JButton button = null;
    
        button = makeNavigationButton("Previous", PREVIOUS,
                                      "go to previous page",
                                      "Previous");
        toolBar.add(button);
    
        button = makeNavigationButton("Next", NEXT,
                                      "go to next page",
                                      "Next");
        toolBar.add(button);
    
    }
    
    protected JButton makeNavigationButton(String imageName,
                                           String actionCommand,
                                           String toolTipText,
                                           String altText) {
        String imgLocation = "images/"
                             + imageName
                             + ".gif";
        URL imageURL = ToolBarDemo.class.getResource(imgLocation);
    
        JButton button = new JButton();
        button.setActionCommand(actionCommand);
        button.setToolTipText(toolTipText);
        button.addActionListener(this);
    
        if (imageURL != null) {                      
            button.setIcon(new ImageIcon(imageURL, altText));
        } else {                                    
            button.setText(altText);
            System.err.println("Resource not found: " + imgLocation);
        }
    
        return button;
    }

  5. #5
    Join Date
    Mar 2008
    Posts
    672

    Re: How to create Tool Bar Buttons in Java?

    You can also customize the tool bar in Java. I have provided you with some of the lines that you can use in your coding for customizing Tool Bars. So just check the following lines :
    1. You can use setRollover(true) in your coding to visually indicate tool bar buttons when the user passes over them with the cursor.
    2. Then you can also add a separator to a tool bar.
    3. If you want your tool bar to be immovable, then you can use setFloatable(false) in your coding.
    4. You can also add a non-button component to a tool bar.

  6. #6
    Join Date
    Oct 2005
    Posts
    2,393

    Re: How to create Tool Bar Buttons in Java?

    Using of the proper constructors and methods are very important in Java. I have tried to provide you all the constructors and methods that is commonly used by the JToolBar.
    1. For creating a tool bar you can use the following constructors or methods :
      • JToolBar()
      • JToolBar(int)
      • JToolBar(String)
      • JToolBar(String, int)
    2. If you want to add a separator to the end of the tool bar, you can use
      • void addSeparator()
    3. If you want to add a component to the tool bar, you can use method
      • Component add(Component)

  7. #7
    Seoconsultant786 Guest

    Re: How to create Tool Bar Buttons in Java?

    These is way to make in java bar button in it.I am doing work on this thing and i will tell you soon.

Similar Threads

  1. Create voting buttons to messages in Outlook
    By Computer_Freak in forum Tips & Tweaks
    Replies: 3
    Last Post: 03-01-2014, 04:37 PM
  2. Replies: 6
    Last Post: 11-08-2011, 10:52 AM
  3. Publish tool for Java JMS load test
    By Sheravat in forum Software Development
    Replies: 9
    Last Post: 18-09-2010, 10:00 PM
  4. Java me sdk tool 3.0 emulator isn't working
    By Rivan in forum Software Development
    Replies: 5
    Last Post: 16-07-2010, 02:04 AM
  5. Need Java Removal Tool for the Windows
    By rooki in forum Windows Software
    Replies: 5
    Last Post: 10-02-2010, 02:11 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,551,805.48052 seconds with 16 queries