Watch, Follow, &
Connect with Us
Public Report
Report From: JBuilder/Designers/UI Designer    [ Add a report in this area ]  
Report #:  9669   Status: Closed
Switching to Design tab crashes w/ JBuilder2005 and a class that extends JToolBar
Project:  JBuilder Build #:  11.0.236.0
Version:    12 Submitted By:   cannon o'meary
Report Type:  Crash / Data loss / Total failure Date Reported:  11/29/2004 5:43:14 PM
Severity:    Critical / Show Stopper Last Updated: 3/20/2012 2:24:39 AM
Platform:    All versions Internal Tracking #:   220142
Resolution: Cannot Reproduce (Resolution Comments) Resolved in Build: : 012.000.203.000
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
5.00 out of 5
Total Votes: 2
Description
After creating a class that extends JToolBar and instantiating it in another JFrame class. Switching to Design Tab causes an immediate crash.

The JToolBar appears as expected in it's own Design tab. Everything compiles and the application works as expected.

JBuilder 2005 Foundation edition. I'm using JDK 1.5. I tried again with the JDK that comes with jbuilder (1.4.x I believe) and it does the same thing.
Steps to Reproduce:
1) New Application, click through accepting the defaults
2) When you arrive at the Frame class check the options menu, status, toolbar, about dialog. (all of them)
3) Click Finish.
4) Make a new class called MyToolBar
5) Cut the lines straight from Frame1 class into MyToolBar so it looks like this:

public class MyToolBar extends JToolBar
{
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    JButton jButton3 = new JButton();
    ImageIcon image1 = new ImageIcon(toolbar.Frame1.class.getResource("openFile.png"));
    ImageIcon image2 = new ImageIcon(toolbar.Frame1.class.getResource("closeFile.png"));
    ImageIcon image3 = new ImageIcon(toolbar.Frame1.class.getResource("help.png"));

    public MyToolBar()
    {
        try
        {
            jbInit();
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }

    }

    private void jbInit() throws Exception
    {    
        jButton1.setIcon(image1);
        jButton1.setToolTipText("Open File");
        jButton2.setIcon(image2);
        jButton2.setToolTipText("Close File");
        jButton3.setIcon(image3);
        jButton3.setToolTipText("Help");
        add(jButton1);
        add(jButton2);
        add(jButton3);
    }
}

6) Frame1 will have these lines now:
    JMenuItem jMenuHelpAbout = new JMenuItem();
    MyToolBar myToolBar = new MyToolBar(); // changed line
    JLabel statusBar = new JLabel();
...and...
        setJMenuBar(jMenuBar1);
        contentPane.add(myToolBar, BorderLayout.NORTH); // changed
        contentPane.add(statusBar, BorderLayout.SOUTH);

7) Click on the design tab in mytoolbar and also in frame1. Everything should look normal.
8) build and run it
9) Click on Frame1 -> source tab, then click back to Frame1 -> design tab. (Click back and forth a few times maybe)
10) Crash?
Workarounds
Don't extend JToolBar and use the Designer.

---------

Don't extend JToolBar and use the Designer.
Attachment
None
Comments

cannon o'meary at 11/29/2004 5:47:40 PM -
Just to clarify:
class MyToolBar extends JToolBar // appears in the designer fine

class Frame1 extends JFrame // causes a crash when switching to Frame1's designer
{
    ...
    MyToolBar myToolBar = ...
    ...
}

Server Response from: ETNACODE01