Results 1 to 3 of 3

Thread: text area

  1. #1
    jumpman8947 is offline Member
    Join Date
    Feb 2013
    Posts
    38
    Rep Power
    0

    Default text area

    I'm trying to create a program where i have an array that holds my image names on a split pane and on the other side of the pane it shows a picture of the selected name.This part of the program works fine but i also have a text area on the frame and what i want it to do is display the text file that pairs with the name selected in the split pane(just like the image). When i run the program the image shows but cmd displays an error message of " java.io.FileNotFoundException: \example.txt <The system cannot find the file specified> The picture of example will show where its supposed to but not the text here is part of my code that deals with this...
    Java Code:
    	public void valueChanged(ListSelectionEvent e)
    	{
    		JList list = (JList)e.getSource();
    		updateLabel(imageNames[list.getSelectedIndex()]);
    
    	}
    	protected void updateLabel (String name)
    	{
    		ImageIcon icon = createImageIcon("/" + name + ".gif");
    		picture.setIcon(icon);
    		if (icon != null)
    		{
    			picture.setText(null);
    		} else {
    			picture.setText("Image not found");
    		}
    		try
    		{
    			FileReader reader = new FileReader("/" + name + ".txt");
    			BufferedReader br = new BufferedReader(reader);
    			fullDes.read( br, null );
    			br.close();
    			fullDes.requestFocus();
    		}
    		catch(Exception e2) {System.out.println(e2); }
    	}
    
    
    
    	protected static ImageIcon createImageIcon(String path)
    	{
    		java.net.URL imgURL = GuideScreen.class.getResource(path);
    		if (imgURL != null)
    		{
    			return new ImageIcon(imgURL);
    		} else {
    			System.err.println("Could't find file: " + path);
    			return null;
    		}
    	}
    (PS fullDes is my textArea).

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

    Default Re: text area

    Also posted at: Text area - Dev Shed
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    jumpman8947 is offline Member
    Join Date
    Feb 2013
    Posts
    38
    Rep Power
    0

    Default Re: text area

    problem fix i simply removed the slash "/" and just kept the quotes empty.

Similar Threads

  1. adding text to a text area dynamically
    By tom2zip in forum AWT / Swing
    Replies: 3
    Last Post: 01-17-2012, 06:58 AM
  2. Replies: 8
    Last Post: 07-17-2011, 03:38 PM
  3. Text Area
    By pabloma2002 in forum CLDC and MIDP
    Replies: 1
    Last Post: 02-11-2011, 05:56 PM
  4. Replies: 0
    Last Post: 12-09-2010, 06:56 PM
  5. Replies: 0
    Last Post: 09-28-2010, 10:52 AM

Posting Permissions

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