Article View: be.comp.programming
Article #12952Question: drawing on JPanel II (How to get the lower right corner)
From: Nick de Graeve
Date: Sat, 22 Sep 2001 17:22
Date: Sat, 22 Sep 2001 17:22
24 lines
2131 bytes
2131 bytes
Hi
I want to draw a rectangle at 20 pixels of the borders of a JPanel and I use
the getWidth() and getHeight() methods to get the lower right corner but the
rectangle gets drawn beyond the lower and right edges of the JPanel. I got a
class that extends JPanel and has following paintComponent method:
public void paintComponent(Graphics g) {
Graphics g2 = (Graphics)g;
super.paintComponent(g2);
g2.drawRect(20, 20, getWidth()-20, getHeight()-20);
}
What am I doing wrong?
Nick de Graeve
ICQ 71563611 (Rotwang)
http://users.pandora.be/nicks_auditorium/
History of and information on movie sound systems.
"Try not! Do... Or do not.
"There is no try!"
-- Master Yoda --
Technical Details
Message-ID:
<CN3r7.65846$6x5.14500406@afrodite.telenet-ops.be>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!dispose.news.demon.net!demon!skynet.be!skynet.be!ossa.telenet-ops.be!afrodite.telenet-ops.be.POSTED!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10fd6d,645be76798212a49,start X-Google-Attributes: gid10fd6d,public X-Google-Thread: 113ae9,645be76798212a49,start X-Google-Attributes: gid113ae9,public X-Google-Thread: 10a146,645be76798212a49,start X-Google-Attributes: gid10a146,public X-Google-Thread: fcea4,645be76798212a49,start X-Google-Attributes: gidfcea4,public X-Google-ArrivalTime: 2001-09-22 10:22:58 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!dispose.news.demon.net!demon!skynet.be!skynet.be!ossa.telenet-ops.be!afrodite.telenet-ops.be.POSTED!not-for-mail From: "Nick de Graeve" <de_graeve@hotmail.com> Newsgroups: be.comp.programming,comp.lang.java.gui,comp.lang.java.help,comp.lang.java.programmer Subject: Question: drawing on JPanel II (How to get the lower right corner) Lines: 26 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Message-ID: <CN3r7.65846$6x5.14500406@afrodite.telenet-ops.be> Date: Sat, 22 Sep 2001 17:22:42 GMT NNTP-Posting-Host: 213.118.8.14 X-Complaints-To: abuse@pandora.be X-Trace: afrodite.telenet-ops.be 1001179362 213.118.8.14 (Sat, 22 Sep 2001 19:22:42 MET DST) NNTP-Posting-Date: Sat, 22 Sep 2001 19:22:42 MET DST Organization: Telenet Internet