Results 1 to 4 of 4
  1. #1
    Mattedatten is offline Member
    Join Date
    Aug 2009
    Location
    South Sweden
    Posts
    24
    Rep Power
    0

    Default How to use graphics

    Hey all

    Can I get some help how to call a graphics-method?
    I mean, how to make it run in a good way?

    Is there any other way to do this than in an applet?
    Drawing Geometric Primitives (The Java™ Tutorials > 2D Graphics > Working with Geometry)
    ^ I mean this code:
    Java Code:
    public void paint (Graphics g) {
        Graphics2D g2 = (Graphics2D) g;
        ...
    }
    How to call it so it will run? (Ok, the one that i quoted isn't a visible object(?), but if it was, how to run it?)

    Sorry for messy post
    But I'm in school, and this is a lesson where we aren't doing anything ^^
    Still I wouldn't want the teacher to see

    ///M~

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    I have no idea with what you mean by "how to run it". If you mean how would you execute that method, then all I can say is, you don't. That is done by the framework itself (Swing or AWT), when the GUI is drawn. And if you're using Swing, you don't override that method, at all, you override paintComponent.

  3. #3
    Mattedatten is offline Member
    Join Date
    Aug 2009
    Location
    South Sweden
    Posts
    24
    Rep Power
    0

    Default

    Quote Originally Posted by masijade View Post
    I have no idea with what you mean by "how to run it". If you mean how would you execute that method, then all I can say is, you don't. That is done by the framework itself (Swing or AWT), when the GUI is drawn. And if you're using Swing, you don't override that method, at all, you override paintComponent.
    I can say that I do not have any idea what I'm talking about either

    I mean that I want it to draw something, but I have no idea how to do so.

    I do not want to use an applet.

    So my question is simply what options I have and how to make any graphics of the code?

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Well, go through the rest of that tutorial Trail: 2D Graphics (The Java™ Tutorials)

    If it uses Applets the entire time then simply change JApplet to JPanel, wrap it in a JFrame and include the "init" and "start" actions in the main method.

Similar Threads

  1. Help me with graphics
    By 7oclock in forum New To Java
    Replies: 12
    Last Post: 04-04-2009, 11:20 PM
  2. Help with 2d graphics please
    By xbox_nutter in forum New To Java
    Replies: 0
    Last Post: 04-02-2009, 11:48 AM
  3. SWT Graphics Example
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 06-28-2008, 09:28 PM
  4. graphics
    By Joe2003 in forum Advanced Java
    Replies: 4
    Last Post: 01-18-2008, 07:44 PM
  5. Graphics
    By feniger in forum New To Java
    Replies: 1
    Last Post: 12-29-2007, 04:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •