Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a new component using java in netbeans

I am developing a software for my university project. I am using java to develop my desktop application. For that I want to add a component like this: http://www.mediafire.com/view/?6y1183p8u6phwzg

I want to add a component which are like ones in the left side of below frame. It is a resizable component contains with heading and it's sub menus. We can also see these kind of components in the left side of the windows XP OS. I tried hard to develop this component and only could able to make a resizable component, but it does not reduces their empty spaces between them. I will put my code below and sample design of my application. I will be very much thankful if any one can give me a solution to make my component working as i hope or give a good solution to make this component.Thank you very much.:)

http://www.mediafire.com/view/?c9b8jwp4c558zae

    private void lbl1MousePressed(java.awt.event.MouseEvent evt) {                                  
    if (!(jpnTop.getSize().equals(lbl1.getSize()))) {
        try {
            Thread.sleep(100);
            jpnTop.setSize(lbl1.getSize());

        } catch (InterruptedException ex) {
        }

    } else {
        try {
            Thread.sleep(100);
            jpnTop.setSize(169, 162);


        } catch (InterruptedException ex) {
        }
    }
}  

  private void lbl2MousePressed(java.awt.event.MouseEvent evt) {                                  
    if (!(jpnLow.getSize().equals(lbl2.getSize()))) {
        try {
            Thread.sleep(100);
            jpnLow.setSize(lbl2.getSize());

        } catch (InterruptedException ex) {
        }

    } else {
        try {
            Thread.sleep(100);
            jpnLow.setSize(169, 162);

        } catch (InterruptedException ex) {
        }
    }
}

Ps: due to this site's restrictions i cannot upload my images i kindly ask u to see them using above medeafire links.thank u very much.

like image 748
SHdinesh Madushanka Avatar asked Jul 10 '26 22:07

SHdinesh Madushanka


1 Answers

as you tagged your question with SwingX - use it instead of re-inventing the wheel :-) The components you are looking for are called JXTaskPane/Container.

BTW: sleeping on the EDT (as you do in the mouseListener methods in your snippet) is wrong - as in REALLY WRONG - simply don't. Same for manually setting sizes/locations components: that's the exclusive task of a suitable LayoutManager.

like image 105
kleopatra Avatar answered Jul 13 '26 13:07

kleopatra