• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with code

 
Karen Wilson
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found a chat application online that uses client/server but they just wrote out all the code to add the buttons, textfields etc to the frame.
I prefer to add a JFrame and drag and drop the stuff over and then create event handlers for the buttons.
But when i try putting the code into my frame nothing works.
I really hope someone can help

The website code works perfectly I just want to put everything in a JFrame.
I would really appreciate if someone could take a look and see what I am doing wrong

here is the website code:




 
Karen Wilson
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and here is my attempt at adding the code to JFrame

here is the login page:


and here is the client page:
 
Greg Charles
Sheriff
Posts: 2989
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of the two, Login is the easier to convert to a JFrame. Why? Because it's not extending a class now. You can just declare it to extend JFrame, remove the JFrame frame1 field, change the first line of the constructor from "frame1 = new JFrame("Login Page") to super("Login Page"), and finally change all other references of frame1 to this. It's all bookkeeping really.

MyClient is just a bit harder since it extends WindowAdapter. You'd either have to make it implement WindowListener (and provide dummy implementations for the methods you don't care about) or create a new WindowAdapter, possibly as an anonymous inner class, with the windowClosing() method that's currently in MyClient. Still bookkeeping, but somewhat harder bookkeeping.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic