aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Can any please review following piece  of code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Can any please review following piece  of code" Watch "Can any please review following piece  of code" New topic
Author

Can any please review following piece of code

Shreyas Rane
Greenhorn

Joined: Apr 10, 2009
Posts: 16
Its a swing application which connects with a Device on N/W and communicates with it.
Is the swing programming part done correctly??
Please review the code.
Thanks in advance

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39818
    
  28
Review? What for? Apart from the many static fields? It is probably an error to have that many fields. They should be local variables. It is very probably an error to mark them static. So the answer to your question is no.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> Is the swing programming part done correctly??

couple of things stand out (from a quick glance)

1)
you have this line
frame.setMinimumSize(new Dimension(1000, 750));
then this
frame.setSize(new Dimension(1000, 850));
finally this
frame.setBounds(100, 100, 750, 400);

do you know what those lines do?

2)
this method
private static void changeContentPane(JPanel panel)

you really should look at using a CardLayout, much easier/neater


and if you want people to have a serious look at your GUI code,
remove all the non-GUI stuff, so you just have a stand alone frame with components,
no listeners/socket codes etc. Make sure it compiles/runs, then post that code.
Shreyas Rane
Greenhorn

Joined: Apr 10, 2009
Posts: 16
Hi Michael Dunn thanks for your reply..

I have removed those redundant setSize() lines..

Actually i was trying to write a swing based desktop application, its a menu driven application. Just wanted to know if i was following the best swing programming practices,
The application runs fine, it needs a bit of testing.

if you want to review the swing (GUI) code i can repost it.

Thanks anyways..
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> if you want to review the swing (GUI) code i can repost it.

I can remove all the redundant code and run it (for myself) as a stand-alone GUI,
and you'll get a single opinion.

if you remove the redundant code and repost the same stand-alone GUI,
you'll most likely get multiple opinions/advices.
Shreyas Rane
Greenhorn

Joined: Apr 10, 2009
Posts: 16
ofcourse you can run it for yourself i just wanted to know if i have followed best coding practices . thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can any please review following piece of code