Results 1 to 2 of 2
  1. #1
    Grid_iso is offline Member
    Join Date
    May 2011
    Posts
    12
    Rep Power
    0

    Default help making class print in jpanel

    So i have this code called jpanel and I want to use it as a gathering place for all my other classes to work together in, in the game I'm making

    Java Code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    
    public class AJPanel extends JPanel {
    
     	public A3JPanel() {
    		setBackground(Color.white);
    	}
    
       	public void paintComponent(Graphics g){
     	    super.paintComponent(g);
    
    	}
    
    }
    now its pretty bare right now because I deleted all the stuff in it as it didn't work and got messy, basically the first thing I want to do right now is make my background in a class called something like "Background" then get it to be printed out in the paint component. ( don't worry about the jframe, that's already been set and is working fine along with the application file.) So how would I go about doing that?

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,577
    Rep Power
    25

    Default

    get it to be printed out in the paint component.
    I assume you mean you want to display some text in the component?
    For one technique See the Graphics class's draw... methods. You'd use them in the paint... method.

Similar Threads

  1. Help making a grid inside of a JPanel
    By satanfx55 in forum AWT / Swing
    Replies: 3
    Last Post: 05-13-2011, 07:18 PM
  2. I would like to print this JPanel class. How?
    By AcousticBruce in forum New To Java
    Replies: 8
    Last Post: 02-26-2011, 06:25 PM
  3. print multiple jpanel
    By anilkumar_vist in forum New To Java
    Replies: 0
    Last Post: 02-05-2010, 03:28 PM
  4. print jpanel
    By anilkumar_vist in forum New To Java
    Replies: 3
    Last Post: 01-08-2010, 12:08 PM
  5. Making text blink in a JPanel?
    By blackcloud72 in forum New To Java
    Replies: 8
    Last Post: 10-31-2008, 11:24 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
  •