Adam Cripps

Ranch Hand
+ Follow
since Oct 01, 2011
Adam likes ...
Eclipse IDE Ubuntu Linux
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Adam Cripps

Mansukhdeep Thind wrote:I too use Windows 7. Can you show me the whole code? I would like to debug and see what does it do.



PM coming your way. Although I thought I would debug it, but nothing really shows up on the console about any errors setting preferences.
10 years ago
I have a simple application that I wrote to help me write reports. Recently at work I have been given a windows 7 machine. My application ran fine under windows xp but under windows 7 it fails to set preferences when the application closes.

I'm using these snippets of code to read and write preferences:



then later on...



to check if it has already been set and then take the necessary action if it is (read in and write).

The on exit, I write with this:



When I run the application, there is nothing on the command line that reports that there is a problem writing the preferences file (I was thinking there might be a permissions problem). Is this a known thing with Windows 7? What else can I do to debug the application? As I said earlier, my code is fine on linux/windows xp machines - it just seems to be this windows 7 setup.

TIA
Adam
10 years ago
Thanks Winston. That gives as output when run - which supports my initial guess (I'm not handling the correct version of jreport). Am I correct in thinking that if I pass the jreport instance to the constructor and that with the declaration at the beginning of the class (JReport jreport;) that the whole class should be able to see jreport?
12 years ago
I want to save some preferences when the user closes the JFrame. I've implemented the WindowEvent to pick this up and set setDefaultCloseOperation(JFrame.DO_NOTHING). I'm calling the applications variable prefs.flush() which is giving the NullPointerException. I'm guessing that the nullpointerexception is thrown because I'm not actually handling the instance of jreport.prefs that I think I am. I would like some help finding out where I'm going wrong with handling the jreport.prefs instance. I declare JReport jreport in JReportFrame (which is instantiated by JReport). And I pass the object of JReport when calling JReportFrame:


and the JReportFrame constructor that receives this:


TIA
Adam
12 years ago
Rob - many thanks - that was exactly the problem (the file and filename clash).
12 years ago
I want my app to store the last used file so that the next time the user opens up the application the file is loaded automatically.

I'm using Preferences to store this. However, when I store the filename, it seems to save the swing widget instead, which means I get an error when the application loads next time.

Code to save the filename:





Code in the constructor trying to load the filename:



The error I get when the code runs:



Any ideas gratefully received.
TIA
Adam
12 years ago
The proverbial "D'Oh!" - many thanks.
12 years ago
Thanks.

tabbedPane has an instance which has tabs - am I thinking that this doesn't work correctly? This is how I set the constructor up:

12 years ago
I've got a small method which I want to iterate through a JTabbedPane and String [] to set the title:



However, with this I get the error NullPointerException:



Line 43 is the tabbedPane.setTitleAt - the tabbedPane is there and it has 11 tabs - so why would I get NullPointerException?
TIA
Adam
12 years ago
Thanks Winston. However, I will need to iterate through the file - how do I knit the two iterations together?
12 years ago
Thanks Randall - you are correct. The BufferedReader is to handle the text file and go through the file line by line. I already have managed to access the JTextFields through set and get, so that part of the problem is sorted - it's reading the file line by line that I really need help with. Thanks.
12 years ago
I have a scenario where I have an Array of CurriculumSubject objects (which in turn has creted 15 JTextField object instances) and then a text file.

I want to iterate through the CurriculumSubject Array (and each JTextField for each subject) and go through the text file line by line, setting each JTextField to one line - and then move on to the next.

Currently, I have this method which receives a File object:



How can I integrate a BufferedReader in to this so that as I move through the 15 JTextFields, the BufferedReader reads the next line of the file?

TIA
Adam
12 years ago
OK. This must be an eclipse weirdness, as I moved all my .java files to a temporary directory - recompiled and it's working as it should.
Thanks.
12 years ago
I do have a console, as the Save section of the actionPerformed reports that save is called - that's why this is weird behaviour.
12 years ago
@Paul Clapham, I guess I'm confused about what code has run as none of the expected code shows in the console (e.g. System.out.println("open called. ");) - however, JFileChoosers do open as does the JOptionPane which shows the about. Without System.out.println showing to console, I'm finding it difficult to debug.
12 years ago