Results 1 to 8 of 8
  1. #1
    bkmr is offline Member
    Join Date
    Jun 2011
    Posts
    4
    Rep Power
    0

    Default Connectivity of a JToolbar to the web

    Ive coded a JToolbar and am using eclipse. The construction of the JToolbar is very basic consisting of back and forward JButtons a JCombobox of URLs each associated with an actionListener which ive left blank for the time being as follows

    button.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {



    }
    });

    My problem is how to proceed? How am i supposed to connect this with the web using eclipse?


    Thanks

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,556
    Rep Power
    25

    Default

    What do you want to happen when the action event happens?

    to connect this with the web
    Some where you would use one of the java.net classes: URLConnection for example to connect to a site on the web.

    Sorry I don't know where the IDE fits in.

  3. #3
    bkmr is offline Member
    Join Date
    Jun 2011
    Posts
    4
    Rep Power
    0

    Default

    The JCombobox consists of an arraylist of urls (in a specific order). When i press the back button i want the previous url to be displayed and when i press the forward button i want the next url in the list to be displayed.

    ArrayList<String> al = new ArrayList<String>();
    al.add("http://xyz.com");
    al.add(" http://abc.com");
    al.add("http:// cde.com ");
    al.add("http:// ");
    al.add("http:// ");
    al.add("http:// ");
    al.add( "http:// ");
    al.add( "http:// mno.com");
    String ia[] = new String[al.size()];
    ia = al.toArray(ia);
    JComboBox comboBox = new JComboBox(ia);


    Since my first url will be xyz.com then if I press forward it will have to jump to the next url ie abc.com and previous would give me mno.com, the same continues.

    Im not sure whether my explanation is clear or not but this is where im stuck. I dont know what to include in the actionlistener methods to achieve this. Any suggestions/ideas?

    It might be simple but im still a learner.Sorry for any mistakes,

    Thanks alot for replying.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,404
    Rep Power
    20

    Default

    You say
    The JCombobox consists of an arraylist of urls
    and then post code (next time, use the code tags!) which shows an ArrayList<String>

    See the API for Desktop#browse(...) and the class that is passed as a parameter to that method.

    db

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,556
    Rep Power
    25

    Default

    To be able to move forwards and backwards in a list you will need to remember where in the list you are currently.
    Then if you get a request to move you can change the current location pointer in the direction requested remembering to wrap the pointer at either end of the list.

  6. #6
    bkmr is offline Member
    Join Date
    Jun 2011
    Posts
    4
    Rep Power
    0

    Default

    DarrylBurke Sir/Ma'am, sorry for not using tags, Im new to this and yes i posted the code and i cant seem to understand the problem anyway my apologies. :)

    Norm Sir/Ma'am, Thank you, ive managed to get the forward and backward buttons to work! The only thing im concerned about now is displaying the urls as webpages (as the output to the code) .

  7. #7
    bkmr is offline Member
    Join Date
    Jun 2011
    Posts
    4
    Rep Power
    0

    Default

    Basically the question which i am putting forth is that - If i have a toolbar with me ( a properly designed toolbar ) how am i supposed to connect it with the web? I know its something to do with java.net butall i need is the basic idea (what all to use and what to start with, {a beginner in this area}). Im not able to really find a tutorial on this particular problem. Though there are many tutorials on constructing a basic toolbar. Thanks alot for helping and replying! :-)

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,556
    Rep Power
    25

    Default

    If i have a toolbar .. how am i supposed to connect it with the web
    That statement doesn't make sense to me.
    One way a program "connects" to the web is by sending an HTML GET to a server addressed by a URL and then reading the response from the server.
    The toolbar is a way to select which URL to send.
    Given that definition, what do you want your code to do?

Similar Threads

  1. Iconified JInternalFrame in JToolbar
    By mine0926 in forum New To Java
    Replies: 1
    Last Post: 05-25-2011, 03:36 AM
  2. JToolBar make it non-draggable
    By nathic in forum New To Java
    Replies: 1
    Last Post: 03-22-2011, 08:52 AM
  3. ActionListener for JToolBar components
    By LianaN in forum New To Java
    Replies: 6
    Last Post: 09-18-2010, 01:37 PM
  4. JToolbar: How to unselect first item
    By mjones in forum AWT / Swing
    Replies: 4
    Last Post: 02-19-2010, 02:56 AM
  5. JToolBar movable but not floatable
    By Fosters in forum AWT / Swing
    Replies: 0
    Last Post: 08-22-2008, 03:04 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
  •