• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can any please review following piece of code

 
Shreyas Rane
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49796
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> 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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> 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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ofcourse you can run it for yourself i just wanted to know if i have followed best coding practices . thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic