Event Handling between JPanels

Hi everyone,
I'm trying a three-fold assignment on java, which relates to graphs and finding strongly connected components.
In the first part, the user can create his own graph and the program should find all SCC and display them.
In the second part, the program creates random graphs and then finds all SCC and displays them.
In the third part, some statistical data is to be displayed.
So what I have done so far is that I have created a JFrame on which I have added 3 JPanels, each for every part of the assignment.
Changing between the JPanels is done by a JTabbedPane.
My problem lies on the second part. I've created a class called RandomGraphPanel, which extends JPanel. Then I've created two sub-JPanels,
called RandomGraphAreaPanel, where the graph should be displayed and RandomGraphDataPanel, where the user can choose some parameters on which the random graph is based. I don't know how I can paint the graph on the first sub-JPanel, after pressing a button on the second sub-JPanel.
I will include some code from my classes:
public class RandomGraphPanel extends JPanel
     private JPanel graphArea;
     private RandomGraphDataPanel data;
     private RandomGraphAreaPanel area;
     public RandomGraphPanel()
          super();
          setLayout(new BorderLayout(5,5));
          data = new RandomGraphDataPanel();
          area = new RandomGraphAreaPanel();
          add(data, BorderLayout.SOUTH);
          add(area, BorderLayout.CENTER);          
     }//RandomGraphPanel constructor
}//RandomGraphPanel class
public class RandomGraphDataPanel extends JPanel
     public RandomGraphDataPanel()
          super();
          //part where RandomGraphDataPanel is filled with 2 JSliders and 1 JButton
     }//RandomGraphDataPanel constructor
     private class ButtonHandler implements ActionListener
          public void actionPerformed(ActionEvent event)
               //code that is executed when the button is pressed               
          }//actionPerformed
     }//ButtonHandler private class
}//RandomGraphDataPanel classAny help will be appreciated.
Thanks,
philimonas

Probably the best way would be to somehow implement the MVC pattern here. Another way would be to move the button handling code out of the RandomGraphDataPanel class and into the RandomGraphPanel class. You could then pass the ActionListener into the RandomGraphDataPanel object by perhaps a constructor parameter, or by a separate addActionListener method that you have created. Something like so:
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
public class RandomGraphPanel extends JPanel
    private JPanel graphArea;
    private RandomGraphDataPanel data;
    private RandomGraphAreaPanel area;
    public RandomGraphPanel()
        super();
        setLayout(new BorderLayout(5, 5));
        // *** passing ActionListener to the data class via constructor parameter
        data = new RandomGraphDataPanel(new ButtonHandler());
        area = new RandomGraphAreaPanel();
        add(data, BorderLayout.SOUTH);
        add(area, BorderLayout.CENTER);    
    // *** move this code into this class
    private class ButtonHandler implements ActionListener
        public void actionPerformed(ActionEvent event)
            area.showGraph();  // or whatever is needed to show graph       
}and
//import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;
public class RandomGraphDataPanel extends JPanel
    public RandomGraphDataPanel(ActionListener buttonHandler)
        super();
        JButton someButton = new JButton("Show Graph");
        someButton.addActionListener(buttonHandler);
    private class ButtonHandler implements ActionListener
        public void actionPerformed(ActionEvent event)
            //code that is executed when the button is pressed         
}

Similar Messages

  • Difference in event handling between Java and Java API

    could anyone list the differences between Java and java-API in event handling??
    thanks,
    cheers,
    Hiru

    the event handling mechanisms in java language
    features and API (java Application Programming
    Features)features .no library can work without a
    language and no language has event handling built in.
    I am trying to compare and contrast the event
    handling mechanisms in the language and library
    combinations such as java/ java API.
    all contributions are welcome!
    thanks
    cheersSorry, I'm still not getting it. I know what Java is, and I know what I think of when I hear API. (Application Programming Interface.) The API is the aggregation of all the classes and methods you can call in Java. If we agree on that, then the event handling mechanisms in Java and its API are one and the same.
    So what do you want to know?
    %

  • Event Handler Between Reboot states using Powershell

    Hi,
    I need some help writing an event handler for a powershell script that would meet the following requirement:
    1.  Continue Upon a restart
    2.  Continue Upon a sleep state
    3.  Continue Upon a hibernation state.

    One way that I can see that would meed all three of your requirements is to use a permanent WMI Consumer to watch the event log for each of these type of events and then perform an action.
    http://learn-powershell.net/2013/08/14/powershell-and-events-permanent-wmi-event-subscriptions/
    It would be best to make a filter for each type of event rather than throwing all into one filter. Depending on your OS, the event IDs may be different, but it is nothing that a quick query via a search engine could find for you.
    Boe Prox
    Blog |
    Twitter
    PoshWSUS |
    PoshPAIG | PoshChat |
    PoshEventUI
    PowerShell Deep Dives Book

  • Event handling between JComboBox & JCheckBox

    Hi.
    My problem is that when i click on the JCheckBox object, the code (i have) also executes the condition for JComboBox object. I assume there is a very simple solution, but i have yet to find it.
    This is the code i'm using:
         public void itemStateChanged(ItemEvent e){
              if(qcmCheckBox.isSelected()){
                   System.out.println("checkbox selected");
              if(e.getStateChange() == ItemEvent.SELECTED){
                   System.out.println("combo selected " + comboBoxOptions.getSelectedIndex());
         }My problem is, i think, that the e.getStateChange() is always returning true. I just haven't figured out a way to 'single out' when the JComboBox is selected.

    thanks for the tip, but that didn't exactly work.
    these are my steps:
    select second drop down option (out of 3)
    select checkbox
    deselect checkbox
    old output
    combo selected1
    qcm selected
    combo selected1new output (using instanceof)
    combo selected 1
    combo selected 1
    checkbox selected
    combo selected 1
    combo selected 1here's my code:
    // setting up vars
    private JCheckBox checkBox = new JCheckBox();
    private final String comboNames[] = {"Option 1", "Option 2", "Option 3"};
    private JComboBox comboBoxOptions = new JComboBox(comboNames);
    // combo box
    comboBoxOptions.addItemListener(this);
    // checkbox
    checkBox.addItemListener(this);
    // event handler
    public void itemStateChanged(ItemEvent e){
         if(checkBox.isSelected()){
              System.out.println("checkbox selected");
         //if(comboBoxOptions instanceof JComboBox){ // the suggested alternative
         if(e.getStateChange() == ItemEvent.SELECTED){
              System.out.println("combo selected " + comboBoxOptions.getSelectedIndex());
    }For some reason, the suggested answer gives me duplicate entries for the dropdown and it still gives me duplicate entries when i click on the checkbox.
    Again, what i'm trying to do is just get the checkbox not to execute the 2nd if statement "if(e.getStateChange() == ItemEvent.SELECTED){"
    I think the statement "e.getStateChange()" is returning everything true because its an event happening but i don't know a way to single the checkbox event.
    I would appreciate all the help I can get. Thanks.
    sijis

  • Event-Handling  Between 2 Classes

    Trying to learn where did I make a mistake!
    Here is a very simple sample code:
    2 classes (each has 1 (awt-style)Panel & 1 (awt-style) Button. By clicking on one of the buttons how do I change the Background (color) of the Panel in the other class?
    //***********Sample Code **********************
    import java.awt.*;
    import java.awt.event.*;
    //=====================================================
    public class App extends Frame
    Panel_1 ap1; //ap1 --> additional panel #1
    Panel_2 ap2;
    public App()
    setLayout(null);
    setBounds(100,100,300,200);
    setBackground(Color.yellow);
    //re: Panel_1
    //=============
    ap1=new Panel_1();
    add(ap1);
    //re: Panel_2
    //===========
    ap2=new Panel_2();
    add(ap2);
    public static void main(String[] args)
    App app=new App();
    app.setVisible(true);
    //==============================================================
    class Panel_1 extends Panel implements ActionListener
    Panel_2 p2;
    Button ap1b=new Button();
    Panel_1()
    setBounds(50,120,100,50);
    setBackground(Color.green);
    ap1b.setBackground(Color.red);
    ap1b.addActionListener(p2);
    add(ap1b);
    public void actionPerformed(ActionEvent ae)
    if (ae.getSource()==p2.ap2b)
    System.out.println("Test Panel 1");
    //=================================
    class Panel_2 extends Panel implements ActionListener
    Panel_1 p1;
    Button ap2b=new Button();
    Panel_2()
    setBounds(50,30,200,50);
    setBackground(Color.orange);
    ap2b.setBackground(Color.red);
    ap2b.addActionListener(p1);
    add(ap2b);
    public void actionPerformed(ActionEvent ae)
    if (ae.getSource()==p1.ap1b)
    System.out.println("Test Panel 2");
    }

    There are several ways to do this. Without going into all of them, let's narrow them down by thinking in terms of design. Why should the panels know anything about each other? Each panel is its own deal. The component which has both of the panels should be the one listening to the buttons.
    Really there is no reason to have separate classes for the panels, but if you must, then write a listener as an inner class of the frame class, then pass that listener to the constructor of each panel as you instantiate it. Then you can have the listener work with both panels directly.
    Drake

  • Question on program structure about event handling in nested JPanels in GUI

    Hi All,
    I'm currently writing a GUI app with a wizard included in the app. I have one class that acts as a template for each of the panels in the wizard. That class contains a JPanel called contentsPanel that I intend to put the specific contents into. I also want the panel contents to be modular so I have a couple of classes for different things, e.g. name and address panel, etc. these panels will contain checkboxes and the like that I want to event listeneres to watch out for. Whats the best way of implementing event handling for panel within panel structure? E.g for the the checkbox example,would it be a good idea to have an accessor method that returns the check book object from the innerclass/panel and use an addListener() method on the returned object in the top level class/panel. Or is it better to have the event listeners for those objects in the same class? I would appreciate some insight into this?
    Regards!

    MyMainClass.main(new String[] { "the", "arguments" });
    // or, if you defined your main to use varags (i.e. as "public static void main(String... args)") then you can just use
    MyMainClass.main("the", "arguments");But you should really extract your functionality out of the main method into meaningful classes and methods and just use those from both your console code and your GUI code.

  • Beginners Questions about Multiple JPanels in JFrame and event handling

    I am a newbie with SWING, and even a newerbie in Event Handling. So here goes.
    I am writing a maze program. I am placing a maze JPanel (MazePanel) at the center of a JFrame, and a JPanel of buttons (ButtonPanel) on the SOUTH pane. I want the buttons to be able to re-randomize the maze, solve the maze, and also ouput statistics (for percolation theory purposes). I have the backbone all done already, I am just creating the GUI now. I am just figuring out EventHandlers and such through the tutorials, but I have a question. I am adding an ActionListener to the buttons which are on the ButtonPanel which are on JFrame (SOUTH) Panel. But who do I make the ActionListener--Basically the one doing the work when the button is pressed. Do I make the JFrame the ActionListener or the MazePanel the ActionListener. I need something which has access to the maze data (the backbone), and which can call the Maze.randomize() function. I'm trying to make a good design and not just slop too.
    Also I was wondering if I do this
    JButton.addActionListener(MazePanel), and lets say public MazePanel implments ActionListenerdoesn't adding this whole big object to another object (namely the button actionlistener) seem really inefficient? And how does something that is nested in a JPanel on JFrame x get information from something nested in another JPanel on a JFrame x.
    Basically how is the Buttons going to talk to the maze when the maze is so far away?

    I'm not an expert, but here's what I'd do....
    You already have your business logic (the Maze classes), you said. I'm assuming you have some kind of public interface to this business logic. I would create a new class like "MazeGui" that extends JFrame, and then create the GUI using this class. Add buttons and panels as needed to get it to look the way you want. Then for each button that does a specific thing, add an anonymous ActionListener class to it and put whatever code you need inside the ActionListener that accesses the business logic classes and does what it needs to.
    This is the idea, though my code is totally unchecked and won't compile:
    import deadseasquirrels.mazestuff.*;
    public class MazeGui extends JFrame {
      JPanel buttonPanel = new JPanel();
      JPanel mazePanel = new JPanel();
      JButton randomizeB = new JButton();
      JButton solveB = new JButton();
      JButton statsB = new JButton();
      // create instanc(es) of your Maze business logic class(es)
      myMaze = new MazeClass();
      // add the components to the MazeGui content pane
      Component cp = getContentPane();
      cp.add(); // this doesn't do anything, but in your code you'd add
                // all of your components to the MazeGui's contentpane
      randomizeB.addActionListener(new ActionListener {
        void actionPerformed() {
          Maze newMaze = myMaze.getRandomMazeLayout();
          mazePanel.setContents(newMaze); // this is not a real method!
                                          // it's just to give you the idea
                                          // of how to manipulate the JPanel
                                          // representing your Maze diagram,
                                          // you will probably be changing a
                                          // subcomponent of the JPanel
      solveB.addActionListener(new ActionListener {
        void actionPerformed() {
          Solution mySolution = myMaze.getSolution();
          mazePanel.setContents(mySolution); // again, this is not a real
                                             // method but it shows you how
                                             // the ActionListener can
                                             // access your GUI
      // repeat with any other buttons you need
      public static void main(String[] args) {
        MazeGui mg = new MazeGui();
        mg.setVisible(true);
        // etc...
    }

  • Differnence between two codes of event handling

    hello i am learning event handling in swing but confused between two codes :-
    the first code of event handling is given in book "head first java " and working fine
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Swingdemo implements ActionListener {
        JButton jbut = new JButton("Click me");
          public void go(){
            JFrame jfrm = new JFrame(" sample swing");
            JLabel jlab = new JLabel("hello Swing");
            jfrm.add(BorderLayout.NORTH,jlab);
            jfrm.add(BorderLayout.CENTER,jbut);
            jfrm.setVisible(true);
            jbut.addActionListener(this); 
            jfrm.setSize(100,100);
            jfrm.setDefaultCloseOperation(jfrm.EXIT_ON_CLOSE);
       public static void main(String[] args) {
            Swingdemo obj = new Swingdemo();
            obj.go();
    public void actionPerformed(ActionEvent e)
        jbut.setText("i have been clicked");
    }}THe second code which i think is fine is giving the following error :-
    C:\java\iodemo\src\Swingdemo.java:26: non-static variable jbut cannot be referenced from a static context
            jfrm.add(BorderLayout.CENTER,jbut);
    C:\java\iodemo\src\Swingdemo.java:28: non-static variable this cannot be referenced from a static context
            jbut.addActionListener(this); 
    C:\java\iodemo\src\Swingdemo.java:28: non-static variable jbut cannot be referenced from a static context
            jbut.addActionListener(this);  the second code is as follows :-
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Swingdemo implements ActionListener {
    public static void main(String[] args) {
    JFrame jfrm = new JFrame(" sample swing");
    JLabel jlab = new JLabel("hello Swing");
    jfrm.add(BorderLayout.NORTH,jlab);
    jfrm.add(BorderLayout.CENTER,jbut);
    jfrm.setVisible(true);
    jbut.addActionListener(this);
    jfrm.setSize(100,100);
    jfrm.setDefaultCloseOperation(jfrm.EXIT_ON_CLOSE);
    JButton jbut = new JButton("Click me");
    public void actionPerformed(ActionEvent e)
    jbut.setText("i have been clicked");
    Plz help me wat this error means that not static variable cannot be reffered from static context .
    thanks

    There are multiple problems in your 2nd set of code. You call this:
    jfrm.add(BorderLayout.CENTER,jbut);
    Before you actually create the jbut button:
    JButton jbut = new JButton("Click me");
    But based on the error message, you have another 'jbut' variable somewhere that's not included in the code you posted, and that's the one it's complaining about being referenced in a static context.
    The problem with the static context is because all your code is in the static void main method. In that method, a Swingdemo instance doesn't exist yet, therefore any non-static variables won't exist yet either. If you move all that code into the Swingdemo constructor, and just have main create a new Swingdemo instance, that should do it.

  • What's different between event handle by bsp frame & MAC

    Hi,
    Can anyone know the different between event handle by BSP frame & handle by MAC?
    and how to know which event is handle by BSP frame or MAC?
    thanks
    Gang

    Hi Abdul,
    So that means the add_entry event is standard event handle by BSP frame.
    thanks
    Gang

  • Difference between method,event handler,supply function.

    hi,
    i wants to know what is the difference between
    method.
    event handler.
    supply funciton.
    Regards:
    Pankaj Aggarwal

    Hi Pankaj,
    These are few lines from the F1 help documentation given,
    Web Dynpro: Method Type :The type of a method defines whether you have an event handler, a supply
                                                function, or a (normal) method.
      Event Handler : Handlers of an event, a controller, an action, or an inbound plug of a view.
       Method : Modularization unit within a view or a controller.Methods of a view can only be called locally
                       within this view.Methods of a controller (component or custom controller) can also be called from
                       a view or another controller, provided the controller is entered as controller used .
       Supply Function : Method for filling a context node.
    For more information refer to the Thomas post
    Regards,
    Sravanthi

  • Swing locks up during event handling of a simple button... bug or feature?

    I have the following code:
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JToolBar;
    import javax.swing.SwingUtilities;
    public class Test extends JFrame {
         private static final long serialVersionUID = 1L;
         private JButton button;
         public static void main(String[] args)
              SwingUtilities.invokeLater(new Runnable(){public void run(){new Test();}});
         public Test()
              setSize(200,00);
              setLayout(new BorderLayout());
              JToolBar toolbar = new JToolBar();
              button = new JButton("button");
              button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { button.setEnabled(false);}});
              toolbar.add(button);
              getContentPane().add(toolbar, BorderLayout.SOUTH);
              JPanel panel = new JPanel();
              panel.setPreferredSize(new Dimension(200,10000));
              for(int i=0;i<10000; i++) { panel.add(new JLabel(""+(Math.random()*1000))); }
              JScrollPane scrollpane = new JScrollPane();
              scrollpane.getViewport().add(panel);
              scrollpane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
              scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
              scrollpane.setPreferredSize(getSize());
              scrollpane.setSize(getSize());
              getContentPane().add(scrollpane, BorderLayout.CENTER);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setLocationRelativeTo(null);
              setVisible(true);
              pack();
    }This code is lethal to swing: when pressing the button, for no identifiable reason the entire UI will lock up, even though all the event handler is doing is setting the button's "enabled" property to false. The more content is located in the panel, the longer this locking takes (set -Xmx1024M and the label loop to 1000000 items, then enjoy timing how long it takes swing to realise that all it has to do is disable the button...)
    Does anyone here know of how to bypass this behaviour (and if so, how?), or is it something disastrous that cannot be coded around because it's inherent Swing behaviour?
    I tried putting the setEnabled(false) call in a WorkerThread... that does nothing. It feels very much like somehow all components are locked, while the entire UI is revalidated, but timing revalidation shows that the panel revalidates in less than 50ms, after which Swing's stalled for no reason that I can identify.
    Bug? Feature?
    how do I make it stop doing this =(
    - Mike

    However, if you replace "setEnabled(false)" with "setForeground(Color.red)") the change is instant,I added a second button to the toolbar and invoked setEnabled(true) on the first button and the change is instant as well. I was just looking at the Component code to see the difference between the two. There are a couple of differences:
        public void setEnabled(boolean b) {
            enable(b);
         * @deprecated As of JDK version 1.1,
         * replaced by <code>setEnabled(boolean)</code>.
        @Deprecated
        public void enable() {
            if (!enabled) {
                synchronized (getTreeLock()) {
                    enabled = true;
                    ComponentPeer peer = this.peer;
                    if (peer != null) {
                        peer.enable();
                        if (visible) {
                            updateCursorImmediately();
                if (accessibleContext != null) {
                    accessibleContext.firePropertyChange(
                        AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
                        null, AccessibleState.ENABLED);
         * @deprecated As of JDK version 1.1,
         * replaced by <code>setEnabled(boolean)</code>.
        @Deprecated
        public void enable(boolean b) {
            if (b) {
                enable();
            } else {
                disable();
         * @deprecated As of JDK version 1.1,
         * replaced by <code>setEnabled(boolean)</code>.
        @Deprecated
        public void disable() {
            if (enabled) {
                KeyboardFocusManager.clearMostRecentFocusOwner(this);
                synchronized (getTreeLock()) {
                    enabled = false;
                    if (isFocusOwner()) {
                        // Don't clear the global focus owner. If transferFocus
                        // fails, we want the focus to stay on the disabled
                        // Component so that keyboard traversal, et. al. still
                        // makes sense to the user.
                        autoTransferFocus(false);
                    ComponentPeer peer = this.peer;
                    if (peer != null) {
                        peer.disable();
                        if (visible) {
                            updateCursorImmediately();
                if (accessibleContext != null) {
                    accessibleContext.firePropertyChange(
                        AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
                        null, AccessibleState.ENABLED);
        }The main difference appears to be with the KeyboardFocusManager. So instead of using a toolbar, I changed it to a JPanel (so the buttons are focusable). I then notice the same lag when I try to tab between the two buttons. So the problem is with the focus manager, not the setEnabled() method.

  • Input value given on web page is not getting pickedup in event handler

    Hi friends,
    I have created one simple page in SE80 with program with flow logic option, in which I would like to show business partner details from BUT000 table with the input of partner number. But the thing is the input value(partner no.)which I am giving on web page is not getting picked up in selection in event handler though I am giving input value it is becoming initial while selecting. What could be the reason?
    Below I am mentioning the code which I have written in even handler for OnInputProcessing event.
    CASE EVENT_ID.
    WHEN 'select'.
    NAVIGATION->SET_PARAMETER( 'partner' ).
    SELECT * FROM but000 INTO TABLE I_but000 WHERE partner BETWEEN partner AND partner1.
    WHEN OTHERS.
    ENDCASE.
    Thanks in advance,
    Steve

    Hi Abhinav,
    I tried with the one you posted. But it is giving run time error as shown below.
    Note
    The following error text was processed in the system CRD : Access via 'NULL' object reference not possible.
    The error occurred on the application server crmdev_CRD_00 and in the work process 0 .
    The termination type was: RABAX_STATE
    The ABAP call stack was:
    Method: ONINPUTPROCESSING of program CLO24DDFJW575HVAQVJ89KWHEHC9OCP
    Method: %_ONINPUTPROCESSING of program CL_O24DDFJW575HVAQVJ89KWHEHC9OCP
    Method: DO_REQUEST of program CL_BSP_PAGE===================CP
    Method: ON_REQUEST of program CL_BSP_RUNTIME================CP
    Method: IF_HTTP_EXTENSION~HANDLE_REQUEST of program CL_HTTP_EXT_BSP===============CP
    Method: EXECUTE_REQUEST_FROM_MEMORY of program CL_HTTP_SERVER================CP
    Function: HTTP_DISPATCH_REQUEST of program SAPLHTTP_RUNTIME
    Module: %_HTTP_START of program SAPMHTTP
    Regards,
    Steve

  • Problem with event handling

    Hello all,
    I have a problem with event handling. I have two buttons in my GUI application with the same name.They are instance variables of two different objects of the same class and are put together in the one GUI.And their actionlisteners are registered with the same GUI. How can I differentiate between these two buttons?
    To be more eloborate here is a basic definition of my classes
    class SystemPanel{
             SystemPanel(FTP ftp){ app = ftp};
             FTP app;
             private JButton b = new JButton("ChgDir");
            b.addActionListener(app);
    class FTP extends JFrame implements ActionListener{
               SystemPanel rem = new SystemPanel(this);
               SystemPanel loc = new SystemPanel(this);
               FTP(){
                       add(rem);
                       add(loc);
                       pack();
                       show();
           void actionPerformed(ActionEvent evt){
            /*HOW WILL I BE ABLE TO KNOW WHICH BUTTON WAS PRESSED AS THEY
               BOTH HAVE SAME ID AND getSouce() ?
               In this case..it if was from rem or loc ?
    }  It would be really helpful if anyone could help me in this regard..
    Thanks
    Hari Vigensh

    Hi levi,
    Thankx..
    I solved the problem ..using same concept but in a different way..
    One thing i wanted to make clear is that the two buttons are in the SAME CLASS and i am forming 2 different objects of the SAME class and then putting them in a GUI.THERE IS NO b and C. there is just two instances of b which belong to the SAME CLASS..
    So the code
    private JButton b = new JButton("ChgDir");
    b.setActionCommand ("1");
    wont work as both the instances would have the label "ChgDir" and have setActionCommand set to 1!!!!
    Actually I have an array of buttons..So I solved the prob by writting a function caled setActionCmdRemote that would just set the action commands of one object of the class differently ..here is the code
    public void setActionCommandsRemote()
         for(int i = 0 ; i <cmdButtons.length ; i++)
         cmdButtons.setActionCommand((cmdButtons[i].getText())+"Rem");
    This just adds "rem" to the existing Actioncommand and i check it as folows in my actionperformed method
         if(button.getActionCommand().equals("DeleteRem") )          
                        deleteFileRemote();
          else if(button.getActionCommand().equals("Delete") )
                     deleteFileLocal();Anyway thanx a milion for your help..this was my first posting and I was glad to get a prompt reply!!!

  • Event handling in JList

    hello to all!!!
    i am having a problem in JList event handling.Following is my code--
    public void valueChanged(ListSelectionEvent  lse)
    {index = list.getSelectedIndex();
    if(index==0)
                     System.out.println( "index"+index);
                     System.out.println("1st frame now opened");
               JFrame f2=new JFrame();
                    JPanel p1=new JPanel();
              f2.getContentPane().add(p1);                    
              JLabel l10=new JLabel("id");
              JTextField t100=new JTextField(20);
              p1.add(l10);
              p1.add(t100);
              p1.add(l11);//declared in constructor
              setDefaultCloseOperation(EXIT_ON_CLOSE);
              f2.setVisible(true);
    if(index==1)
              System.out.println("now index is"+index);
              }My problem is that 2 frames get opened whenever index==0 .even the code written in System.out.println() is displayed 2 times on the screen.2 JFrames open up whenever index==0.i want that only 1 JFrame should be opened.and moreover 1 of the JFrame does not contain the JLabel that is declared in the constructor.and when index==1,then The index value is displayed 2 times on the screen.i want that only 1 value should be there.any help would be highly appreciated.thanks in advance.

    even after entering if (lse.getValueIsAdjusting())
    }index = list.getSelectedIndex();i am having the same value.my problem is not when value of index changes.even if i use only 1 st index (i.e. only click on academic record) than also 2 frames open up.i entered this code after if(index==0) and if if(index==1).but it was of no help.same problem of 2 times each event occuring is there.
    urgent Help required.any help would be highly appreciated.thnx in advance

  • OIm11g event handler-Bulk Orchestration

    Hi All,
    Can anyone help me with a sample code of bulk orchestration.
    Can i just copy and paste my execute() code in bulkexecute?
    My requirement is that my event handler shd work for a single user event
    Thanks
    -Mukul

    In case of updating a user from the console directly, in the Event Handlers one can implement the method
    public EventResult execute(long l1, long l2, Orchestration orchestration)This will get the CURRENT_USER_STATE and NEW_USER_STATE. For example, the user old attributes and the new changed attributes from the Orchestration class as :
    hm = orchestration.getInterEventData();
    oracle.iam.identity.usermgmt.vo.User oldUsr = (oracle.iam.identity.usermgmt.vo.User) hm.get(CURRENT_USER);
    oracle.iam.identity.usermgmt.vo.User newUsr = (oracle.iam.identity.usermgmt.vo.User) hm.get(NEW_USER_STATE);But in case of reconciliation from the database,one may want to implement the method
    public BulkEventResult execute(long arg0, long arg1, BulkOrchestration bulkOrchestration)There's a difference between single event and bulk event orchestration. In single event orchestration the interEventData gets populated with CURRENT_USER and NEW_USER_STATE, where each is an object storing the User's properties. But, bulk orchestration does not concern a single user. It's concern is multiple users in one event.
    CURRENT_USER and NEW_USER_STATE are still there, but they are not a single User object. They are actually an array of Identity objects (Identity is a superclass of User).

Maybe you are looking for