Results 1 to 3 of 3
Thread: Help
- 01-11-2011, 04:02 AM #1
Member
- Join Date
- Jan 2011
- Posts
- 1
- Rep Power
- 0
Help
I just started learning java swing components. I want to create an event that open a dialog box after you click button to select the files I have. I looked at some examples and they showed this.
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
//This is where a real application would open the file.
log.append("Opening: " + file.getName() + "." + newline);
} else {
log.append("Open command cancelled by user." + newline);
}
log.setCaretPosition(log.getDocument().getLength() );
What does the above means? what does append means? how come when i key in append in my IDE, the word "append" is highlighted in red and couldn't compile.
Secondly, What does the below means?
int returnVal = fc.showOpenDialog(aComponent);
it's just a response to a mouse click right? but when i key into IDE, aComponent, the word "aComponent" is highlighted in red and couldn't compile.
Can anyone tell me how to do to make it compile? I just started java so i have a lot of things that i don't know. Please help. Thanks in advance :)
-
Please read the tutorial on using file choosers: How to Use File Choosers (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
Your error seems to be coming from trying to use a log file that doesn't exist, which you have no need for, and likely is from cutting and pasting code you've found without understanding it. Again, read the tutorial as it will explain what you need to know.
- 01-11-2011, 08:18 AM #3
Considering this
you probably need to start here:when i key into IDE, aComponent, the word "aComponent" is highlighted in red and couldn't compile.
http://download-llnw.oracle.com/javase/tutorial/
db


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks