Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: actionPerformed not returning a value.

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Location
    PH
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy actionPerformed not returning a value.

    Hello fellow java enthusiasts,

    I have been stuck on this problem for this past few days.
    I have tried different ways to get my program going but it failed.

    Here it is.

    public void doWrite(){
    		User u = new User();
    		String passconcat= new String(password.getPassword());
    		u.setUserName(username.getText());
    		u.setPassword(passconcat);
    		u.setName(name.getText());
    		doDisplayMonth().getActionListeners();
    		UserWriter writer = new UserWriter();
    		writer.writeUserInfo(u);
    	}
    	public JComboBox doDisplayMonth(){
    		Object comboBox [] = {"January","February","March","April","May","June","July","August","September","October","November","December"};
    		final JComboBox month = new JComboBox(comboBox);
    		month.setBounds(86, 287, 97, 23);
    		contentPane.add(month); 
     
    		month.addActionListener(new ActionListener() {
    			public void actionPerformed(ActionEvent arg0) {
    				User u = new User();
    				u.setMonth((String) month.getSelectedItem());
    				System.out.print(u.getMonth());
    			}
    		});
    		return month;
    	}


    That piece of code is trying to write the selected item on a JComboBox containing an array of months.
    I just want the method actionPerformed to return a string value to be declared at the method doWrite().

    Any solutions?
    It will be highly appreciated.

    Thanks in advance.


    PS. Sorry if my english is not that good.


  2. #2
    Junior Member
    Join Date
    Oct 2011
    Posts
    20
    Thanks
    1
    Thanked 4 Times in 4 Posts

    Default Re: actionPerformed not returning a value.

    Try using the ItemStateChanged event for the JComboBox, i've used that one before and i know it works. Let me know how that works out for you.

Similar Threads

  1. Tic Tac Toe ActionPerformed Issue
    By Jakesta42 in forum What's Wrong With My Code?
    Replies: 19
    Last Post: August 15th, 2011, 12:11 AM
  2. Needed help in actionPerformed statements
    By S-NESH in forum What's Wrong With My Code?
    Replies: 7
    Last Post: January 7th, 2011, 06:36 PM
  3. returning String from ActionPerformed
    By Bill'o in forum AWT / Java Swing
    Replies: 5
    Last Post: December 17th, 2010, 10:16 PM
  4. actionPerformed method
    By Deprogrammer in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 4th, 2010, 02:29 AM
  5. actionPerformed
    By Kumarrrr in forum Java Theory & Questions
    Replies: 5
    Last Post: November 23rd, 2010, 09:08 AM