Results 1 to 3 of 3
  1. #1
    koddy is offline Member
    Join Date
    Apr 2010
    Posts
    20
    Rep Power
    0

    Default paint and repaint problem

    Hallo,

    I use Netbeans 6.5 and just to make simple, I made a GUI with Netbeans GUI Builder.
    Say that I have made a JFrame with a JPanel. And I want to draw the graph in this JPanel.

    In JPanel "ProfilPanelLinks" I have add this methode:
    Java Code:
        private void gambar(Graphics g){
            ProfilPanelLinks.add(dataModel);
            dataModel.doDraw(g);
            ProfilPanelLinks.repaint();
        }
    and the class for another is:

    Java Code:
    public class EvaluateDataModel {
    
        private EvaluateDrawing draw;
    
        protected EvaluateDataModel(){
            draw = new EvaluateDrawing();
        }
        
        public void doDraw(Graphics g)
        {
            draw.draw(g);
        }
    }
    Java Code:
    public class EvaluateDrawing extends JPanel {
    
          public void draw(Graphics g)
        {
            Graphics2D g2d = (Graphics2D)g;
            super.paint(g2d);
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g2d.setStroke(new BasicStroke(1));
            g2d.setColor(Color.blue);
            g2d.drawLine(0, 0, 100, 100);
        }
    }
    There are 2 classes, yes, since this is just a cut from a long class. I need to paint at least 6 more graph from another ArrayList. But it won´t draw just a simple line.
    Can anyone help me, how can I draw it with netbeans panel?

    Thank you very much.

  2. #2
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    5

    Default

    This is not really a NetBeans issue but a how to draw graphics in Swing issue, and I think that your best bet is to go to the Sun Java tutorials and check out the tutorials that cover this. There's a bit to learn, but it is all worthwhile.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default

    Also, making a GUI with Netbeans GUI Builder makes things more complicated, not simpler.

    db

Similar Threads

  1. Problem with repaint();
    By dunafrothint in forum AWT / Swing
    Replies: 8
    Last Post: 01-07-2010, 12:33 AM
  2. Repaint problem
    By citizenXL in forum New To Java
    Replies: 4
    Last Post: 10-28-2009, 03:02 PM
  3. other than paint repaint
    By amith in forum Java 2D
    Replies: 1
    Last Post: 07-01-2008, 11:39 PM
  4. Repaint problem
    By swimberl in forum Java 2D
    Replies: 1
    Last Post: 02-16-2008, 09:12 PM
  5. Repaint problem
    By swimberl in forum Java 2D
    Replies: 0
    Last Post: 01-06-2008, 03:28 AM

Tags for this Thread

Posting Permissions

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