Jump to content

How to open file using Jbutton ?

- - - - -

  • Please log in to reply
7 replies to this topic

#1
xxxxjayxxx

xxxxjayxxx

    Programmer

  • Members
  • PipPipPipPip
  • 123 posts
How can open a file using Jbutton ... means that when i click a certain buttion a library will pop up and let you select your files ..

#2
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
You need the JFileChooser

JFileChooser fc = new JFileChooser();

fc.showOpenDialog(null);

File file= chooser.getSelectedFile();



#3
xxxxjayxxx

xxxxjayxxx

    Programmer

  • Members
  • PipPipPipPip
  • 123 posts

wim DC said:

You need the JFileChooser

JFileChooser fc = new JFileChooser();

fc.showOpenDialog(null);

File file= chooser.getSelectedFile();


Ok thx .. the library open up :) but when i select the file to open there's an error ..

#4
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
which error?

#5
xxxxjayxxx

xxxxjayxxx

    Programmer

  • Members
  • PipPipPipPip
  • 123 posts

wim DC said:

which error?

sorry I mean i cant open the file i want .. Sorry I'm new to java .. :(
here's a screenshot of the error :

Posted Image

#6
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
Actually the first 2-3 lines of the error are usually the most important, and those just didn't make the screenshot :)

#7
xxxxjayxxx

xxxxjayxxx

    Programmer

  • Members
  • PipPipPipPip
  • 123 posts
does that mean that if i solve the 1st 3 line of the error the problem will be solve ?

#8
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
This problem, yes. All those lines are only 1 error.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users