Results 1 to 6 of 6
  1. #1
    zhider is offline Member
    Join Date
    Oct 2012
    Posts
    37
    Rep Power
    0

    Default Clear menu item in swing

    I am supposed to make it so that when I press the clear button under file in my program, it clears the demension boxes, output label and sets it to circleRadioButton. This code should do that. any idea as to why this would not be working?


    Java Code:
    private void ClearActionPerformed(java.awt.event.ActionEvent evt) { 
         outputLabel.setText("");
         dimension1Label.setText("");
         dimension2Label.setText("");
         circleRadioButton.setSelected(true);
    }

  2. #2
    SJF
    SJF is offline Senior Member
    Join Date
    Oct 2012
    Posts
    108
    Rep Power
    0

    Default Re: Clear menu item in swing

    Are you getting an error? Are the Labels/Radio Button visible to this action listener?

    I'm no swing expert, but I think your action listener may need to be in the form:

    Java Code:
    	private class ClearActionListener implements ActionListener{
    
    		@Override
    		public void actionPerformed(ActionEvent e) {
    			//Do clear stuff here.
    		}
    	}
    
    		....
    	ActionListener clearAL = new ClearActionListener();
    	clearBtn.addActionListener(clearAL);

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Clear menu item in swing

    1. Learn to follow the Java coding conventions: Code Conventions for the Java Programming Language: Contents

    2. To get better help sooner, post a SSCCE (Short, Self Contained, Correct (Compilable), Example) that demonstrates the problem.

    Oh, and 'not working' doesn't tell us anything. It just leads to more questions, so you might as well tell us all the relevant details upfront.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    zhider is offline Member
    Join Date
    Oct 2012
    Posts
    37
    Rep Power
    0

    Default Re: Clear menu item in swing

    I kind of wish that all of the moderaters on this site were nice... That other one from the other post I made was cool, but you are just getting annoying. post something positive for once in your life.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: Clear menu item in swing

    You can read his posts any way you wish. The way I read it, if you follow his advice, we'll be able to better understand your code and your problem and be better able to help you. Your mileage may vary. So if you're still stuck, please tell and show us more, and again if you code that you posts conforms with convention, we'll all have a much better ability to understand it. Luck.

    Edit: but heck, I've suggested this to you before.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Clear menu item in swing

    Quote Originally Posted by zhider View Post
    I kind of wish that all of the moderaters on this site were nice... That other one from the other post I made was cool, but you are just getting annoying. post something positive for once in your life.
    So you think it's nicer that people leave you to unknowingly violate coding conventions and continue to write code that is difficult for other coders to read? And that it would be nicer if I didn't tell you how to get better help sooner?

    Get real. Or get a paid tutor -- and pay him/her extra to be 'nice' about everything.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Add item to menu context
    By ahmakki in forum New To Java
    Replies: 2
    Last Post: 02-15-2012, 08:58 PM
  2. menu item event
    By Johanis in forum New To Java
    Replies: 6
    Last Post: 10-26-2011, 11:10 PM
  3. How can you add an action listener to a menu item?
    By SerbianSergeant in forum New To Java
    Replies: 7
    Last Post: 08-24-2011, 08:55 PM
  4. How to clear checkboc item in swing
    By man4ish in forum AWT / Swing
    Replies: 2
    Last Post: 01-08-2010, 06:58 AM
  5. Checking toggle state of a menu item
    By xsive in forum SWT / JFace
    Replies: 1
    Last Post: 09-22-2008, 03:42 PM

Posting Permissions

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