Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML

Fresher Job


 

Search Host

Monthly Fee($)
Disk Space (MB)
Register With us for Newsletter!
Visit Forum! Post Questions!
Jobs At RoseIndia.net!

Have tutorials?
Add your tutorial to our Java Resource and get tons of hits.

We offer free hosting for your tutorials. and exposure for thousands of readers. drop a mail
roseindia_net@yahoo.com
 
   

Tutorials

Java Server Pages

JAXB

Java Beans

JDBC

MySQL

Java Servlets

Struts

Bioinformatics

Java Code Examples

Interview Questions

 
Join For Newsletter

Powered by groups.yahoo.com
Visit Group! Post Questions!

Web Promotion

Web Submission

Submit Sites

Manual Submission?

Web Promotion Guide

Hosting Companies

Web Hosting Guide

Web Hosting

Linux

Beginner Guide to Linux Server

Frameworks

Persistence Framework

Web Frameworks

Free EAI Tools

Web Servers

Aspect Oriented Programming

Free Proxy Servers

Softwares

Adware & Spyware Remover

Open Source Softwares

Listeners
Expert:tarun1
can u get me the code for Window listener and Text Listener and Component Listener?
Answers
Hi friend,

Code for Window listener :

import java.awt.event.WindowListener;
import java.awt.event.*;
import javax.swing.JFrame;

public class WindowListenerExample {
public static void main(String args[]) {
JFrame jf = new JFrame("Window Listener");
WindowListener wl = new WindowAdapter() {
public void windowClosing(WindowEvent w) {
System.exit(0);
}
};
jf.addWindowListener(wl);
jf.setSize(300, 300);
jf.show();
}
}

Code for Component Listener :

import java.awt.*;
import java.awt.event.ComponentListener;
import java.awt.event.*;
import javax.swing.*;


public class ComponentListenerExample {
public static void main(String args[]) {
JFrame jf = new JFrame();
Container container = jf.getContentPane();

ComponentListener cl = new ComponentListener() {
public void clonentHidden(ComponentEvent e) {
dump("Hidden", e);
}

public void clonentMoved(ComponentEvent e) {
dump("Moved", e);
}

public void clonentResized(ComponentEvent e) {
dump("Resized", e);
}

public void clonentShown(ComponentEvent e) {
dump("Shown", e);
}

private void dump(String type, ComponentEvent e) {
System.out.println(e.getComponent().getName() + " : " + type);
}
};

JButton jbl = new JButton("Left");
jbl.setName("Left");
jbl.addComponentListener(cl);

final JButton jbr = new JButton("Right");
jbr.setName("Right");
jbr.addComponentListener(cl);

ActionListener al = new ActionListener() {
public void alPerformed(ActionEvent e) {
jbr.setVisible(!jbr.isVisible());
}
};
jbl.addActionListener(al);

JSplitPane jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true,
jbl, jbr);

container.add(jsp, BorderLayout.CENTER);

jf.setSize(300, 200);
jf.show();
}
}

For more information on Listener visit to :

http://www.roseindia.net/java/example/java/swing/

Thanks

More Questions
Post Answers
 
Ask Question Facing Programming Problem?
Useful Links
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2007. All rights reserved.