Article View: borland.public.jbuilder.java.swing
Article #1180the red component mistery
From: Sven Goetgeluck
Date: Thu, 29 Jan 2004 21:20
Date: Thu, 29 Jan 2004 21:20
156 lines
5268 bytes
5268 bytes
hi ,
when using my dialogs in jb 9 i'll get a red component in design mode
what can i do about it?
all my dialogs are extended from myescdialog so i dont have to put all the
code agian for reacting on esc button press
a.. Failed to create live instance for variable 'this'.
components.dialogs.MyESCDialog
b.. Failed to create live visual subcomponent this as
components.dialogs.MyESCDialog(cls); creating a red component in its place
is there a wourk around??
sven
public class MyESCDialog extends JDialog
{
public ResourceBundle recources;
public ResourceBundle images;
protected void setResourceBundle(ResourceBundle r , ResourceBundle i)
{
recources = r;
images = i;
}
public MyESCDialog(Frame parent, String title, boolean modal)
{
super(parent,title,modal);
((Container)getLayeredPane()).addContainerListener(
new ContainerHandler());
getContentPane().addContainerListener(new ContainerHandler());
keyHandler = new KeyHandler();
addKeyListener(keyHandler);
addWindowListener(new WindowHandler());
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}
protected void centerScreen()
{
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
Dimension dialogsize = this.getSize();
setLocation((dim.width/2 -dialogsize.width/2),(dim.height/2 -dialogsize.heig
ht/2) );
}
// protected members
protected KeyHandler keyHandler;
// Recursively adds our key listener to sub-components
class ContainerHandler extends ContainerAdapter
{
public void componentAdded(ContainerEvent evt)
{
componentAdded(evt.getChild());
}
public void componentRemoved(ContainerEvent evt)
{
componentRemoved(evt.getChild());
}
private void componentAdded(Component comp)
{
comp.addKeyListener(keyHandler);
if(comp instanceof Container)
{
Container cont = (Container)comp;
cont.addContainerListener(this);
Component[] comps = cont.getComponents();
for(int i = 0; i < comps.length; i++)
{
componentAdded(comps[i]);
}
}
}
private void componentRemoved(Component comp)
{
comp.removeKeyListener(keyHandler);
if(comp instanceof Container)
{
Container cont = (Container)comp;
cont.removeContainerListener(this);
Component[] comps = cont.getComponents();
for(int i = 0; i < comps.length; i++)
{
componentRemoved(comps[i]);
}
}
}
}
class KeyHandler extends KeyAdapter
{
public void keyPressed(KeyEvent evt)
{
if(evt.isConsumed())
return;
if(evt.getKeyCode() == KeyEvent.VK_ESCAPE)
{
dispose();
evt.consume();
}
}
}
class WindowHandler extends WindowAdapter
{
public void windowClosing(WindowEvent evt)
{
dispose();
}
}
}
///////////// an example of a "red" dialog
public class errorDialog extends MyESCDialog {
JPanel panel1 = new JPanel();
JButton jButton1 = new JButton();
XYLayout xYLayout1 = new XYLayout();
public errorDialog(Frame frame, String title, boolean modal) {
super(frame, title, modal);
try {
jbInit();
pack();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
public errorDialog() {
this(null, "", false);
}
private void jbInit() throws Exception {
panel1.setLayout(xYLayout1);
jButton1.setText("jButton1");
this.getContentPane().add(panel1, BorderLayout.CENTER);
panel1.add(jButton1, new XYConstraints(257, 123, -1, -1));
}
}
Technical Details
Message-ID:
<4019791d$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!zeus.visi.com!priapus.visi.com!orange.octanews.net!news.octanews.net!news-out.visi.com!hermes.visi.com!feed2.news.rcn.net!feed1.news.rcn.net!rcn!news.maxwell.syr.edu!peernews-us.colt.net!colt.net!newsfeed.icl.net!newsfeed.fjserv.net!proxad.net!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,13c33929f7fcff3b,start X-Google-Attributes: gid111d45,public X-Google-ArrivalTime: 2004-01-29 13:35:04 PST From: "Sven Goetgeluck" <sven.goetgeluck@pandora.be> Newsgroups: borland.public.jbuilder.java.swing Subject: the red component mistery Date: Thu, 29 Jan 2004 22:20:31 +0100 Lines: 159 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 213.224.11.244 Message-ID: <4019791d$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1075411229 213.224.11.244 (29 Jan 2004 13:20:29 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!zeus.visi.com!priapus.visi.com!orange.octanews.net!news.octanews.net!news-out.visi.com!hermes.visi.com!feed2.news.rcn.net!feed1.news.rcn.net!rcn!news.maxwell.syr.edu!peernews-us.colt.net!colt.net!newsfeed.icl.net!newsfeed.fjserv.net!proxad.net!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail