The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > General Programming > Java


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.
Reply
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 07-25-2007, 06:15 PM
nogono nogono is offline
Novice
Join Date: Jul 2007
Posts: 35
iTrader: (0)
nogono is on a distinguished road
Java help

what is addactionListener(this) means.....what exactly this means over here....



thanks

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #2 (permalink)  
Old 07-25-2007, 06:33 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,109
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
this means the class that you're working on...
addActionListener(this) then means that you're passing this class into ActionListener, which I don't think would work...

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #3 (permalink)  
Old 07-26-2007, 08:16 AM
Lee's Avatar
Lee Lee is offline
PT Staff*
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: Blackpool, UK
Posts: 615
iTrader: (0)
Lee will become famous soon enoughLee will become famous soon enoughLee will become famous soon enoughLee will become famous soon enough
Quote:
Originally Posted by HelloWorld View Post
this means the class that you're working on...
addActionListener(this) then means that you're passing this class into ActionListener, which I don't think would work...
I think that line was an example and to know what that part ment he put this there so that it was clear to others trying to help
Reply With Quote
  #4 (permalink)  
Old 07-27-2007, 02:06 PM
nogono nogono is offline
Novice
Join Date: Jul 2007
Posts: 35
iTrader: (0)
nogono is on a distinguished road
Java

What is pane,panel,getcontentpane,container.......want meaning + Example...

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #5 (permalink)  
Old 07-27-2007, 02:27 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,109
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Quote:
Originally Posted by nogono View Post
What is pane,panel,getcontentpane,container.......want meaning + Example...
Here's quote from Java API

Quote:
ContainergetContentPane()
Returns the contentPane object for this frame.
That's from javax.swing.JFrame package.

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

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #6 (permalink)  
Old 07-27-2007, 03:31 PM
nogono nogono is offline
Novice
Join Date: Jul 2007
Posts: 35
iTrader: (0)
nogono is on a distinguished road
Icon7 Client java

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........


__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #7 (permalink)  
Old 07-27-2007, 03:38 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,109
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Quote:
Originally Posted by nogono View Post
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........
From the code that you gave me, it doesn't give me much information of what kind of application are you trying to create. But you named your class pretty well so I guess you're trying to create some kind of networking application. However, what does:

Code:
frame.listenSocket();
that do in your program?
The rest of your code is just the general setup for GUI

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #8 (permalink)  
Old 07-27-2007, 07:59 PM
nogono nogono is offline
Novice
Join Date: Jul 2007
Posts: 35
iTrader: (0)
nogono is on a distinguished road
Icon13

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......


__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #9 (permalink)  
Old 07-27-2007, 10:55 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,109
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
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:
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
And I hope that code is more readable than the one that you have (although it's actually better to use the one what you have because it's more explicit) "Better" in the sense that you have much more control to what do you want your GUI to do when the close "X" button is pressed.. lol.. I played with this around with my friend by poping up another window each time it's pressed!!!

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:
WindowListener l = new WindowAdapter() {


that means that you're calling the instance of WindowListener (the action listener for the GUI's window). As you may realize, Java divided your GUI into 3 parts: Window, Frames, and Panel. The Window will be the outer most of your GUI, the Frame will be the one that's within the Window (the content), and the Panel will be what is within the Frames (you can add JPanel within Frame).

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:
System.exit(0); // you can change "0" to whatever you wanted 
This code is the one that's going to close the System process of the JVM. Be careful with this when you run 2 Java program at the same time, because both of them will be closed when this function is called. It will basically turned off the JVM process.

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

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #10 (permalink)  
Old 07-28-2007, 11:15 AM
nogono nogono is offline
Novice
Join Date: Jul 2007
Posts: 35
iTrader: (0)
nogono is on a distinguished road
Class Hierarchy

<B><FONT size=-1>

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

   Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 05:39 PM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50