JComboBox action listener

I have registered an action listener on a JComboBox.. I change the selected value of this combobox from another component's actions also.. My question is how can i distinguish between an action event in which an item was selected using the combo box directly and an event in which the selected value in the combo box was set by different comopnent.. the actionEvent.getSource gives the combo box itself..
Is using a mouselistener the only way out??

You can't and its a bad design to attempt to do so.dont know about bad design but.. in my case its required. I have to make a file chooser type User interface for browsing an ftp site.. So the combo box needs to be updated when the user changes a directory by double clicking on the directory.. Could i do something else?? please suggest anything u can
>
Is using a mouselistener the only way out?? What about if the user uses the key board to select
the item from the combo box? Would you also need to
write your own KeyListener? Getting very ugly.good point.. didnt think about this....now i understand why they used action listener
>
As a workaround, you could add code to your "other"
compnent:
comboBox.removeActionListener(...);
comboBox.setSelectedItem(...);
comboBox.addActionListener(...);thanks, does this have a significant performance penalty.. I mean it does not look good does it??

Similar Messages

  • Notify JComboBox action listener ?

    Hi,
    i would like to notify the action listener of a JComboBox by myself (like doing a doClick for a JButton). What is the method that i could use for it ?

    JComboBox cbo1;
    cbo1.addItemListener(this);
    or you could use
    cbo1.addActionListener(this);
    for the first one have
    public void itemStateChanged(ItemEvent ie)
    if(ie.getSource()==cbo1)
    your code
    extend interface ItemListener
    for second one have
    public void actionPerformed(ActionEvent ae)
    if(ie.getSource()==cbo1)
    your code
    extend interface ActionListener
    Is this what u need ?

  • Speed issue with Action Listener

    I have a JCombobox that has an action listener that waits for an action to be performed.
    When I update the Combobox list by using removeAllItems() and then loop additem on an array to rebuild it, It take 14 seconds to rebuild the list.
    When I remove my action listener, it does it instantly. I tried setEnable(false) on my combobox to disable the action listener temporarily while I update the combobox, but it doesn't appear to work.
    Looking for a way to disable my listener temporarily to increase performance when I update it.
    Thanks in advance.

    Nevermind. got it.

  • Pass arguments inside action listener

    Hi everybody, I have a bunch of combo boxes which I have stored in an array. Now I have action listeners on these and i wanna know which combo box of the array element has been called. Like lets say ihave combobox = new JComboBox. I want to know the value of "i" inside the action listener when that particular combo box is called. I am not sure whether I have explained it well enuf, but please let me know if thats the case. I need some urgent help on this.

    No its not that I guess. I have this loop where u run thru it for i = n lets say and create an array of comboboxes. Now I have to know whenever which of these comboboxes has been fired. lets say combobox # 5 in the array has been fired then somehow I have to know and get this value 5 (which I have to store in a class variable). Hope I made myself clear this time.
    You can always call getSource() on the action
    event to figure out which component fired it. Is this
    what you are looking for? I think your message is
    missing a section in the middle.
    Mitch Goldstein
    Author, Hardcore JFC (Cambridge Univ Press)
    [email protected]

  • How can i disable an Action listener temporary?

    hi folks,
    I have a GUI with many Jcomboxes. Each one of them has an actionlistener.
    The idea was: when one of those comboboxes is selected, then the selected value will appear on ALL the comboboxes (by using setSelectedIndex(int index)).
    The problem is when i select a value on ONE of those comboboxes and set it on the others, the actionListener thinks that i selcted a value on the other comboboxes and starts setting the values again... I other words if i select one combobox i obtain an endless loop...
    Is it possible to disable the action listener temporary when setting the selectd values on the other comboboxes?

    Just use removeActionListener and then addActionListener
    Noah

  • Property on Backing Bean is Not set when Action Listener is Fired

    Why is it that when my action listener is invoked, the property for my other component on the page has not been reflected in model yet?
    Here is what I have:
    My JSP has the following two components:
    <h:inputText value="#{manageQuestionBean.newStory}"></h:inputText>
    <h:commandButton value="add" actionListener="#{manageQuestionBean.onAddStory}"></h:commandButton> My Java code has the following:
    public void onAddStory(ActionEvent event) {
           //This always prints out 'null'
           System.out.println("The value of 'newStory' is: " + newStory);
          //TO DO: this is where the logic would go for creating a new story object.
        } When I put logging statements inside my setter for the newStory property, I see that it is being set to the right value, but then it being reset to empty string. Why is that? During what phase do the action listeners get invoked?

    Which JSF implementation/version are you using?
    mczauz wrote:
    When I put logging statements inside my setter for the newStory property, I see that it is being set to the right value, but then it being reset to empty string. Why is that? When exactly happens when exactly?
    During what phase do the action listeners get invoked?The invoke application phase, after the update model values phase.
    You may find this article useful to learn about phases and how to add a 'phase debugger' yourselfl: [http://balusc.blogspot.com/2006/09/debug-jsf-lifecycle.html].

  • Transaction Posting Confirmation Message and Action Listener behaviour

    Hi, I have a scenario that a user is Posting a Transaction and when he press the “Post” Button a, confirmation dialog box should popup asking “Do you really want to Post the record ?”. If the user press “Yes” the record is further process and If the user press “No” then the transaction should not proceed.
    I have implemented the main screen(PostTransaction.java) and the popup confirmation window(ConfirmationWindow.java)
    Question 1 ) Why the code is not stoping in the Post Button Action listener as in JOptionPane, then how do i know that the user has selected "Yes" or "No" ?
    Question 2) Do I have to write the code for posting of a Transaction(postTransaction() method) in the “ConfirmationWindow”? or it should be in “PostTransaction”.
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.application.Application;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.Label;
    import javafx.scene.control.TextField;
    import javafx.scene.layout.GridPane;
    import javafx.stage.Stage;
    public class PostTransaction extends Application{
           public void start(final Stage stage) throws Exception {
                  Group root = new Group();
                  Scene scene = new Scene(root, 300,300);
                  stage.setScene(scene);
                  stage.setTitle("Transaction Post Screen");
                  GridPane gp = new GridPane();
                  Label lblName = new Label("Name");
                  Label lblAmount = new Label("Amount");
                  TextField txtName = new TextField();
                  TextField txtAmount = new TextField();
                  Button btnPost = new Button("Post Record");
                  gp.add(lblName, 1, 1);
                  gp.add(lblAmount, 1, 2);
                  gp.add(txtName, 2, 1);
                  gp.add(txtAmount, 2, 2);
                  gp.add(btnPost, 2, 3);
                  btnPost.setOnAction(new EventHandler<ActionEvent>() {
                        @Override
                        public void handle(ActionEvent arg0) {
                             //The code does not stop here as in JOptionPane, then how do i know that the user has selected "Yes" or "No" ??
                             boolean popupResult = ConfirmationWindow.confirmTranactionPosting(stage, "Please Confirm");
                             if(popupResult==true){
                                  //This line is printed before the user selects yes or no
                                  System.out.println("Proceeding with Tranaction Posting");
                                  //postTransaction();
                             if(popupResult==false){
                                  //This line is printed before the user selects yes or no
                                  System.out.println("Do not Proceed with Tranaction Posting");
                 root.getChildren().add(gp);
                stage.show();
                public static void main(String[] args) {
                  launch(args);
              private void postTransaction(){
                   //write the code for posting here
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.Label;
    import javafx.scene.layout.BorderPane;
    import javafx.scene.layout.HBox;
    import javafx.stage.Modality;
    import javafx.stage.Stage;
    import javafx.stage.StageStyle;
    public class ConfirmationWindow extends Stage {
         Stage owner;
         Stage stage;
         BorderPane root;
         static boolean postStatus = false;
      public ConfirmationWindow( Stage owner, String title){
        root = new BorderPane();
        stage = this;
        this.owner = owner;
        initModality( Modality.APPLICATION_MODAL );
        initOwner( owner );
        initStyle( StageStyle.UTILITY );
        setTitle( title );
        setContents();
      public void setContents(){
        Scene scene = new Scene(root,250,150);
        setScene(scene);
        Group groupInDialog = new Group();
        groupInDialog.getChildren().add( new Label("Do you really want to Post this record ?") );
        root.setCenter( groupInDialog );
        Button yes = new Button( "Yes" );
        yes.setOnAction(new EventHandler<ActionEvent>() {
              @Override
              public void handle(ActionEvent e) {
                   postStatus =true;
                   stage.close(); // Close the pop up. Transfer control to PostTransaction.java and execute the PostTransaction() method.
        Button no  = new Button( "No" );
        no.setOnAction(new EventHandler<ActionEvent>() {
              @Override
              public void handle(ActionEvent e) {
                   postStatus =false;
                   stage.close(); // Close the pop up only
        HBox buttonPane = new HBox();
        buttonPane.setSpacing(10);
        buttonPane.getChildren().addAll(yes,no);
        root.setBottom(buttonPane);
        stage.show();
      public static boolean confirmTranactionPosting(Stage owner, String title) {
           new ConfirmationWindow(owner, title);
           return postStatus;
    }

    The MII Message listener is a queue. But when I understand you correctly, you do not want to process the messages immediately after arriving in the Listener.
    Maybe the categorization of messages is an option for you (see [Sap Help: Processing Rule Editor - Category|http://help.sap.com/saphelp_mii121/helpdata/en/43/e80b59ad40719ae10000000a1553f6/frameset.htm]. You can enter a category for the control recipe messages. The messages will then be placed in the Listener queue. You can use the [Message Services|http://help.sap.com/saphelp_mii121/helpdata/en/43/e80b59ad40719ae10000000a1553f6/frameset.htm] actions to read the categorized messages and process them as you need.
    In addition to Manoj, you may also use the [Queueing actions|http://help.sap.com/saphelp_mii121/helpdata/en/43/e80b59ad40719ae10000000a1553f6/frameset.htm] of MII, where you can queue xml contents.
    Hope this helps.
    Michael

  • I need a code example for an action listener for a jcheckbox using matisse

    I am trying to make it so that when some body clicks a jcheckbox it will put a figure into a jtextfield. Because I am using matisse I need to know the code for the action listener and I need to know quickly as well so I don't have time to look it up with searches etc.
    Can anbody provide me with some example code please.

    I thought that as you are all more experienced than I am that you would know where to look and as you would have already been to all of the sites you would have been able to save me a lot of time looking for the best one. I didn't mean to insult you sorry, I knew that I would be looking for a long time and hoped that some one could help speed that up for me.
    Any way I have obviously annoyed you in that thread earlier this week. I know that you are all pee'd at me and don't believe me and that is fine. I have learnt every thing that I need to learn and would like to thank you for your help although I think that your language in your last post was not very pleasant, but that is ok.
    I don't want to continue posting any more. But thank you for your help.

  • Issue with setting an Action Listener for a Command Button

    Hi all,
    I'm trying to set an action listener for a CoreCommanButton in a backing bean. Here's my code:
         CoreCommandButton editBtn = new CoreCommandButton();
              MethodBinding mb = FacesContext.getCurrentInstance().getApplication().createMethodBinding("#{backBean.doButtonAct}",null);
              editBtn.setActionListener(mb);
    //Action listener method
         public void doButtonAct(ActionEvent actionEvent)
    I keep getting a javax.faces.el.MethodNotFoundException error. However when I remove the ActionEvent parameter in doButtonAct(), I get a wrong number of arguments error.
    So i'm guessing there is something wrong with the parameters i accept in my action listener method. what can be causing this issue?
    Cheers.

    I figured this out.
    Since doButtonAct() requires an ActionEvent object as a parameter, i needed to define the parameter type when I create the method binding.
    Solution:
         Class argsString[] = new Class[] { ActionEvent.class };
              MethodBinding mb = FacesContext.getCurrentInstance().getApplication().createMethodBinding("#{backBean.doButtonAct}",argsString);

  • Calling action listener for a BUTTON component in java bean page

    Hi,
    I have made it like this.
    public void handleButtonPressed(ActionEvent event){
    System.out.println("success!!!!!");
    //code for calling actionlistener
    FacesContext fctx = FacesContext.getCurrentInstance();
    ELContext elctx = fctx.getELContext();
    Application application = fctx.getApplication();
    ExpressionFactory exprFactory = application.getExpressionFactory();
    MethodExpression methodExpr = null;
    methodExpr = exprFactory.createMethodExpression(elctx, "#{exbean.handleButtonPressed}",null,new Class[] { ActionEvent.class });
    MethodExpressionActionListener actionListener = null;
    actionListener = new MethodExpressionActionListener(methodExpr);
    button.addActionListener(actionListener);
    Even after making the listener Function as Void wHen i click the button i m getting the error saying."ARGUMENTS MISMATCH,ADF_FACES60097"??
    can you help me out?
    and in the msg log i m getting this
    "SkinFactoryImpl> <getSkin> Cannot find a skin that matches family portal and version v1.1. We will use the skin portal.desktop.
    <MethodExpressionActionListener> <processAction> Received 'javax.el.PropertyNotFoundException' when invoking action listener '#{exbean.handleButtonPressed}' for component 'null'
    <MethodExpressionActionListener> <processAction> javax.el.PropertyNotFoundException: Target Unreachable, identifier 'custombean' resolved to null"
    I Have tried with this giving Void TYPE as an argument
    methodExpr = exprFactory.createMethodExpression(elctx, "#{exbean.handleButtonPressed},Void.TYPE,new Class[] { ActionEvent.class });
    I M getting the same error.
    Edited by: chaya on Dec 22, 2011 2:47 PM

    yeah but i m creating button itself dynamically by java code....
    //code
    UIComponent button;
    button = findComponentInRoot("cb1");
    RichPanelGroupLayout pgl;
    pgl = (RichPanelGroupLayout)button.getParent();
    List<UIComponent> children;
    children = pgl.getChildren();
    RichPanelGroupLayout pgll;
    pgll = new RichPanelGroupLayout();
    RichInputText it;
    it = new RichInputText();
    it.setLabel("New textbox " + (children.size()));
    RichCommandButton but = new RichCommandButton();
    but.setPartialSubmit(true);
    but.setText("Delete");
    /*calling actionevent*/
    FacesContext fctx = FacesContext.getCurrentInstance();
    ELContext elctx = fctx.getELContext();
    Application application = fctx.getApplication();
    ExpressionFactory exprFactory = application.getExpressionFactory();
    MethodExpression methodExpr = null;
    methodExpr = exprFactory.createMethodExpression( elctx,"#{inbean.actionPerformed}",null, new Class[] {ActionEvent.class});
    MethodExpressionActionListener actionListener = null;
    actionListener = new MethodExpressionActionListener(methodExpr);
    but.addActionListener(actionListener);
    /*end of call*/
    children.add(pgll);
    children.add(it);
    children.add(but);
    AdfFacesContext.getCurrentInstance().addPartialTarget(pgl);
    //code to call method
    public void actionPerformed(ActionEvent event) {
    System.out.println("entered sec bean");
    return " ";}
    this way i m trying to create a button programatically and tryin to add actionlistener which is not working.
    the actionlistener is throwing error.... with the line
    methodExpr = exprFactory.createMethodExpression( elctx,"#{inbean.actionPerformed}",null, new Class[] {ActionEvent.class});

  • Problem with action listener

    hello
    the problem in my code is that i defined
    actionlistener for a button but it does not
    do what it should do . it throws an error in the console
    and i think my code is 100% correct what is the problem
    please help me this is the codewith
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    class Library extends JFrame implements ActionListener     {
         private JMenuBar jmb      = new JMenuBar();
         private JMenu books      = new JMenu("Books",true);
         private JMenu members      = new JMenu("Members",true);
         private JMenu loans      = new JMenu("Loans",true);
         private JMenuItem addNb = new JMenuItem("Add New Book");
         private JMenuItem listB = new JMenuItem("List All Books");
         private JMenuItem listAb = new JMenuItem("List Available Books");
         private JMenuItem listBb = new JMenuItem("List Borrowed Books");
         private JMenuItem addNm = new JMenuItem("Add New Member");
         private JMenuItem removeM = new JMenuItem("Remove a Member");
         private JMenuItem listAm = new JMenuItem("List All Members");
         private JMenuItem loanB = new JMenuItem("Loan A Book");
         private JMenuItem returnB = new JMenuItem("Return A Book");
         private JTextField bNumber = new JTextField(14);
         private JTextField bAuthor = new JTextField(14);
         private JTextField bTitle = new JTextField(14);
         private JTextField mId = new JTextField(14);
         private JTextField mName = new JTextField(14);
         private JTextField idB = new JTextField(14);
         private JTextField nBToB = new JTextField(14);
         private JTextField nBTor = new JTextField(14);
         private JTextArea dispaly = new JTextArea();
         private JButton oKb1 = new JButton("OK");
         private JButton okb2 = new JButton("OK");
         private JButton cloaseb = new JButton("Close");
         private JButton oKm1 = new JButton("OK");
         private JButton oKm2 = new JButton("OK");
         private JButton cancelM = new JButton("Cancel");
         private JButton oKm3 = new JButton("OK");
         private JButton oKm4 = new JButton("OK");
         private JButton cancelM2 = new JButton("Cancel");
         private JButton oKl = new JButton("OK");
         private JButton oKr = new JButton("OK");
         private JButton yes = new JButton("Yes");
         private JButton no = new JButton("No");     
         private JLabel bN = new JLabel("Book Number");
         private JLabel bA = new JLabel("Book Author");
         private JLabel bT = new JLabel("Book Title");
         private JLabel iN          = new JLabel("ID Number");
         private JLabel mN          = new JLabel("Member's Name");
         private JLabel     iNb          = new JLabel("ID number of the borrower");
         private JLabel nBb          = new JLabel("Number of the books to borrow");
         private JLabel nBr          = new JLabel("Number of the books to return");
         private JLabel mIdl     = new JLabel("ID number of the stuednt");
         private JPanel tempoIPanel= new JPanel(new FlowLayout());
         Container cp;
         JFrame mainFrame;
         JInternalFrame tempoI;
    Library()     {
         //LibraryClass lClass = new LibraryClass();/*
         mainFrame = new JFrame();
         mainFrame.setJMenuBar(jmb);
         mainFrame.setSize(800,550);
         mainFrame.getContentPane().setLayout(new FlowLayout());
         jmb.add(books);
         jmb.add(members);
         jmb.add(loans);
         books.add(addNb);
         addNb.addActionListener(this);
         books.add(listB);
         listB.addActionListener(this);
         books.add(listAb);
         listAb.addActionListener(this);
         books.add(listBb);
         listBb.addActionListener(this);
         members.add(addNm);
         addNm.addActionListener(this);
         members.add(removeM);
         removeM.addActionListener(this);
         members.add(listAm);
         listAm.addActionListener(this);
         loans.add(loanB);
         loanB.addActionListener(this);
         loans.add(returnB);
         returnB.addActionListener(this);
         //actions listeners
         oKb1.addActionListener(this);
         mainFrame.setVisible(true);
    public void actionPerformed(ActionEvent ae)     {
         if(ae.getSource() == addNb)     {
              tempoI = new JInternalFrame("Add new Book",true,true);
              mainFrame.getContentPane().add(tempoI);
              tempoI.getContentPane().setLayout(new FlowLayout());
              tempoI.getContentPane().add(bN);
              tempoI.getContentPane().add(bNumber);
              tempoI.getContentPane().add(bA);
              tempoI.getContentPane().add(bAuthor);
              tempoI.getContentPane().add(bT);
              tempoI.getContentPane().add(bTitle);
              tempoI.getContentPane().add(oKb1);//add action listener here
              tempoI.setVisible(true);
         if(ae.getSource() == listB)     {
              //LibraryClass.listBooks();
         if(ae.getSource() == listAb){}
         if(ae.getSource() == listBb){}
         if(ae.getSource() == addNm)     {
              tempoI = new JInternalFrame("Add new Member",true,true);
              mainFrame.getContentPane().add(tempoI);
              tempoI.getContentPane().setLayout(new FlowLayout());
              tempoI.getContentPane().add(iN);
              tempoI.getContentPane().add(mId);
              tempoI.getContentPane().add(mN);
              tempoI.getContentPane().add(mName);
              tempoI.getContentPane().add(oKm1);//add action listener
              tempoI.getContentPane().setSize(300,400);
              tempoI.setVisible(true);
         if(ae.getSource() == removeM)     {
              tempoI = new JInternalFrame("Rmove member",true,true);
              mainFrame.getContentPane().add(tempoI);
              tempoI.getContentPane().setLayout(new FlowLayout());
              tempoI.getContentPane().add(mIdl);
              tempoI.getContentPane().add(mId);
              tempoI.getContentPane().add(oKm2);//add action listener
              //LibraryClass.removeM(Double.parseDouble(mId.getText()));
              tempoI.getContentPane().setSize(300,400);
              tempoI.setVisible(true);
         if(ae.getSource() == listAm)     {
              //LibraryClass.listMembers();
         if(ae.getSource() == loanB)     {
              tempoI = new JInternalFrame("Loan book",true,true);
              mainFrame.getContentPane().add(tempoI);
              tempoI.getContentPane().setLayout(new FlowLayout());
              tempoI.getContentPane().add(iNb);
              tempoI.getContentPane().add(idB);
              tempoI.getContentPane().add(nBb);
              tempoI.getContentPane().add(nBToB);
              tempoI.getContentPane().add(oKl);
              //LibraryClass.borrowBook(Book bk,Member m);
              tempoI.getContentPane().setSize(300,400);
              tempoI.setVisible(true);
         if(ae.getSource() == returnB)     {
              tempoI = new JInternalFrame("Return Book",true,true);
              mainFrame.getContentPane().add(tempoI);
              tempoI.getContentPane().setLayout(new FlowLayout());
              tempoI.getContentPane().add(iNb);
              tempoI.getContentPane().add(idB);
              tempoI.getContentPane().add(nBr);
              tempoI.getContentPane().add(nBTor);
              tempoI.getContentPane().add(oKr);
              tempoI.getContentPane().setSize(400,300);
              tempoI.setVisible(true);
              //Book.addBook(bNumber.getText(),bAuthor.getText(),bTitle.getText());
    class ClubLibrarySystem     {
         public static void main(String[] args)     {
         new Library();
    }

    hello
    the problem in my code is that i defined
    actionlistener for a button but it does not
    do what it should do . it throws an error in the
    consoleWhat error?
    and i think my code is 100% correct what is theWell, but it isn't.
    Have you tried using a debugger?
    problem
    please help me this is the codewith
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    class Library extends JFrame implements
    ActionListener     {
         private JMenuBar jmb      = new JMenuBar();
         private JMenu books      = new JMenu("Books",true);
    private JMenu members      = new
    JMenu("Members",true);
    private JMenu loans      = new
    JMenu("Loans",true);
    private JMenuItem addNb = new JMenuItem("Add New
    Book");
    private JMenuItem listB = new JMenuItem("List All
    Books");
    private JMenuItem listAb = new JMenuItem("List
    Available Books");
    private JMenuItem listBb = new JMenuItem("List
    Borrowed Books");
    private JMenuItem addNm = new JMenuItem("Add New
    Member");
    private JMenuItem removeM = new JMenuItem("Remove a
    Member");
    private JMenuItem listAm = new JMenuItem("List All
    Members");
    private JMenuItem loanB = new JMenuItem("Loan A
    Book");
    private JMenuItem returnB = new JMenuItem("Return A
    Book");
         private JTextField bNumber = new JTextField(14);
         private JTextField bAuthor = new JTextField(14);
         private JTextField bTitle = new JTextField(14);
         private JTextField mId = new JTextField(14);
         private JTextField mName = new JTextField(14);
         private JTextField idB = new JTextField(14);
         private JTextField nBToB = new JTextField(14);
         private JTextField nBTor = new JTextField(14);
         private JTextArea dispaly = new JTextArea();
         private JButton oKb1 = new JButton("OK");
         private JButton okb2 = new JButton("OK");
         private JButton cloaseb = new JButton("Close");
         private JButton oKm1 = new JButton("OK");
         private JButton oKm2 = new JButton("OK");
         private JButton cancelM = new JButton("Cancel");
         private JButton oKm3 = new JButton("OK");
         private JButton oKm4 = new JButton("OK");
         private JButton cancelM2 = new JButton("Cancel");
         private JButton oKl = new JButton("OK");
         private JButton oKr = new JButton("OK");
         private JButton yes = new JButton("Yes");
         private JButton no = new JButton("No");     
    private JLabel bN = new JLabel("Book
    Number");
    private JLabel bA = new JLabel("Book
    Author");
    private JLabel bT = new JLabel("Book
    Title");
         private JLabel iN          = new JLabel("ID Number");
    private JLabel mN          = new JLabel("Member's
    Name");
    private JLabel     iNb          = new JLabel("ID number of the
    borrower");
    private JLabel nBb          = new JLabel("Number of the
    books to borrow");
    private JLabel nBr          = new JLabel("Number of the
    books to return");
    private JLabel mIdl     = new JLabel("ID number of
    the stuednt");
    private JPanel tempoIPanel= new JPanel(new
    FlowLayout());
         Container cp;
         JFrame mainFrame;
         JInternalFrame tempoI;
    Library()     {
         //LibraryClass lClass = new LibraryClass();/*
         mainFrame = new JFrame();
         mainFrame.setJMenuBar(jmb);
         mainFrame.setSize(800,550);
    mainFrame.getContentPane().setLayout(new
    FlowLayout());
         jmb.add(books);
         jmb.add(members);
         jmb.add(loans);
         books.add(addNb);
         addNb.addActionListener(this);
         books.add(listB);
         listB.addActionListener(this);
         books.add(listAb);
         listAb.addActionListener(this);
         books.add(listBb);
         listBb.addActionListener(this);
         members.add(addNm);
         addNm.addActionListener(this);
         members.add(removeM);
         removeM.addActionListener(this);
         members.add(listAm);
         listAm.addActionListener(this);
         loans.add(loanB);
         loanB.addActionListener(this);
         loans.add(returnB);
         returnB.addActionListener(this);
         //actions listeners
         oKb1.addActionListener(this);
         mainFrame.setVisible(true);
    public void actionPerformed(ActionEvent ae)     {
         if(ae.getSource() == addNb)     {
    tempoI = new JInternalFrame("Add new
    w Book",true,true);
              mainFrame.getContentPane().add(tempoI);
    tempoI.getContentPane().setLayout(new
    w FlowLayout());
              tempoI.getContentPane().add(bN);
              tempoI.getContentPane().add(bNumber);
              tempoI.getContentPane().add(bA);
              tempoI.getContentPane().add(bAuthor);
              tempoI.getContentPane().add(bT);
              tempoI.getContentPane().add(bTitle);
    tempoI.getContentPane().add(oKb1);//add action
    n listener here
              tempoI.setVisible(true);
         if(ae.getSource() == listB)     {
              //LibraryClass.listBooks();
         if(ae.getSource() == listAb){}
         if(ae.getSource() == listBb){}
         if(ae.getSource() == addNm)     {
    tempoI = new JInternalFrame("Add new
    w Member",true,true);
              mainFrame.getContentPane().add(tempoI);
    tempoI.getContentPane().setLayout(new
    w FlowLayout());
              tempoI.getContentPane().add(iN);
              tempoI.getContentPane().add(mId);
              tempoI.getContentPane().add(mN);
              tempoI.getContentPane().add(mName);
    tempoI.getContentPane().add(oKm1);//add action
    n listener
              tempoI.getContentPane().setSize(300,400);
              tempoI.setVisible(true);
         if(ae.getSource() == removeM)     {
    tempoI = new JInternalFrame("Rmove
    e member",true,true);
              mainFrame.getContentPane().add(tempoI);
    tempoI.getContentPane().setLayout(new
    w FlowLayout());
              tempoI.getContentPane().add(mIdl);
              tempoI.getContentPane().add(mId);
    tempoI.getContentPane().add(oKm2);//add action
    n listener
              //LibraryClass.removeM(Double.parseDouble(mId.getText
              tempoI.getContentPane().setSize(300,400);
              tempoI.setVisible(true);
         if(ae.getSource() == listAm)     {
              //LibraryClass.listMembers();
         if(ae.getSource() == loanB)     {
              tempoI = new JInternalFrame("Loan book",true,true);
              mainFrame.getContentPane().add(tempoI);
    tempoI.getContentPane().setLayout(new
    w FlowLayout());
              tempoI.getContentPane().add(iNb);
              tempoI.getContentPane().add(idB);
              tempoI.getContentPane().add(nBb);
              tempoI.getContentPane().add(nBToB);
              tempoI.getContentPane().add(oKl);
              //LibraryClass.borrowBook(Book bk,Member m);
              tempoI.getContentPane().setSize(300,400);
              tempoI.setVisible(true);
         if(ae.getSource() == returnB)     {
    tempoI = new JInternalFrame("Return
    n Book",true,true);
              mainFrame.getContentPane().add(tempoI);
    tempoI.getContentPane().setLayout(new
    w FlowLayout());
              tempoI.getContentPane().add(iNb);
              tempoI.getContentPane().add(idB);
              tempoI.getContentPane().add(nBr);
              tempoI.getContentPane().add(nBTor);
              tempoI.getContentPane().add(oKr);
              tempoI.getContentPane().setSize(400,300);
              tempoI.setVisible(true);
              //Book.addBook(bNumber.getText(),bAuthor.getText(),bT
    tle.getText());
    class ClubLibrarySystem     {
         public static void main(String[] args)     {
         new Library();

  • Calling Action listener in Custom component

    Hello,
    I am currently developing my own component containing an hyper-link and I am stuck with the Renderer. What should I put in the href of my "a" tag (<a href="???">) in order to call an Action listener ? I would like my renderer to do something similar to <h:commandLink actionListener="#{myBean.myActionListener}".
    Could you help me?
    Gerald.</a>

    Hello,
    Did you achieve this??? I'm also planing to put very similar to your thought. If you have a solution on your requirement, pls mail me to [email protected]
    Thanks in Advance.
    regards,
    Ram

  • Is there a way to have the same action listener for few buttons?

    guys, lets say i have button1, button2 and button3
    how do i add the same action listener for 3 of them. doing 3 different action listener is very tedius! my assignment have almots 100 buttons but I need their action listener to be the same.

    Hi,
    Your class needs an action listener, so add implements ActionListener to you class creation string.
    Then on each button set an action command;
    button1.setActionCommand(BUTTON1);Now add an listener;
    buttons1.addActionListener(this);Finally create a method to perform a task
    public void actionPerformed(ActionEvent e)
       if (e.getActionCommand().equals(BUTTON1))
           xxxx   
      }This should do the trick.
    adelebt

  • Action Listener Method called multiple times

    I have a page (fragment .jsff), containing a simple input text and a button called "search". When I click on "Search" the action listener is triggered multiple times. (The results are displayed in a table inside a panel collection).
    The results are actually coming back ok.
    When I debug the code, I can see the action listener method called twice.
    Do you know why is that?
    What should I be taking care of?
    This is my code :
    *** Fragment ****
    <af:commandButton text="#{identityBundle.search_label}" id="cb1"
    actionListener="#{UserDetailsBean.searchUsersListener}"
    disabled="#{!bindings.searchUsers.enabled}"/>
    *** Managed bean ***
    public void searchUsersListener(ActionEvent actionEvent) {
    // Add event code here...
    DCBindingContainer bindings = (DCBindingContainer)getBindings();
    DCIteratorBinding iter = bindings.findIteratorBinding("userIterator");
    DCDataRow row = (DCDataRow)iter.getCurrentRow();
    User user = (User)row.getDataProvider();
    boolean isSearchCriteriaPresent = false;
    if(user != null){
    String fn = user.getFirstname();
    if(fn != null && !fn.trim().equals("")){
    isSearchCriteriaPresent = true;
    user.setLastname(fn);
    user.setNonMTUserLogin(fn);
    try {
    Map <Object, Object> userMap = PropertyUtils.describe(user);
    for(Map.Entry<Object, Object> entry: userMap.entrySet()){
    if(entry.getKey() != null && entry.getValue() != null && !entry.getKey().toString().equalsIgnoreCase("class")){
    isSearchCriteriaPresent = true;
    break;
    } catch (IllegalAccessException e) {
    e.printStackTrace();
    } catch (InvocationTargetException e) {
    e.printStackTrace();
    } catch (NoSuchMethodException e) {
    e.printStackTrace();
    if(!isSearchCriteriaPresent){
    user.setFirstname("*");
    OperationBinding opBinding = (OperationBinding)bindings.getOperationBinding("searchUsers");
    opBinding.getParamsMap().put("user", user);
    opBinding.execute();
    AdfFacesContext adfFacesCtx = AdfFacesContext.getCurrentInstance();
    Map<String, Object> scopePageFlowScopeVar= adfFacesCtx.getPageFlowScope();
    scopePageFlowScopeVar.put("userSearchCriteria", user);
    ADFContext adfCtx = ADFContext.getCurrent();
    Map sessionScope = adfCtx.getSessionScope();
    sessionScope.put("userSearchCriteria", user);
    setUserSearchCriteria(user);
    if(selectedUserID != null){
    selectedUserID.setValue(null);
    RichTable table = getUserResultsTable();
    DCIteratorBinding searchUsersIterator = (DCIteratorBinding)bindings.get("searchUsersIterator");
    Row[] rows = searchUsersIterator.getAllRowsInRange();
    if(rows.length > 0){
    RowKeySetImpl rks = new RowKeySetImpl();
    ArrayList keyList = new ArrayList();
    keyList.add(rows[0].getKey());
    rks.add(keyList);
    table.setSelectedRowKeys(rks);
    table.setDisplayRowKey(keyList);
    refreshState(table);
    if(!isSearchCriteriaPresent){
    user.setFirstname(null);
    else{
    deleteUserButton.setDisabled(true);
    resetPasswordButton.setDisabled(true);
    enableUserButton.setDisabled(true);
    disableUserButton.setDisabled(true);
    Thanks in advance for your help

    Hi,
    Can you try this?
    1. set partialSubmit=true for the "search" button
    2. set "search" button id as partialTrigger in your result table
    -Prasad

  • How to create a single action listener for a group of buttons

    hi there.. i am new at java and i have a problem with my applet..
    i am doing a virtual ticket programme..
    i have a tab that says books seats.. in the tab, i am suppose to create 50 buttons.
    i have done that already by using for (int i=1; i<=10;i++) 5 times for 50 buttons.
    but i do not know how to set an actionlistener in the for loop for each of these buttons..
    For example, if the user were to chose seat "no3" , a text area(already created) below will show something like "no3" and so on..
    how do i bind these buttons into one single action listener so i do not have to create 50 actionlisteners and buttons individually..
    appreciate the help..

    You're killing me.
    class MyFrame extends JFrame implements ActionListener
         JTextArea myTextArea = new JTextArea();
         JButton myButton = new JButton("My Button");
         JButton otherButton = new JButton("Other Button");
         MyFrame()
              super();
              myButton.addActionListener(this);
              otherButton.addActionListener(this);
              setLayout(new FlowLayout());
              add(myButton);
              add(otherButton);
              add(myTextArea);
         public void actionPerformed(ActionEvent e)
              Object source = e.getSource();
              if(source == myButton)
                   myTextArea.append("My Button Pressed\n");
              else if(source == otherButton)
                   myTextArea.append("Other Button Pressed\n");
    }

Maybe you are looking for

  • Can't save a file in DW CS6

    i open a single file in DW CS6 and make a change I chose File > Save and it doesn't save the file (asterisk is still next to the tab) If i close the file, DW prompts that the file has been modified and then the save works. Also, if i do a File > Save

  • Modvat in excise report

    Hello SAP Experts, We have received a invoice from Prime Engineer & they given modvat on Honeywell India ltd. At time of excise report Modvat should shown on Honeywell India ltd & Purchase entry on Prime Engineer(payment party) How to handle this iss

  • Web Services will not connect

    I have a Officejet 8500A Plus. Trying to setup web services. Every time i try to connect I get the message "A proxy address might be required to connect to Web Services." I do not use a proxy server. I'm connected to the internet via Cox cable, throu

  • How to arrange month in order in cross tab in crystal report

    Hi all,       we are using cross tab to arranging the data (month wise)  in crystal report. we have month in string format like jan2008. this field is in column of the cross tab. now we need to arrange the month in sorted order. At Present , the mont

  • How to start the emulator from eclipse

    Hello everybody, i've just installed Java_ME_platform_SDK_3.0 on my XP machine and i use eclipse helios with the eclipseme plugin for developing midlets. now, when i start a simple midlet with the emulator for my nokia device (S60_3rd_FP2_SDK_v1.1) t