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


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

extending JComboBox break

Path csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!novia!news-out.readnews.com!news-xxxfer.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail
From "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this>
Subject extending JComboBox break
Message-ID <45b5940b$0$28066$4c368faf@roadrunner.com> (permalink)
X-Comment-To comp.lang.java.gui
Newsgroups comp.lang.java.gui
Content-Type text/plain; charset=IBM437
Content-Transfer-Encoding 8bit
X-Gateway time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92]
Lines 49
Date Wed, 27 Apr 2011 15:29:25 GMT
NNTP-Posting-Host 96.60.20.240
X-Complaints-To news@tds.net
X-Trace newsreading01.news.tds.net 1303918165 96.60.20.240 (Wed, 27 Apr 2011 10:29:25 CDT)
NNTP-Posting-Date Wed, 27 Apr 2011 10:29:25 CDT
Organization TDS.net
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.gui:764

Show key headers only | 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