Results 1 to 2 of 2

Thread: How to write a element Listener in Java?

  1. #1
    Brownchris is offline Senior Member
    Join Date
    Dec 2009
    Posts
    331
    Rep Power
    3

    Default How to write a element Listener in Java?

    I am little bit confused while writing the Component Listener..!! I have tried a lot of method but none of then worked out. I want to know how to write a Component Listener in Java? Any help would be highly appreciated.

  2. #2
    MartinWilson is offline Senior Member
    Join Date
    Dec 2009
    Posts
    281
    Rep Power
    3

    Default

    Following are the techniques of the ComponentListener Interface:

    • componentHidden(ComponentEvent) - method is called after the listened-to component is hidden.

    • componentMoved(ComponentEvent) - method is called after the listened-to component moves.

    • componentResized(ComponentEvent) - method is called when the listened-to component's size changes.
    The following is the method of the ComponentEvent Class:

    • Component getComponent() - method returns the component that fired the event.
    Use the code given below which is helpful for you:

    Code:
    private static void createAndShowGUI() {
            frame = new JFrame("TrialComponentEvent");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JComponent newContentPane = new ComponentEventDemo();
            newContentPane.setOpaque(true);
            frame.setContentPane(newContentPane);
            frame.pack();
            frame.setVisible(true);
        }

Similar Threads

  1. Open and write text file in JAVA
    By Davismoore in forum Programming
    Replies: 2
    Last Post: 03-26-2010, 02:50 PM
  2. Document Listener in Java
    By Brian Close in forum Programming
    Replies: 3
    Last Post: 03-17-2010, 11:56 AM
  3. How to carve a Focus Listener in Java?
    By SmithJohnson in forum Programming
    Replies: 1
    Last Post: 02-13-2010, 01:51 PM
  4. write sequence data java program
    By Brownchris in forum Programming
    Replies: 1
    Last Post: 01-22-2010, 06:09 PM
  5. Write program on palindrome in java
    By MoralesMyers in forum Programming
    Replies: 2
    Last Post: 01-14-2010, 06:24 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

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