Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #764

extending JComboBox break

From "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this>
Subject extending JComboBox break
Message-ID <45b5940b$0$28066$4c368faf@roadrunner.com> (permalink)
Newsgroups comp.lang.java.gui
Date 2011-04-27 15:29 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
hello,

I've created my own JComboBox and implemented the ActionListener 
interface for the new class.  I defined the actionPerformed() and all 
was well until I realized that calling comboBox.getSelectedItem() no 
longer returns anything as long as I define comboBox to be of type 
myJComboBox instead of JComboBox.  I assume this is due to JComboBox 
already implementing the ActionListener interface and I am essentially 
overriding what used to be in actionPerformed() . Is there a method to 
call in my actionPerformed() so I can still make the getSelectedItem() 
work, something like super() if this was occurring in a constructor? Or 
if something else is causing it to not work are there any tips for 
solving it?

Here is my custom JComboBox class:

private class myJComboBox extends JComboBox implements ActionListener {
	private static final long serialVersionUID = 0L;
	public myJComboBox(ComboBoxModel mod) {
		super(mod);
	}
	public myJComboBox(String[] mod) {
		super(mod);
	}
		
	public void actionPerformed(ActionEvent e) {
		if (e.getActionCommand().equals("dirType")) {
		//directoryType is a JComboBox
		String d =
		(String)directoryType.getSelectedItem();
			if (!d.equals(""))
				dirType = true;
			else
				dirType = false;
		}
		if (host && port && hostType && dirType)
			fetchBtn.setEnabled(true);
		else
			fetchBtn.setEnabled(false);
	}
}

thanks

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextNext in thread | Find similar | Unroll thread


Thread

extending JComboBox break "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> - 2011-04-27 15:29 +0000
  Re: extending JComboBox b "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:29 +0000
    Re: extending JComboBox b "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> - 2011-04-27 15:29 +0000
      Re: extending JComboBox b "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:29 +0000
  Re: extending JComboBox b "Michael Rauscher" <michael.rauscher@THRWHITE.remove-dii-this> - 2011-04-27 15:29 +0000
    Re: extending JComboBox b "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> - 2011-04-27 15:29 +0000

csiph-web