ActionListener and other methods

Hi.
Is it possible to call other methods (from within the same class) into an ActionListener method?

samBe wrote:
Yes I tried it but it doesnt seem to work. Does anybody know if it could work and how?Then you may be trying it wrong, I think, because it should work. What you need to do is show us a small example of your trial code preferably in a small compilable program. When you post the code, please don't forget to use code tags so that your code remains readable.
Good luck.

Similar Messages

  • Separated GUI, ActionListener and other Listener like a DocumentListener

    Hi there
    Has someone of you an idea how to get the text from JTextbox when the Action is handeld in a separated "Action class"?
    I tried it already with a TextListener and a DocumentListener but without success.
    I use the following model all in the same package:
    Class 1:
    public static void main(String[] args)
         Commands commands = new Commands();
         UserInterface gui = new UserInterface(commands);
    Class 2:
    public class UserInterface
    extends JFrame
    JTextField textfield = new JTextField();
    Class 3:
    public class Commands
    extends JFrame
    implements ActionListener
    public void actionPerformed(ActionEvent event)
    Thank you all for your attention and answers.
    Philipp

    I think if you make th class2 like
    Class 2:
    public class UserInterface
    extends JFrame
    public JTextField textfield = new JTextField();// Imeen as a member in the class
    and in the class 3
    public class Commands
    extends JFrame
    implements ActionListener
    UserInterface u = new UserInterface();
    u.textfield.addActionListener();
    public void actionPerformed(ActionEvent event)
    I think it will work.

  • Plain Explain  and s methods (tools) for  to improve Performance

    Hi
    How can I do to use Plain Explain and others methods for to impove performance ?
    Where can I to find tutorial about it ?
    thank you in advance

    Hi
    How can I do to use Plain Explain and others
    methods for to impove performance ?
    Internally there are potentially several hundred 'procedures' that can be assembled in different ways to access data. For example, when getting one row from a table, you could use an index or a full table scan.
    Explain Plan shows the [proposed] access path, or complete list of the procedures, in the order called, to do what the SQL statement is requesting.
    The objective with Explain Plan is to review the proposed access path and determine whether alternates, through the use of hints or statistics or indexes or materialized views, might be 'better'.
    You often use Wait analysis, through StatsPack, AWR/ADDM, TKProf, Trace, etc. to determine which SQL statement is likely causing a performance issue.
    >
    Where can I to find tutorial about it ?Ah ... the $64K question. If we only knew ...
    There are so many variables involved, that most tutorials are nearly useless. The common approach therefore is to read - a lot. And build up your own 'interpretation' of the reading.
    Personal suggestion is to read (in order)
    1) Oracle's Database Concepts manual (described some of 'how' this is happening)
    2) Oracle's Performance Tuning manual (describes more of 'how' as related to performance and also describes some of the approaches)
    3) Tom Kyte's latest book (has a lot of demos and 'proofs' about how specific things work)
    4) Don Burleson's Statspack book (shows how to set up and do some basic interpretation)
    5) Jonathan's book (how the optimizer works - tough reading, though)
    6_ any book by the Oak Table (http://oaktable.net)
    Beyond that is any book that contains the words 'Oracle' and 'Performance' in the title or description. BUT ... when reading, use truck-loads, not just grains, of salt.
    Verify everything. I have seen an incredible amount of mistakes ... make 'em mysellf all the time, so I tend to recognize them when I see them. Believe nothing unless you have proven it for yourself.. Even then, realize there are exceptions and boundary conditions and ibgs and patches and statistics and CPU and memory and disk speed issues that will change ehat you have proven.
    It's not hopeless. But it is a lot of work and effort. And well rewarded, if you decide to get serious.

  • TreeItem - leaf property wrappers (and others) are private. Should be protected?

    I was creating a TreeItem subclass. Instead of overriding isLeaf and other methods, I simply wanted to use binding so that when the "value" changed, I could set the leaf property, or just bind to the leaf so that the value is updated when my domain object's value changes. However I noticed that both setLeaf and the leaf property wrapper are both private. This forces me to override isLeaf. All I wanted to do was setup some binding expressions or at least a change notifier when the value changes and set the leaf value according. The leaf property is a wrapper and the documentation suggests that a wrapper property was created to help support this scenario directly.  Since my isLeaf computation takes awhile, I have to setup several lines of code to cache the value whereas binding allows me to simplify my code and set it when the value changes, etc.
    Should these properties and the set* companion methods be protected instead to support subclassing using the new property system in javafx?
    Otherwise, there is no easy way to inform the UI that the "leaf" property has changed. Overriding isLeaf does not do that.
    jdk8 ea

    This sounds like a good tweak request to file in the Jira issue tracker here: http://javafx-jira.kenai.com
    Thanks!
    -- Jonathan

  • Pm-suspend resumes from suspend, but all other methods don't

    Running Arch with xfce. Everything is updated and am on kernal 3.9. Desktop PC, motherboard Gigabyte H61N-USB3 (latest BIOS).
    I've been having an issue for a few months with resume not working properly after a suspend. I've tried all sorts of solutions, e.g.:
    adding items to my kernal line (hpet=disable, acpi_osi=Linux)
    installing acpi, acpid
    disabling HPET in the BIOS
    editing /etc/mkinitcpio.conf with the resume hook instead of autodetect
    installing uswsusp
    None worked. Seen a lot of threads here of people having the same issue, but with me, it ALWAYS resumes fine if I suspended with pm-suspend.
    If I issue pm-suspend, the computer suspends nicely. I press the power button and everything comes back on. /var/log/pm-suspend.log is always successful.
    But, if I use any other method, such as sysctl suspend, or upower, or the suspend option in the Xfce menu (uses xfce4-power-manager), the resume doesn't wake any USB devices (my mouse light stays off) or the monitor (stays in blinking stanby mode). Sometimes it will resume fine, very rarely, but 90% of the time it won't. Only the PC power light will come on but that's it. Even the reset button won't restart the PC. I have to hold the power button for 4 seconds to turn it off.
    I'm almost to the point of replacing the motherboard over this as it's driving me up the wall.
    pm-suspend (which works great) generates a pm-suspend log. But any of the other methods generate a pm-powersave log. So those other methods must have something in common. I will post the contents later as I'm at work.
    I'd like to get the other methods working because if the PC suspends after a set time (through xfce), or if I use the Xfce suspend menu option, I know it won't resume. A workaround would be to make a pm-suspend menu option and some sort of schedule for it to run after a certain idle time, but that's not an answer for the original problem.
    Is there any way I can troubleshoot why systemd and other methods don't resume but pm-suspend does resume it fine?
    Last edited by nLinked (2013-05-24 13:52:20)

    I cleared pm-powersave.log and suspended through the xfce menu > Suspend.
    Resume worked fine once.
    Suspended again.
    Resume worked fine second.
    Suspended again, resume didn't work, PC fans on but mouse and display off.
    The output of the new pm-suspend.log is here, although it's possible it can't write any errors to the log when resume fails?
    http://pastebin.com/ZHDSeG6H

  • Why can I no longer, after having downloaded Lion, write accents and other diacriticals when in the Google, Yahoo, FaceBook, or even here in this post? The new method for getting at the "option" symbols works fine in other places like spotlight, but now e

    Why can I no longer, after having downloaded Lion, write accents and other diacriticals when in the Google, Yahoo, FaceBook, or even here in this post? The new method for getting at the "option" symbols works fine in other places like spotlight, but now even the older "option+letter" doesn't work in most places.

    Chrome doesn't support the new accent/diacritics/macron chooser. I'm not sure about other browsers such as Firefox. You can use the old Option+letter combination that Doug suggested. Hopefully updates will solve these little incompatibilities shortly.
    Neill

  • EJB 3.1 @Asynchronous and calling other methods from within

    Hey all,
    I am helping a friend set up a test framework, and I've turned him on to using JEE6 for the task. I am decently familiar with entity beans, session beans, and such. One of the new features is @Asynchronous, allowing a method to be ran on a separate thread. The test framework generally needs to spawn potentially 1000's of threads to simulate multiple users at once. Originally I was doing this using the Executor classes, but I've since learned that for some reason, spawning your own threads within a JEE container is "not allowed" or bad to do. I honestly don't quite know why this is.. from what I've read the main concern is that the container maintains threads and your own threads could mess up the container somehow. I can only guess that this might be possible if your threads use the container services in some way.. but if anyone could enlighten me on the details as to why this is bad, that would be great.
    None the less, EJB 3.1 adds the async capability and I am now looking to use this. From my servlet I use @EJB to access the session bean, and call an async method. My servlet returns right away as it should. From the async method I do some work and using an entity bean store results, so I don't need to return a Future object. In fact, my ejb then makes an HttpClient call to another servlet to notify it that the result is ready.
    My main question though, is if it's ok to call other methods from the async method that are not declared @Asynchronous. I presume it is ok, as the @Asynchronous just enables the container to spawn a thread to execute that method in. But I can't dig up any limitations on the code within an async method.. whether or not it has restrictions on the container services, is there anything wrong with using HttpClient to make a request from the method.. and making calls to helper methods within the bean that are not async.
    Thanks.

    851827 wrote:
    Hey all,.. from what I've read the main concern is that the container maintains threads and your own threads could mess up the container somehow. I can only guess that this might be possible if your threads use the container services in some way.. but if anyone could enlighten me on the details as to why this is bad, that would be great.
    Yes since the EE spec delegated thread management to conatiners, the container might assume that some info is available in the thread context that you may not have made available to your threads.
    Also threading is a technical implementation detail and the drive with the EE spec is that you should concentrate on business requirements and let the container do the plumbing part.
    If you were managing your own threads spawned from EJBs, you'd have to be managing your EJBs' lifecycle as well. This would just add to more plumbing code by the developer and typically requires writting platform specific routines which the containers already do anyway.
    >
    None the less, EJB 3.1 adds the async capability and I am now looking to use this. From my servlet I use @EJB to access the session bean, and call an async method. My servlet returns right away as it should. From the async method I do some work and using an entity bean store results, so I don't need to return a Future object. In fact, my ejb then makes an HttpClient call to another servlet to notify it that the result is ready.
    My main question though, is if it's ok to call other methods from the async method that are not declared @Asynchronous. I presume it is ok, as the @Asynchronous just enables the container to spawn a thread to execute that method in. But I can't dig up any limitations on the code within an async method.. whether or not it has restrictions on the container services, is there anything wrong with using HttpClient to make a request from the method.. and making calls to helper methods within the bean that are not async.
    Thanks.If you want to be asynchronous without caring about a return value then just use MDBs.
    The async methods have no restrictions on container services and there is nothing wrong with calling other non async methods. Once the async method is reached those annotations don't matter anyway (unless if you call thhose methods from a new reference of the EJB that you look up) as they only make sense in a client context.
    Why do you need to make the call to the servlet from the EJB? Makes it difficult to know who is the client here. Better use the Future objects and let the initial caller delegate to the other client components as needed.

  • I dont know what to do!!! I pulled out my headphones and then saw that my sound was not working correctly. I was horrified to find a piece of the headphone never came out. I have heard how much it costs to repair and the other methods are not working.

    Please help, i am so scared that i will never get my laptop back the way it was.

    "the other methods aren't working"
    Well, what other methods have you tried that didn't work?  Frankly, your post reads as a hoax, but I have some extra time on my hands, and an idea.  Make an appointment with the Apple Genius at your local Apple store.  You could also bring your MBP to an AASP.  Regardless, either one should be able to remove the bottom cover, and use a plastic thingy (dang, what is that tool called?) to push out the offending bit.

  • Hello sir i purchase second hand iphone4s now my iphone ask for activation with id and password i contact with previous owner and use that id and password but that also not work what i do ola help me i try all other method restore ' upgrade

    hello sir i purchase second hand iphone4s now my iphone ask for activation with id and password i contact with previous owner and use that id and password but that also not work what i do ola help me i try all other method restore ' upgrade etc but none work plz say what i do if u find some solution tham msg me on
    iPhone 4S

    oenkz33 wrote:
    this does not help at all for the second owner, after making the first owner id with careless, sorry for my english ...
    Careless? Possible, but unlikely. Most likely the phone was stolen from the first owner. It would be a VERY careless iPhone owner who did not erase their personal information from a phone before selling it, and to do that it is necessary to disable Activation Lock. In most places in the world knowingly using stolen property is a crime, so the fact that the phone doesn't work may be the least of one's risks.

  • I need an app or other method to preserve and restore my text message conversations which will be erased during a battery repair on my iPhone 5.

    I need an app or other method to preserve and restore my text message conversations which will be erased during a battery repair on my iPhone 5.

    Backup your phone to iCloud/your PC and when you restore your phone they will all come back.
    There are 3rd party apps that will allow you to export your messages on your PC.   A google search will help you sort out which suits your needs best.

  • [svn:bz-trunk] 23143: Certain code needs to check the existence of the class validation validator  (some brokers and other listeners) during message broker init, however the validator was not being created till the very end of the method .

    Revision: 23143
    Revision: 23143
    Author:   [email protected]
    Date:     2011-10-27 06:31:02 -0700 (Thu, 27 Oct 2011)
    Log Message:
    Certain code needs to check the existence of the class validation validator (some brokers and other listeners) during message broker init, however the validator was not being created till the very end of the method.  Promote it to be at the top instead of at the bottom.
    Modified Paths:
        blazeds/trunk/modules/core/src/flex/messaging/config/MessagingConfiguration.java

    Revision: 23143
    Revision: 23143
    Author:   [email protected]
    Date:     2011-10-27 06:31:02 -0700 (Thu, 27 Oct 2011)
    Log Message:
    Certain code needs to check the existence of the class validation validator (some brokers and other listeners) during message broker init, however the validator was not being created till the very end of the method.  Promote it to be at the top instead of at the bottom.
    Modified Paths:
        blazeds/trunk/modules/core/src/flex/messaging/config/MessagingConfiguration.java

  • ItemListemer and ActionListener...and others...how can they live together?

    Hi,
    I want to have a couple of DropDown Menus, some Buttons and some Checkboxes in the same class....How can I do that knowing that my class needs to implement ItemListener and ActionListener ?
    I've tried something like:
    "public class extends Applet implements ItemListener implements ActionListener"
    but not surprisingly it doesn't work....
    and what if on top of that I want a MouseListener, a WindowListener or God knows what else...?
    Thanks in advance for your help...
    Tom

    You need to read the basics about Swing events.
    For starters, you do not implement listeners in your Applet class. Instead, you add new listeners to specific components that you want to listen on. For example, if you need to perform certain actions when a JComboBox's selection changes, you would do something like:
    my_combo.addActionListener(  new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("selection changed to: " + my_combo.getSelectedItem());
    });And for buttons:
    my_button.addActionListener( new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("You clicked " + ((JButton) e.getSource()).getText() " button);
    }MoustListener and other listeners can be similarily added. See JDK Documentation or Tutorials

  • Cost Analysis and Benefits of ELM as compared to other methods of data inpu

    Hi all,
    Can someone throw light on the benefits of External List Management.How is it benefitial in terma of effeciency, cost and other parameters.

    Hi,
    Can you please elaborate. I want the general comparison of ELM qnd any other methodology used for data maintenance, ex creation of BPs manually Vs using ELM etc.
    Thanks
    Nidhi

  • ActionListener and Inner Class Issue

    When I add ".addActionListener()" to buttons and create an inner class to listen/handle the action, my main class does not display the GUI. If I remove the ".addActionListener()" from the buttons and the inner class, the GUI displays. Below is my code. Anyone know what is wrong with my code?
    package projects.web;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    public class AppletGUI{
         // JButtons
         JButton addButton = new JButton("Add");
         JButton removeButton = new JButton("Remove");
         JButton saveButton = new JButton("Save");
         JButton cancelButton = new JButton("Cancel");
         // JPanels
         JPanel containerPanel = new JPanel();
         JPanel optionsPanel = new JPanel();
         JPanel thumbnailPanel = new JPanel();
         JPanel selectionPanel = new JPanel();
         // JScrollPane
         JScrollPane thumbnailScroll;
         public AppletGUI(JRootPane topContainer){
              // Add actionListener
              addButton.addActionListener(new ButtonHandler());
              removeButton.addActionListener(new ButtonHandler());
              saveButton.addActionListener(new ButtonHandler());
              cancelButton.addActionListener(new ButtonHandler());
              // Set border layout
              containerPanel.setLayout(new BorderLayout());
              // Add buttons to target panels
              optionsPanel.add(addButton);
              optionsPanel.add(removeButton);
              selectionPanel.add(saveButton);
              selectionPanel.add(cancelButton);
              // Set size and color of thumbnail panel
              thumbnailPanel.setPreferredSize(new Dimension (600,500));
              thumbnailPanel.setBackground(Color.white);
              thumbnailPanel.setBorder(new LineBorder(Color.black));
              // Add thumbnail panel to scrollpane
              thumbnailScroll = new JScrollPane(thumbnailPanel);
              // Set background color of scrollPane
              thumbnailScroll.setBackground(Color.white);
              // Add subpanels to containerPanel
              containerPanel.add(optionsPanel, BorderLayout.NORTH);
              containerPanel.add(thumbnailScroll, BorderLayout.CENTER);
              containerPanel.add(selectionPanel, BorderLayout.SOUTH);
              // Add containerPanel to rootPane's contentPane
              topContainer.getContentPane().add(containerPanel);
         } // end constructor
         class ButtonHandler implements ActionListener{
              public void actionPerformed(ActionEvent event){
                   new FileBrowser();
              } // end actionPerformed method
         } // end inner class ActionHandler
    } // end AppletGUI class package projects.web;
    import java.awt.*;
    import java.io.*;
    import javax.swing.*;
    import javax.swing.filechooser.*;
    public class FileBrowser{
         JFileChooser fileChooser = new JFileChooser();
         public FileBrowser(){
              int fileChooserOption = fileChooser.showOpenDialog(null);
         } // end constructor
    } // end class fileBrowser

    Encephalopathic wrote:
    Dan: When it doesn't display, what happens? Do you see any error messages? Also, please take a look at your other thread in this same forum as it has relevance to our conversations in the java-forums.org about whether to add GUIs to root containers or the other way around. /PeteI fiddled with the code some more and it seems that the problem is the inner code. When I changed from the inner class to the main class implementing ActionListener and had the main class implement the actionPerformed method, the GUI displayed and JFileChooser worked as well. I've add this version of the code at the bottom of this message.
    To answer your question: When it doesn't display, what happens? -- The web page loads and is blank. And there are no error messages.
    I took a look at the other thread is this forum (the one relates to our conversation in the other forum); the problem may be the way I've add the GUI. I'll try it the other way and see what happens.
    Thanks,
    Dan
    package projects.web;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    public class AppletGUI implements ActionListener{
         // JButtons
         JButton addButton = new JButton("Add");
         JButton removeButton = new JButton("Remove");
         JButton saveButton = new JButton("Save");
         JButton cancelButton = new JButton("Cancel");
         // JPanels
         JPanel containerPanel = new JPanel();
         JPanel optionsPanel = new JPanel();
         JPanel thumbnailPanel = new JPanel();
         JPanel selectionPanel = new JPanel();
         // JScrollPane
         JScrollPane thumbnailScroll;
         public AppletGUI(JRootPane topContainer){
              // Add actionListener
              addButton.addActionListener(this);
              removeButton.addActionListener(new ButtonHandler());
              saveButton.addActionListener(new ButtonHandler());
              cancelButton.addActionListener(new ButtonHandler());
              // Set border layout
              containerPanel.setLayout(new BorderLayout());
              // Add buttons to target panels
              optionsPanel.add(addButton);
              optionsPanel.add(removeButton);
              selectionPanel.add(saveButton);
              selectionPanel.add(cancelButton);
              // Set size and color of thumbnail panel
              thumbnailPanel.setPreferredSize(new Dimension (600,500));
              thumbnailPanel.setBackground(Color.white);
              thumbnailPanel.setBorder(new LineBorder(Color.black));
              // Add thumbnail panel to scrollpane
              thumbnailScroll = new JScrollPane(thumbnailPanel);
              // Set background color of scrollPane
              thumbnailScroll.setBackground(Color.white);
              // Add subpanels to containerPanel
              containerPanel.add(optionsPanel, BorderLayout.NORTH);
              containerPanel.add(thumbnailScroll, BorderLayout.CENTER);
              containerPanel.add(selectionPanel, BorderLayout.SOUTH);
              // Add containerPanel to rootPane's contentPane
              topContainer.getContentPane().add(containerPanel);
         } // end constructor
         public void actionPerformed(ActionEvent event){
                   new FileBrowser();
              } // end actionPerformed method
         class ButtonHandler implements ActionListener{
              public void actionPerformed(ActionEvent event){
                   new FileBrowser();
              } // end actionPerformed method
         } // end inner class ActionHandler
    } // end AppletGUI class

  • ActionListener and Navigation PROBLEM

    Hi , I haveing problme wiht ActionListener and Navigation ,
    I am using ActionListener and after getting values I am forwarding the
    page, but its getting to same page, below is my bean code.
         * this method edit the survey
         * @return
         public String doEditSurvey(ActionEvent event){
              //first get the question ID,questionType ,Question and Releated Answers
              String surveyQuestionID = (String) event.getComponent().getAttributes().get("surveyQuestionID");
              System.err.println("the question id is :"+surveyQuestionID);
              String surveyQuestionDesc = (String) event.getComponent().getAttributes().get("surveyQuestionDesc");
              String questionType = (String) event.getComponent().getAttributes().get("questionType");
              ArrayList surveyQuestionList = (ArrayList) event.getComponent().getAttributes().get("surveyQuestionList");
                   Iterator it = surveyQuestionList.iterator();
                   while(it.hasNext()){
                        SelectItem selectItem = (SelectItem)it.next();
                        setAnswer(selectItem.getLabel());
                        setAnswer("\n");
                   setQuestion(surveyQuestionDesc);               
                   setSelectedType(questionType);
              System.err.println("the question id is :"+surveyQuestionID);
              //System.err.println("the surveyQuestionList id is :"+surveyQuestionList);
              System.err.println("the surveyQuestionDesc id is :"+surveyQuestionDesc);
              System.err.println("the questionType id is :"+questionType);
              FacesContext facesCtx = FacesContext.getCurrentInstance();
              facesCtx.responseComplete();
              return "questionTemplate";
    so when I return this string , Its not getting their, any idea .
    Thanks
    Srikanth

    Check your faces-config.xml file for the navigation rule questionTemplate.
    SirG

Maybe you are looking for