Results 1 to 3 of 3
  1. #1
    SajeshBahing is offline Member
    Join Date
    Feb 2012
    Posts
    2
    Rep Power
    0

    Default Guys how to navigate through images

    i wrote the following code...it works fine but now i've got to make JButtons navigate the images...previous and next images...

    Java Code:
    try{
    		int count=0;{
                    //LB is my JList
    		o=LB.getSelectedValue().toString();
    		StringTokenizer st1=new StringTokenizer(o,"+");
    		while(st1.hasMoreTokens()){
    			b=st1.nextToken().toString();
    			count++;
    			if(count==1)
    				ImageIcon image=new ImageIcon(b);
    				//L[2] is one of my label 
    				L[2].setIcon(image);
    				}count=0;
    			}
    		}
    		catch(Exception e){
    			JOptionPane.showMessageDialog(null, "First select an object", "Warning", JOptionPane.WARNING_MESSAGE);
    			}
    what should i do..

    i tried making an array of previously selected values from JLIst but it doesn't seem to work out...Please someone help me.......

    Java Code:
    @Override
    public void valueChanged(ListSelectionEvent e) {
    	
    	if (!e.getValueIsAdjusting()) {
            LB = (JList)e.getSource();
            Object[] selected = LB.getSelectedValues();
            for (int i=0; i<selected.length; i++) {
                String g=selected[i].toString();
            }
    	}
    Last edited by Fubarable; 02-05-2012 at 11:49 PM. Reason: code tags added

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Guys how to navigate through images

    What does any of that code have to do with the problem at hand? And where is the code that in fact is related to the current problem?

  3. #3
    SajeshBahing is offline Member
    Join Date
    Feb 2012
    Posts
    2
    Rep Power
    0

    Default Re: Guys how to navigate through images

    int no=0;
    String [] array=new String[100];

    else if(source==B[5]){
    try{
    int count=0;{
    o=LB.getSelectedValue().toString();
    no++;
    array [no]=o;
    StringTokenizer st1=new StringTokenizer(o,"+");
    while(st1.hasMoreTokens()){
    g=st1.nextToken().toString();
    count++;
    if(count==1)
    image=new ImageIcon(g);
    L[2].setIcon(image);
    }count=0;
    for(int i=1;i<no;i++){
    PrintWriter pw=new PrintWriter(new FileWriter("Log.txt",true),true);
    pw.println(array[no]);
    }
    }
    }

    else if(source==B[8]){
    try{
    --no;
    int count=0;
    StringTokenizer st1=new StringTokenizer(array[no],"+");
    while(st1.hasMoreTokens()){
    b=st1.nextToken().toString();
    count++;
    if(count==1)
    image=new ImageIcon(b);
    L[2].setIcon(image);
    }count=0;
    }
    catch(ArrayIndexOutOfBoundsException ee){

    }
    catch(Exception ee){
    --no;
    }
    }
    else if(source==B[9]){
    try{
    ++no;
    int count=0;
    StringTokenizer st1=new StringTokenizer(array[no],"+");
    while(st1.hasMoreTokens()){
    b=st1.nextToken().toString();
    count++;
    if(count==1)
    image=new ImageIcon(b);
    L[2].setIcon(image);
    }count=0;
    }
    catch(Exception ee){
    ++no;
    }
    }

    Ok what i can't do is, i select the previous or the next button the values keeps decreasing and increasing respectively.
    how to make them stop when images limit are reached...is this much code enough for you to help me...please help me

Similar Threads

  1. setting the tab index and navigate
    By Jennifer Davis in forum NetBeans
    Replies: 0
    Last Post: 10-29-2010, 12:17 PM
  2. Navigate through a multidimensional array
    By VinTiger in forum New To Java
    Replies: 4
    Last Post: 05-05-2009, 07:16 PM
  3. Navigate to behind pages when I am in a wizard
    By Radhikaibm in forum SWT / JFace
    Replies: 2
    Last Post: 09-09-2008, 07:42 AM
  4. [SOLVED] Navigate from a tiles to another page
    By hannehomuth in forum JavaServer Faces (JSF)
    Replies: 1
    Last Post: 09-04-2008, 04:56 PM
  5. [SOLVED] Navigate with Cursor keys
    By hannehomuth in forum Advanced Java
    Replies: 7
    Last Post: 07-25-2008, 12:22 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
  •