Custom Component [message #136260] |
Wed, 07 March 2007 06:20 |
Eclipse User |
|
|
|
Originally posted by: shobanaramaswamy.yahoo.co.in
Hi All,
I need help regarding the code generation of graphic objects such as Label
etc when they are dragged and dropped from the component palette to the
container.
The initialization code for such object are written in to the container
getXXX() method rather then a separate method by itself.
For Example in Visual Editor, when a Label is dragged and dropped from the
component palette on to a Panel, the default code generated for that
component is:
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel() {
if (jPanel == null) {
jLabel = new JLabel();
jLabel.setText("JLabel");
jPanel = new JPanel();
jPanel.setLayout(new GridBagLayout());
jPanel.setSize(new Dimension(372, 264));
jPanel.add(jLabel, gridBagConstraints);
}
return jPanel;
}
I want to generate code in a separate method for this label component not
inside the container. Like
Private JLabel getJLabel()
{
If(jLabel ==null)
{
jLabel = new JLabel();
jLabel.setText("JLabel");
}
return jLabel;
}
Please help me generate the get method for the component like the label on
drag and drop action.
Also I want to add a few properties as default properties of the component
when the code is generated on the drop of the component. Is there a way
where I can get hold of the event, which adds the component to the
container. I would like to pop-up a dialog to accept the basic required
properties and generate the code accordingly.
Any help or pointer in this regard will be greatly appreciated.
Thanks and Best Regards,
Shobana
|
|
|
Powered by
FUDForum. Page generated in 0.02825 seconds