Java A window within a JFrame

Discussion in 'Mac Programming' started by jsmwoolf, Aug 30, 2011.

  1. jsmwoolf macrumors regular

    Joined:
    Aug 17, 2011
    #1
    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?
     
  2. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #2
    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);
     
  3. jsmwoolf thread starter macrumors regular

    Joined:
    Aug 17, 2011
    #3
    Do you mean I should use a JFrame for the window or for drawing graphics(lines, circles, etc.)? Not a JWindow or just Window?
     
  4. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #4
    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.
     
  5. jsmwoolf thread starter macrumors regular

    Joined:
    Aug 17, 2011
    #5
    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.
     
  6. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #6
    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
     

Share This Page