Article View: be.comp.programming
Article #5486JAVA repaint
From: An Ony
Date: Sat, 19 Apr 2003 10:54
Date: Sat, 19 Apr 2003 10:54
56 lines
2223 bytes
2223 bytes
Hallo,
heeft er iemand enig idee waarom mijn SOUTH-panel er niet direkt opkomt bij
het klikken van de button?
Als je eens aan de rand van het frame klikt met de muis (een resize zeg
maar) tekent hij hem er wel bij.
Die repaint() doet dus eigenlijk niets.
===============================================================
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class Border extends JPanel
{
public Border()
{
this.setLayout(new BorderLayout());
this.add(buttonPanel(),BorderLayout.CENTER);
}
public JPanel buttonPanel()
{
JPanel tmp = new JPanel();
JButton but = new JButton("Click me");
but.addActionListener(new ButtonClick());
tmp.add(but);
return tmp;
}
public JPanel emptyPanel()
{
JPanel tmp = new JPanel();
tmp.add(new JLabel("Nothing here"));
return tmp;
}
private class ButtonClick implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
add(emptyPanel(),BorderLayout.SOUTH);
repaint();
}
}
public static void main(String [] args)
{
JFrame f = new JFrame("Yo yo");
f.setContentPane(new Border());
f.pack();
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
===============================================================
Technical Details
Message-ID:
<3ea12b25$0$1903$ba620e4c@reader1.news.skynet.be>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!skynet.be!skynet.be!louie!tlk!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fcea4,19330713e98893a,start X-Google-Attributes: gidfcea4,public X-Google-ArrivalTime: 2003-04-19 03:56:23 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!skynet.be!skynet.be!louie!tlk!not-for-mail From: "An Ony" <Dontknow@some.net> Newsgroups: be.comp.programming Subject: JAVA repaint Date: Sat, 19 Apr 2003 12:54:48 +0200 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Lines: 58 Message-ID: <3ea12b25$0$1903$ba620e4c@reader1.news.skynet.be> Organization: -= Belgacom Usenet Service =- NNTP-Posting-Host: 80.201.6.72 X-Trace: 1050749734 reader1.news.skynet.be 1903 80.201.6.72:1405 X-Complaints-To: abuse@skynet.be