Thread View: borland.public.jbuilder.java.swing
3 messages
3 total messages
Started by Sven Goetgeluck
Mon, 19 Jan 2004 15:35
jbUILER 9
Author: Sven Goetgeluck
Date: Mon, 19 Jan 2004 15:35
Date: Mon, 19 Jan 2004 15:35
237 lines
7278 bytes
7278 bytes
Hi since jbuilder 9 when opening mydialogs i get a red square in design what
can be my problem
i have made my own escdialog who listens for esc keys and all my other
dialogs are extended from this one
fe warningdiolog
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
public class WarningDialog
extends MyESCDialog {
JPanel panel1 = new JPanel();
MyDialogButton OKButton = new MyDialogButton();
XYLayout xYLayout1 = new XYLayout();
JLabel image = new JLabel();
JLabel transparentImage1 = new JLabel();
JLabel jLabel1 = new JLabel();
JLabel filename = new JLabel();
UtilityClass m_Utils = new UtilityClass();
private ActionListener okListener = null;
public WarningDialog(Frame frame, String title, boolean modal,
ResourceBundle r, ResourceBundle i) {
super(frame, title, modal);
this.setResourceBundle(r, i);
jbInit();
pack();
}
void jbInit() {
panel1.setLayout(xYLayout1);
OKButton.setText(recources.getString("OK"));
OKButton.addActionListener(okListener = new
java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
OKButton_actionPerformed(e);
}
});
xYLayout1.setHeight(116);
xYLayout1.setWidth(365);
transparentImage1.setIcon(new ImageIcon(images.getString("WARNING")));
transparentImage1.setHorizontalAlignment(SwingConstants.CENTER);
transparentImage1.setHorizontalTextPosition(SwingConstants.CENTER);
panel1.setMaximumSize(new Dimension(370, 120));
panel1.setMinimumSize(new Dimension(370, 120));
panel1.setPreferredSize(new Dimension(370, 120));
getContentPane().add(panel1);
panel1.add(OKButton, new XYConstraints(139, 82, 92, 29));
panel1.add(filename, new XYConstraints(87, 42, 267, 23));
panel1.add(jLabel1, new XYConstraints(87, 13, 267, 26));
panel1.add(transparentImage1, new XYConstraints(1, 5, 70, 70));
this.setSize(370, 120);
centerScreen();
}
void OKButton_actionPerformed(ActionEvent e) {
dispose();
}
public void setReason(String r) {
jLabel1.setText(r);
}
public void setFilename(String f) {
filename.setText(f);
}
private void done() {
OKButton.removeActionListener(okListener);
m_Utils.removeAllComponents(this);
dispose();
}
//--------------------------------------------------------------------------
--
// finalize
//
// Added lots of stuff here!
// Always make sure you set ALL objects to null when working with Swing.
//--------------------------------------------------------------------------
--
protected void finalize() {
panel1 = null;
OKButton = null;
xYLayout1 = null;
image = null;
transparentImage1 = null;
jLabel1 = null;
recources = null;
images = null;
filename = null;
m_Utils = null;
okListener = null;
try {
super.finalize();
}
catch (Throwable e) {}
}
}
//////////////////////////////////////////////
the escdialog is below
/////////////////////////////////////////////
package components.dialogs;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public abstract 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();
}
}
}
Re: jbUILER 9
Author: Tad Frysinger [TeamB]
Date: Tue, 20 Jan 2004 04:19
Date: Tue, 20 Jan 2004 04:19
14 lines
1619 bytes
1619 bytes
Sven Goetgeluck wrote: > Hi since jbuilder 9 when opening mydialogs i get a red square in design what > can be my problem > i have made my own escdialog who listens for esc keys and all my other > dialogs are extended from this one > fe warningdiolog It means that the JBuilder Designeer can't create an instance of one of the components. This can happen when the class or constructor isn't public, the class threw exceptions on every constructor that JBuilder tried, or the class in question extends an abstract class. Check out "Handling Red Beans" in the help. -- Tad Frysinger [TeamB]
Re: jbUILER 9
Author: Sven Goetgeluck
Date: Tue, 20 Jan 2004 08:29
Date: Tue, 20 Jan 2004 08:29
32 lines
1914 bytes
1914 bytes
i'm reading my recourses from file , can that be the problem? is thre another way then? are there some standards like OK ect that can be read from standard classes for every language sven "Tad Frysinger [TeamB]" <tfrysinger@earthlink.net> schreef in bericht news:400caca1$1@newsgroups.borland.com... > Sven Goetgeluck wrote: > > Hi since jbuilder 9 when opening mydialogs i get a red square in design what > > can be my problem > > i have made my own escdialog who listens for esc keys and all my other > > dialogs are extended from this one > > fe warningdiolog > It means that the JBuilder Designeer can't create an instance of one of > the components. This can happen when the class or constructor isn't > public, the class threw exceptions on every constructor that JBuilder > tried, or the class in question extends an abstract class. Check out > "Handling Red Beans" in the help. > > -- > Tad Frysinger [TeamB] >
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads