Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #1260

Re: implementing paint

From "Oliver Wong" <oliver.wong@THRWHITE.remove-dii-this>
Subject Re: implementing paint
Message-ID <7ugMh.57206$Zb.996207@weber.videotron.net> (permalink)
Newsgroups comp.lang.java.gui
References <46017533$0$488$cc7c7865@news.luth.se>
Date 2011-04-27 15:32 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui

"Carramba" <user@example.net> wrote in message 
news:46017533$0$488$cc7c7865@news.luth.se...
>
> but now the problem is in this
>
>     public void paint(Graphics g) {
> // TODO Auto-generated method stub
> Graphics2D g2d = (Graphics2D)g;
> super.paint(g);
> Polygon p = new Polygon();
> System.out.println(getBounds());
> p.addPoint(getBounds().x+3, getBounds().y+3);
> p.addPoint(getBounds().x+10, getBounds().y+3);
> p.addPoint(getBounds().x+3, getBounds().x+10);
> g2d.fillPolygon(p);
> g2d.drawPolygon(p);
>     }
>
>     /* (non-Javadoc)
>      * @see java.awt.Component#getBounds()
>      */
>     @Override
>     public Rectangle getBounds() {
> // TODO Auto-generated method stub
> return super.getBounds();
>     }
> get bounds returns absolute position, but I would like to have relative 
> to by able to draw triangle..

    The relative origin position is (0,0). I.e. call addPoint(3,3), and 
not addPoint(getBounds().x+3,getBounds().y+3).

    - Oliver

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

implementing paint "Carramba" <carramba@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
  Re: implementing paint "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
    Re: implementing paint "Carramba" <carramba@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
      Re: implementing paint "Oliver Wong" <oliver.wong@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000

csiph-web