Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Is it possible to use e.getsource with a switch statement?

807607Dec 2 2006 — edited Dec 2 2006
Is it possible to use e.getsource for a switch statement? I keep getting an error, which I understand. I'm just not sure if it can be done by using another method or casting e.getsource to something. Any ideas? Thanks!

	public void actionPerformed(ActionEvent e)
	{
				
		switch(e.getSource())
		{
			//buttons 0 - 6
			case buttons[0]:
				Master_Clock.tickPos();
				break;
			case buttons[1]:
				Master_Clock.tockPos();
				break;
			case buttons[2]:
				Master_Clock.reset();
				break;
			case buttons[3]:
				Master_Clock.tickNeg();
				break;
			case buttons[4]:
				Master_Clock.tockNeg();
				break;
			case buttons[5]:
				Master_Clock.dayPos();
				break;
                }
        }
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 30 2006
Added on Dec 2 2006
6 comments
621 views