![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |
| ||||
| Quote:
Quote:
For panel, the only one that I usually use is JPanel, that will create the container of objects (which can be anything... example: JButton, another JPanel, JToolbar, etc) Container is basically an Object that can be JFrame itself, which is the outermost of your panel, or JPanel... I'm not sure if there's another type of container, but those two are the most commonly used. You may want to check Java APIs for what are classes that inherits from the java.awt.Container package to see different kind of containers that Java offers You may want to see my previous tutorial for the JFrame example ![]() http://www.programmerstalk.net/thread692.html |
| |||
| SocketClient frame = new SocketClient(); frame.setTitle("Client Program"); WindowListener l = new WindowAdapter() { publicvoid windowClosing(WindowEvent e) { System.exit(0); } }; frame.addWindowListener(l); frame.pack(); frame.setVisible(true); frame.listenSocket(); Can u understand me whole program........ |
| ||||
| Quote:
Code: frame.listenSocket(); The rest of your code is just the general setup for GUI |
| |||
| SocketClient frame = new SocketClient(); frame.setTitle("Client Program"); WindowListener l = new WindowAdapter() { publicvoid windowClosing(WindowEvent e) { System.exit(0); } }; frame.addWindowListener(l); frame.pack(); frame.setVisible(true); i know it s a part of code(GUI)...I just want to understand this code......i am familiar with some concepts...but i am not clear about the syntax.....specially window adapter function...... |
| ||||
| Before the explanation about WindowAdapter. Just to let you know that those lines of codes may also be replaced with this one and do the exact same thing: PHP Code: ![]() Anyways, WindowAdapter and WindowListener are basically (almost) the same thing with actionListener that you have with other objects such as buttons. When you say PHP Code: WindowAdapter however is one method that must be overridden when you called WindowListener (It's an abstract method). And WindowAdapter class has a method called windowClosing that takes a WindowEvent. PHP Code: Please note that I haven't personally research that deep to these matters, so I can't give you more detailed explanation than what I understood. Hopefully this would help ![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |