Jonathan Glass

Greenhorn
+ Follow
since Jan 23, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Jonathan Glass

Hi -

I'm designing an app with cross-platform look and feel. Does anyone know how to design forms with the Netbeans GUI Builder so that the components such as buttons display on the form with cross-platform (i.e. Metal or Ocean) look and feel? I have a Windows XP machine with Netbeans 5.5.1 and the updated GUI Builder module installed. If I drag a button onto a frame, it looks like a flat grey Windows button. If I press the preview design button, I see the same. If I right click the Frame icon at the bottom left, I can click Design Preview / Metal and see a proper preview in Metal, which can have different spacing etc. than Windows. However, I don't want to have to preview the Metal look and feel - it would be much easier to have it WYSIWYG right as I build the GUI.

I even tried changing the NetBeans configuration file so that the look and feel of NetBeans became METAL. The look of NetBeans certainly changed, but components dragged onto forms still have the Windows feel. The problem is that there's a lot of trial and error getting the GUI to look good under the cross platform look and feel. Any suggestions?

Along the same lines: I just want my GUIs to look good and have proper spacing regardless of whether run on a Mac, PC, or UNIX machine. Do you think I'll get the best results with cross platform look and feel, or is it safer to request the native look and feel of each system? Maybe I'm missing something but so far it seems like a most imperfect tradeoff. Using cross-platform, for example, tables show gridlines on PCs but no gridlines on Macs. Any color button other than default looks defective on Macs and flat (as opposed to gradated) on my PC. I call for cross platform look and feel in the first line of main() so I think I've set this up correctly, but I don't have much experience with GUI building...

Thanks,

Jonathan Glass
[ August 20, 2007: Message edited by: Jonathan Glass ]
17 years ago
Ernest - Thanks for your feedback. I actually looked with interest at JESS after you replied to a different post of mine the other day. I've only been programming in Java for about six months. I know nothing of "rules-based" or "expert" systems, but the name "rule-based" intrigued me because the nature of my program is that the user writes rules to test trading systems over very detailed (i.e. second by second) historical price data of all sorts of financial instruments. Reading George Rudolph's piece on your site made me think that I should know what my specific need for JESS would be (besides the problem delineated in my latest post) before diverting my attention from Java itself which I'm just learning. I'll keep it in mind for down the road.
17 years ago
Here's what I'm trying to do. I have a program which runs tests on lots of historical price data. The big testing program is in one package, and a second package contains one class per test (each class defines the rules of a separate test). The program runs and writes the test results for the specified test class to a text file; in the file are various sorts of quantitative results of the the test. The text results file also contains the name of the class tested (which I obtain via reflection) and the values of parameters used for testing, etc. Typically the user than modifies the test class a little and runs the test again, and repeats this process many times. I thought it would be nice for each test results file to have the complete code of the testing algorithm printed at the bottom so there would be a very clear permanant record of exactly which test the results represent. I looked in the java reflection package but could only find ways of outputting method names and signatures but not the actual method code. I see what you mean, Ernest - the .class files don't contain source code, so how can one expect the program to output the source code?

There's a limit to how many hoops I'm willing to jump through to get this to work. For example I know there are programs that reverse engineer compiled code to produce source code, but I don't think I'd want to go there. As it is I keep the source files, and the text files with the test results provide reference to those source files (because they output the name of the class) so they can be looked up. It seems the user will have to rename each test class each time, though, in order to keep a discrete record of each test unless the source code can be stored elsewhere, e.g. in the results file. If anyone has a fairly simple solution, great; otherwise I'll have to make due.

Thanks for your consideration.

Jonathan
17 years ago
Hi -
Does anyone know how I can create a method which returns a String or StringBuilder object containing the code from a class? For example:



The output of this program would simply be a text string (with appropriate newline characters) which contains the text code of the class.

Thanks,

Jonathan Glass
[ July 25, 2007: Message edited by: Jonathan Glass ]
17 years ago
Thanks Ernest for taking the time to respond so clearly and promptly (not to mention humoursly). I see I have to get in the habit of passing needed info along to methods and instances instead of sticking info up in the sky (i.e. in global variables) for everyone to see.
Jonathan
17 years ago
Ernest - Thanks so much for what I now see was a very prompt reply! I wasn't on Java Ranch until today since the day of my post, and I thought I would get an email notifications of replies (I must have forgotten to check the box). Going forward I'll log a bit after posting.

By "process" I mean another thread of the program or any method running that can't refer to a particular class instance (like duck1 in my example). I recently moved from procedural to OOP programming, and I keep feeling I need to make my class members static so that I can get at them directly from anywhere. Indeed the application I am developing uses threads and various kinds of composition / delegation, and I often find myself writing methods which need to access values which have been set in variables in other classes. I feel like I'm not harnessing the power of OOP by creating so many static members, but the scope of instance variables seems limiting. Rereading my post a month later, I sense it may not have a specific answer, and I think I need to ponder this more before I can even better-form the question. If anyone happens to have a quick idea of what might be helpful for me to do or ask myself, that would be appreciated, but I may need to work through my issue more in order to solve or better phrase my problem.

Thanks,
Jonathan
17 years ago
Hi - I wonder if anyone can provide some guidance on the following.

After instantiating an object I can't figure out how to make the object visible to a separate process. For example:


Now if there's another process that wants to see how much duck1 weighs, it can't even though class Duck is public and duck.getWeight is coderanch. Only the instantiating method (DuckWorld.main in this case) has access to duck1 and its members. One could use a static object instead, e.g.:


Now any process out there can view and/or manipulate DuckWorld.staticDuck1 and can even import static DuckWorld.* to avoid using the DuckWorld qualifier. This is not the solution I'm looking for, though, because we had to know to how many ducks would be created when we made the class; what if the number of ducks created is determined dynamically by the user at runtime?
So the question is, what can you do if you want process B to view and/or manipulate objects created dynamically by process A?
17 years ago

Hi - I'm using NetBeans 5.5 and in my Java program am loading a few arrays into memory which total around 70MB. At a point a I get an OutOfMemoryError regarding the heap space. I have a Windows XP machine with 1GB RAM. It seems that the logical solution is to increase the initial and maximum heap memory; NetBeans documention seems to instruct one to do this using the flags -J-Xms128m -J-Xmx256m (to make the initial and maximum memory 128MB and 256 MB, respectively) either a) after netbeans.exe if launched from the terminal window or b) in a line of the netbeans.conf file if launched from a shortcut (netbeans_default_options="-J-Xms128m -J-Xmx256m).

Anyway I've tried this many times both ways and it seems that it has no effect. Using Runtime.getRuntime().freeMemory()
and
ManagementFactory.getMemoryMXBean methods in my program, I see that the total memory stays at 65,769,472, the initial heap memory is zero, and the max heap memory is 66,650,112 no matter how I start Netbeans. I can't seem to get the heap to be as large as I need. I don't believe I have any large background programs running, and the Windows Task Manager seems to show a lot of available memory (e.g. over 400MB Available Physical Memory - I don't know why it's not even more but this sounds ample).

Any suggestions? One thing I tried was to allow for no paging file under Control Panel/System/Advanced/Performance/Settings/Advanced, but this made no difference and I was surprised that after rebooting the "PF Usage" on the Task Manager Performance tab shows about 514MB. I don't know whether this is relevant to the problem; generally it seems I should be able to load 70MB of data into memory given my 1GB of RAM.

Thanks for reading this.

Jonathan Glass
Hi -
I'm pretty new to NetBeans and Java, and I'm writing a fairly complex desktop application with no other coders helping. For "versioning," I made a folder in my Project folder called PackageBackups. To back up my work, I frequently go to the Folder view window in Netbeans, copy the package folder I'm working on from the src directory of my Project folder, and paste it in the PackageBackups folder giving it a name with a date and version number. Then when I need to revert to a previous version, I delete classes (or the whole package) from my src directory and paste in the older classes or package from the appropriate backup directory containing the previous version.

I suspect there are pitfalls to this methodology and that there is a better way. I see that there is CVS which is integrated into NetBeans and seems somewhat complicated and I need a "repository," etc. Should I by all means learn CVS, or might that be overkill? Is there an intermediate sort of version control tool or method I might use instead? I've been known to copy and paste code into Word files to use their Compare Documents feature to see what I've changed from a previous version. NetBeans and/or CVS seems to have such a feature... What would you recommend for a versioning solution?!

Thanks,
Jonathan Glass
Thanks so much for the guidance!!
18 years ago
Hi - I'm designing a desktop application which displays data in a table (like a spreadsheet). I would like the user to be able to type java source code for a method in a text box and click on a button to compile it. If it doesn't compile, I'd like the user to see a compilation error, but if it does compile it will be used by the program as a formula for a new column in the table. I don't have an idea about how I can have my program take text input and convert it to source code... any suggestions or resources I might consult for this?

A connected issue which I imagine will be doable once I figure out the above is that I'd then like to design a simple pseudocode which the user will type instead of real java code, and my program will translate this into real code which will be compiled and incorporated into the program...

Any pointers will be much appreciated.
Thanks,

Jonathan Glass
18 years ago