Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Adding a jToolBar to my desktop application

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Adding a jToolBar to my desktop application

    Hello guys, i have problebs adding a toolbar to my main jframe and i want you to help me. The code is as follows:


    import java.io.*;
    import javax.swing.*;
    import javax.swing.JToolBar;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    import javax.swing.Timer;
    //import javax.swing.util.*;
    //import javax.swing.JPasswordField;

    public class UIJBHotelMainGui extends JFrame
    {
    //ATTRIBUTES
    private JButton checkInJButton,checkOutJButton,bookingJButton,view JButton,managementJButton,securityJButton,reportJB utton,logoutJButton;
    private Container container;





    public UIJBHotelMainGui()
    {
    super("UIJBHotel");
    MainWindowGui();
    }



    public void MainWindowGui()
    {
    //Long startTime = System.currentTimeMillis();
    JFrame mainFrame = new JFrame("uijbHotel");
    mainFrame.setSize(500,400);
    mainFrame.setLocation(100,50);
    mainFrame.setVisible(true);

    JMenuBar mainMenuBar = new JMenuBar();
    mainFrame.setJMenuBar(mainMenuBar);

    JMenu fileMenu = new JMenu("File");
    JMenu helpMenu = new JMenu("Help");
    mainMenuBar.add(fileMenu);
    mainMenuBar.add(helpMenu);
    fileMenu.add(new JMenuItem("Check In"));

    fileMenu.addSeparator();
    fileMenu.add(new JMenuItem("Check Out"));
    fileMenu.addSeparator();
    fileMenu.add(new JMenuItem("View"));
    fileMenu.addSeparator();
    fileMenu.add(new JMenuItem("Bookin"));
    fileMenu.addSeparator();
    fileMenu.add(new JMenuItem("Management"));
    fileMenu.addSeparator();
    fileMenu.add(new JMenuItem("Security"));
    fileMenu.addSeparator();
    fileMenu.add(new JMenuItem("Report"));
    fileMenu.addSeparator();
    fileMenu.add(new JMenuItem("Logout"));
    fileMenu.addSeparator();


    helpMenu.add(new JMenuItem("View Help"));
    helpMenu.addSeparator();
    helpMenu.add(new JMenuItem("About"));





    }//end of mainwindowfui

    public static void main (String args[])
    {
    UIJBHotelMainGui ustaz = new UIJBHotelMainGui();
    ustaz.setDefaultCloseOperation(EXIT_ON_CLOSE);

    }//end of main


    }//end of class UIJBHotelMainGui


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Adding a jToolBar to my desktop application

    Quote Originally Posted by uijbaba View Post
    Hello guys, i have problebs adding a toolbar to my main jframe and i want you to help me.
    I think that you will want to tell us what problems you're having, else we have to guess, and we're notoriously bad at doing that.

    The code is as follows:...
    Next time, please use [code=java] [/code] tags so that your posted code is readable. For example:

    import java.io.*;
    import javax.swing.*;
    import javax.swing.JToolBar;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    import javax.swing.Timer;
    //import javax.swing.util.*;
    //import javax.swing.JPasswordField;
     
    public class UIJBHotelMainGui extends JFrame
     {
    		//ATTRIBUTES
    		private JButton checkInJButton,checkOutJButton,bookingJButton,viewJButton,managementJButton,securityJButton,reportJButton,logoutJButton;
    		private Container container;
     
     
     
     
     
    		public UIJBHotelMainGui()
    		{
    		super("UIJBHotel");
    		MainWindowGui();	
    		}
     
     
     
     public void MainWindowGui()
       {
       	//Long startTime = System.currentTimeMillis();
       	 JFrame mainFrame = new JFrame("uijbHotel");
       	mainFrame.setSize(500,400);
       	mainFrame.setLocation(100,50);
       	mainFrame.setVisible(true);
     
       	JMenuBar mainMenuBar = new JMenuBar();
       	mainFrame.setJMenuBar(mainMenuBar);
     
       	JMenu fileMenu = new JMenu("File");
       	JMenu helpMenu = new JMenu("Help");
       	mainMenuBar.add(fileMenu);
       	mainMenuBar.add(helpMenu);
       	fileMenu.add(new JMenuItem("Check In"));
     
       	fileMenu.addSeparator();
       	fileMenu.add(new JMenuItem("Check Out"));
       	fileMenu.addSeparator();
       	fileMenu.add(new JMenuItem("View"));
            fileMenu.addSeparator();
            fileMenu.add(new JMenuItem("Bookin"));
       	fileMenu.addSeparator();
            fileMenu.add(new JMenuItem("Management"));
       	fileMenu.addSeparator();
            fileMenu.add(new JMenuItem("Security"));
       	fileMenu.addSeparator();
            fileMenu.add(new JMenuItem("Report"));
       	fileMenu.addSeparator();
            fileMenu.add(new JMenuItem("Logout"));
       	fileMenu.addSeparator();
     
     
            helpMenu.add(new JMenuItem("View Help"));
       	helpMenu.addSeparator();
            helpMenu.add(new JMenuItem("About"));
     
     
     
     
     
       	}//end of mainwindowfui
     
    	public static void main (String args[])
    		{
    			UIJBHotelMainGui ustaz = new UIJBHotelMainGui();
    		ustaz.setDefaultCloseOperation(EXIT_ON_CLOSE);
     
    		}//end of main
     
     
    	}//end of class UIJBHotelMainGui

    Edit: on review of your code, I don't see anywhere where you've tried to add the JToolBar. It will be hard to guess what you're doing wrong if you don't show us your attempt.
    Last edited by curmudgeon; September 29th, 2012 at 05:26 PM.

  3. #3
    Junior Member
    Join Date
    Sep 2012
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Adding a jToolBar to my desktop application

    Quote Originally Posted by curmudgeon View Post
    I think that you will want to tell us what problems you're having, else we have to guess, and we're notoriously bad at doing that.



    Next time, please use [code=java] [/code] tags so that your posted code is readable. For example:

    import java.io.*;
    import javax.swing.*;
    import javax.swing.JToolBar;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    import javax.swing.Timer;
    //import javax.swing.util.*;
    //import javax.swing.JPasswordField;
     
    public class UIJBHotelMainGui extends JFrame
     {
    		//ATTRIBUTES
    		private JButton checkInJButton,checkOutJButton,bookingJButton,viewJButton,managementJButton,securityJButton,reportJButton,logoutJButton;
    		private Container container;
     
     
     
     
     
    		public UIJBHotelMainGui()
    		{
    		super("UIJBHotel");
    		MainWindowGui();	
    		}
     
     
     
     public void MainWindowGui()
       {
       	//Long startTime = System.currentTimeMillis();
       	 JFrame mainFrame = new JFrame("uijbHotel");
       	mainFrame.setSize(500,400);
       	mainFrame.setLocation(100,50);
       	mainFrame.setVisible(true);
     
       	JMenuBar mainMenuBar = new JMenuBar();
       	mainFrame.setJMenuBar(mainMenuBar);
     
       	JMenu fileMenu = new JMenu("File");
       	JMenu helpMenu = new JMenu("Help");
       	mainMenuBar.add(fileMenu);
       	mainMenuBar.add(helpMenu);
       	fileMenu.add(new JMenuItem("Check In"));
     
       	fileMenu.addSeparator();
       	fileMenu.add(new JMenuItem("Check Out"));
       	fileMenu.addSeparator();
       	fileMenu.add(new JMenuItem("View"));
            fileMenu.addSeparator();
            fileMenu.add(new JMenuItem("Bookin"));
       	fileMenu.addSeparator();
            fileMenu.add(new JMenuItem("Management"));
       	fileMenu.addSeparator();
            fileMenu.add(new JMenuItem("Security"));
       	fileMenu.addSeparator();
            fileMenu.add(new JMenuItem("Report"));
       	fileMenu.addSeparator();
            fileMenu.add(new JMenuItem("Logout"));
       	fileMenu.addSeparator();
     
     
            helpMenu.add(new JMenuItem("View Help"));
       	helpMenu.addSeparator();
            helpMenu.add(new JMenuItem("About"));
     
     
     
     
     
       	}//end of mainwindowfui
     
    	public static void main (String args[])
    		{
    			UIJBHotelMainGui ustaz = new UIJBHotelMainGui();
    		ustaz.setDefaultCloseOperation(EXIT_ON_CLOSE);
     
    		}//end of main
     
     
    	}//end of class UIJBHotelMainGui

    Edit: on review of your code, I don't see anywhere where you've tried to add the JToolBar. It will be hard to guess what you're doing wrong if you don't show us your attempt.



    my problem is that i do not know how to add the toolbar given this code. kindly give me some idea so that i will try it and see.
    thank you.

  4. #4
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Adding a jToolBar to my desktop application

    Quote Originally Posted by uijbaba View Post
    my problem is that i do not know how to add the toolbar given this code. kindly give me some idea so that i will try it and see.
    thank you.
    If this were my project, the first place I'd start would be to look at the Swing tutorials: How to use Tool Bars. Please have a look as it contains great explanations and sample code. Learning from these tutorials is an acquired skill, and so the more you do this, the better they'll become for you.

Similar Threads

  1. Netbean Desktop Application Help!!
    By flyto9 in forum Java Theory & Questions
    Replies: 2
    Last Post: June 30th, 2011, 05:52 PM
  2. Remote Desktop Application
    By Drango in forum Java ME (Mobile Edition)
    Replies: 3
    Last Post: January 24th, 2011, 07:01 AM
  3. Replies: 0
    Last Post: December 3rd, 2009, 03:43 PM
  4. SQLite and Desktop Application
    By urosz in forum JDBC & Databases
    Replies: 12
    Last Post: November 2nd, 2009, 02:50 AM
  5. Desktop Database Application
    By TCoomer in forum JDBC & Databases
    Replies: 2
    Last Post: June 4th, 2009, 03:51 PM