Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jsmwoolf

macrumors regular
Original poster
Aug 17, 2011
123
0
I plan on adding a graphing feature on my calculator and I was wondering if I should use plain Window or a JWindow in order to draw graphics(lines, parabolas, circles, hyperbola, etc.). Besides what's the difference between a Window object and a JWindow object?
 
I plan on adding a graphing feature on my calculator and I was wondering if I should use plain Window or a JWindow in order to draw graphics(lines, parabolas, circles, hyperbola, etc.). Besides what's the difference between a Window object and a JWindow object?

java.awt.Window objects are "legacy" from AWT. javax.swing.JWindow objects are from Swing. JWindow is a subclass of Window.

There's no advantage to using a Window over a JWindow anymore. It used to be an advantage in ancient versions of Java which didn't include Swing.

But really, I do think you want a javax.swing.JFrame. It's really rude not to provide the "trimmings", such as a title bar, to at least allow the user to move the window around. A JFrame doesn't necessarily have to be resizable. Just call setResizable(false);
 
But really, I do think you want a javax.swing.JFrame. It's really rude not to provide the "trimmings", such as a title bar, to at least allow the user to move the window around. A JFrame doesn't necessarily have to be resizable. Just call setResizable(false);

Do you mean I should use a JFrame for the window or for drawing graphics(lines, circles, etc.)? Not a JWindow or just Window?
 
Do you mean I should use a JFrame for the window or for drawing graphics(lines, circles, etc.)? Not a JWindow or just Window?

Hmm, I'm confused. Are we talking about a window, a frame, or just a panel?

A window (in Java's sense) is what is commonly called a window by users, but doesn't have the border around it, title bar, etc. A frame (again in Java's sense) is a window with border, title bar, etc. A panel (javax.swing.JPanel) is just a region within a window.
 
Sorry for confusing you. I'm trying to create a little window within a window(much like an NSView from Objective-C/Cocoa). This is where the program would draw graphics such as lines, circles, parabolas, etc.
 
Sorry for confusing you. I'm trying to create a little window within a window(much like an NSView from Objective-C/Cocoa). This is where the program would draw graphics such as lines, circles, parabolas, etc.

In Java, a "window within a window" would be a JPanel. At least in the sense of roughly corresponding to NSView. Another possibility would be JInternalFrame, but I don't think you want to go there.


Some Java chart/graph libraries, from my "frequently pasted URLs" list:

Scientific Graphics Toolkit (SGT) -- plotting & charting (JDK 1.1.8+)
http://www.epic.noaa.gov/java/sgt/

JFreeChart -- LGPL (?)
http://www.jfree.org/jfreechart/index.html

JSci -- scientific math and charting
http://sourceforge.net/projects/jsci
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.