Bug 115217 - Automatically modify visual code created in NetBeans when opening with VE
Summary: Automatically modify visual code created in NetBeans when opening with VE
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: VE (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P1 enhancement (vote)
Target Milestone: ---   Edit
Assignee: VE Bugzilla inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-05 16:00 EST by Dennis Piccioni CLA
Modified: 2011-06-13 11:36 EDT (History)
2 users (show)

See Also:


Attachments
Test JFrame created with NetBeans 4.1 (1.61 KB, text/plain)
2005-11-07 14:10 EST, Dennis Piccioni CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dennis Piccioni CLA 2005-11-05 16:00:48 EST
When opening visual (Swing) code created in NetBeans, the Visual Editor shows 
the components in a frame pretty messed up, as if they are not inside the 
frame. I understand that this is due to differences in the code that the VE 
creates from the code NetBeans creates (I researched this in the newsgroups). 
It seems that the code differences are minor, but tedious to apply manually. 
The VE should either simply make the changes for me, or ask me if I would like 
it to make them.
Comment 1 Peter Walker CLA 2005-11-07 11:59:37 EST
Could you be more specific about the code patterns that do not work and/or
provide and example class that illustrates the problem? Thanks...
Comment 2 Dennis Piccioni CLA 2005-11-07 14:10:50 EST
Created attachment 29461 [details]
Test JFrame created with NetBeans 4.1

This is a very simple JFrame created in NteBeans 4.1 with a JTextField and a
JButton in it. Opening it in Eclipse 3.1.1 with VE 1.1.0.1 will display it as
if the JFrame has a size of 0,0. In addition, it looks like the 2 components
are not inside the JFrame, and their locations are also incorrect. A few simple
code adjustments will make this code look and work correct in Eclipse.
Comment 3 Dennis Piccioni CLA 2005-11-07 14:12:40 EST
Comment on attachment 29461 [details]
Test JFrame created with NetBeans 4.1

Sorry, I mean, of course, it is a simple JFrame subclass.
Comment 4 Peter Walker CLA 2005-11-17 12:02:28 EST
(In reply to comment #2)
> Test JFrame created with NetBeans 4.1
> 
> This is a very simple JFrame created in NteBeans 4.1 with a JTextField and a
> JButton in it. Opening it in Eclipse 3.1.1 with VE 1.1.0.1 will display it as
> if the JFrame has a size of 0,0. In addition, it looks like the 2 components
> are not inside the JFrame, and their locations are also incorrect. A few simple
> code adjustments will make this code look and work correct in Eclipse.

Dennis,
Thanks for the example.. this helps us understand the code patterns. 
Currently VE will support using other initialization methods such NetBeans
'initComponents' but the problem here is VE doesn't handle an implicit component
such as the content pane which is used in the initComponents method. VE uses an
explicit JPanel for it's content pane. In other words, VE can't handle:
        getContentPane().add(jButton1);

As a work around, if you create a new JPanel and set the content pane of the
JFrame to this panel, and change all the places in your code that reference
'getContentPane()', VE should work fine. 

Here's the example with the changed code:

   private void initComponents() {
        jTextField1 = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();

        JPanel jPanel = new JPanel();  // Added 
        this.setContentPane(jPanel);   // Added
        jPanel.setLayout(null);        // Changed

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        this.setSize(new Dimension(243, 183));
        jTextField1.setText("jTextField1");
        jPanel.add(jTextField1);      // Changed
        jTextField1.setBounds(50, 20, 120, 19);

        jButton1.setText("jButton1");
        jPanel.add(jButton1);        // Changed
        jButton1.setBounds(70, 80, 73, 23);

        pack();
    }
Comment 5 Dennis Piccioni CLA 2005-11-18 14:24:34 EST
Hi Peter,

I understand the technical reasons behind the differences in what Eclipse and 
Netbeans create and I understand the changes in code you need to make to get 
this to work -- I made them to my project. What I am asking for is that these 
be made automatically.

Maybe I misunderstood you reply. Do you disagree that this should be automated?

Thanks,
Dennis
Comment 6 Peter Walker CLA 2005-11-18 15:47:45 EST
(In reply to comment #5)
> Hi Peter,
> 
> I understand the technical reasons behind the differences in what Eclipse and 
> Netbeans create and I understand the changes in code you need to make to get 
> this to work -- I made them to my project. What I am asking for is that these 
> be made automatically.
> 
> Maybe I misunderstood you reply. Do you disagree that this should be automated?
> 
> Thanks,
> Dennis

Dennis,
Sorry I wasn't more clear.
Yes... I agree with your request that VE make this change automatically. 
Once VE is able to handle 'implicit' type of components, this type of code
pattern with work fine in VE.

I left this bug open to be handled as a future enhancement to VE.

Regards...
Peter