text area
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: text area

Hybrid View

  1. #1
    Join Date
    Feb 2013
    Posts
    22

    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...
    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
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,397

    Re: text area

    Norm

  3. #3
    Join Date
    Feb 2013
    Posts
    22

    Re: text area

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

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center