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


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

JButton Action Listeners

From "Sriram" <sriram@THRWHITE.remove-dii-this>
Subject JButton Action Listeners
Message-ID <8f4084e9-5e60-460f-93e0-e18732aa51fe@v13g2000pro.googlegroups.com> (permalink)
Newsgroups comp.lang.java.gui
Date 2011-04-27 15:49 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
Hi all

     I have a question regarding action events... Is it possible for a
button to have multiple events generated??... I have been wanting to
generate two events from clicking a single button ..My following
sample code has the Add Row button and Up button that generates
separate events but I would like a single Up button to generate adding
a row below as well as insertion of a row if there are entries say
between table cells A and C it should insert a cell in between
(functionality like Excel)......

How do I do this? Pls help!!

	button = new JButton( "Add Row" );
	buttonPanel.add( button );
	button.addActionListener( new ActionListener()
	{
	 public void actionPerformed(ActionEvent e)
	 {
	   model.addRow( createRow() );
	   int row = table.getRowCount() - 1;
	   table.getColumnModel().getColumn(4).setCellEditor(new
DefaultCellEditor(comboBox));
            	   table.changeSelection(row, 0, false, false);
	   table.requestFocusInWindow();
	}
	});

       //

                button = new JButton( "Up" );
	buttonPanel.add( button );
	button.addActionListener( new ActionListener()
	{
	 public void actionPerformed(ActionEvent e)
	 {
	    int row=table.getSelectedRow();
	    model.insertRow(row, createRow() );
	    table.changeSelection(0, 0, false, false);
	    table.requestFocusInWindow();
	 }
	});

---
 * 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


Thread

JButton Action Listeners "Sriram" <sriram@THRWHITE.remove-dii-this> - 2011-04-27 15:49 +0000
  Re: JButton Action Listen "Sabine Dinis Blochberger" <sabine.dinis.blochberger@THRWHITE.remove-dii-this> - 2011-04-27 15:49 +0000
  Re: JButton Action Listen "Mark Space" <mark.space@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000

csiph-web