craftleft.gif (3002 bytes)QuickTable
Home | API | Tutorial | Download | Support | Contact topblack.gif (108 bytes)


QuickTable User Cp  |  Register  |  Members  |  Search  |  Help
    |- QuickTable Discussion Forums > UI , Look and Feel, Colors, Navigation, font, Locale Post New Topic   Post A Reply
one VK_ENTER in celleditor go next cell printer friendly version
next newest post | next oldest post
Author Messages
infow
Lieutenant General

Gender: Male
Location: France
Registered: Mar 2005
Status: Offline
Posts: 38

Click here to see the profile for infow Send email to infow Send private message to infow Find more posts by infow Edit or delete this message Reply w/Quote
Posted Wednesday, August 23, 2006 @ 11:51:58  

hi,
when i'm editing a cell (string / default), i had to press 2 time VK_ENTER in order to go to next cell ...
How can i make to press only 1 VK_ENTER ? (like VK_TAB)

must i change something in DbTableCellEditor ?

thank for your help

--------------------
Olivier

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Thursday, August 24, 2006 @ 06:01:58  

do you get any clues for this thread?

http://quicktable.org/discussion/cutecast/cutecast.pl?forum=10&thread=289

infow
Lieutenant General

Gender: Male
Location: France
Registered: Mar 2005
Status: Offline
Posts: 38

Click here to see the profile for infow Send email to infow Send private message to infow Find more posts by infow Edit or delete this message Reply w/Quote
Posted Thursday, August 24, 2006 @ 09:13:10  

i havethis one in your forum:
KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0);
KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
InputMap tableInputMap = getTable().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
tableInputMap.put(enterKey, tableInputMap.get(tab));

but i had to press 2 time enter because the first one is for validate the cell and then the second is for go to next cell ...

in other word :
- i'm editing a cell
- i press enter -> the cell is validate and the cell is selected (selection for the table / out of the celleditor)
- i press enter and i go to the nextline

what i want :
- i'm editing a cell
- i press enter -> the cell is validate and i go to the next cell

I think a have to put a event int the celleditor , no ?

--------------------
Olivier

infow
Lieutenant General

Gender: Male
Location: France
Registered: Mar 2005
Status: Offline
Posts: 38

Click here to see the profile for infow Send email to infow Send private message to infow Find more posts by infow Edit or delete this message Reply w/Quote
Posted Monday, September 11, 2006 @ 03:32:05  

up

--------------------
Olivier

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Monday, September 11, 2006 @ 10:35:21  

when you call this statement
tableInputMap.put(enterKey, tableInputMap.get(tab));

could you first check whether you are receiving a non null object for "tableInputMap.get(tab)"?

You can also try the method specified in this forum.
http://forum.java.sun.com/thread.jspa?forumID=57&threadID=563919

Add some system.out.println within the AbstractAction.actionPerformed method to see whether the method is called when you press enter inside the cell.

infow
Lieutenant General

Gender: Male
Location: France
Registered: Mar 2005
Status: Offline
Posts: 38

Click here to see the profile for infow Send email to infow Send private message to infow Find more posts by infow Edit or delete this message Reply w/Quote
Posted Tuesday, September 19, 2006 @ 10:10:25  

well, my english is too poor. you don't understand :~

after a long work time i found this function:

getTable().setSurrendersFocusOnKeystroke(true);

it's perfect but when i'm using enableTextOverwriteOnCellEdit = true;

it's not working for the first key typing (because it's in the celle, then it's all selected and deletete by typing another key)

can you please see your bug ?

thank and have a nice day

--------------------
Olivier

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Sunday, September 24, 2006 @ 22:14:46  

In jdk 1.4
1) setSurrendersFocusOnKeystroke = true
If user starts editing the cell, user still needs to press enter two times to go to the next cell. If the user does not edit the cell, one enter is enough to move to the next cell

2) without setting setSurrendersFocusOnKeystroke
even if user starts editing cell, pressing Enter one time is enough to move to next cell.

It looks like by default without using setSurrendersFocusOnKeystroke, it is already working as you expected, so I don't understand what you are trying to acheive by setting setSurrendersFocusOnKeystroke = true

infow
Lieutenant General

Gender: Male
Location: France
Registered: Mar 2005
Status: Offline
Posts: 38

Click here to see the profile for infow Send email to infow Send private message to infow Find more posts by infow Edit or delete this message Reply w/Quote
Posted Monday, September 25, 2006 @ 03:00:03  

thank you for your answer

i don't need setSurrendersFocusOnKeystroke = true for textfield.
But for combobox, i had to use it in order to change the cell value without using the mouse !

i want to use the jtable without the mouse . so i have to use setSurrendersFocusOnKeystroke = true to enter the combobox when pressing space ...

the problem is for this example :

i can' t select avalue from the combobox when i 'm not using setsurrendersfocusonkeystroke without using the mouse to enter the celleditor
but when i'm using the setsurrend... then try to change a value from a textfield WITHOUT using the mouse. you will see that the first key is for nothing ! ! !

here's the example:

import javax.swing.*;

import quick.dbtable.*;

import java.awt.event.KeyEvent;
import java.sql.*;
import java.util.Hashtable;

public class QuickTableFrame extends JFrame
{
public QuickTableFrame()
{
//set Frame properties
setSize(300,200);
setVisible(true);

//create a new quicktable
quick.dbtable.DBTable dBTable1 = new quick.dbtable.DBTable();

//add to frame
getContentPane().add(dBTable1);

//set the database driver to be used, we are using jdbc-odbc driver
dBTable1.setDatabaseDriver("sun.jdbc.odbc.JdbcOdbcDriver");

/*
set the jdbc url,"quicktabledemo" is the data source we have created
for the database
*/
dBTable1.setJdbcUrl("jdbc:odbc:quicktabledemo");

// set the select statement which should be used by the table
dBTable1.setSelectSql("select * from employee");

//to create the navigation bars for the table
dBTable1.createControlPanel();


dBTable1.enableTextOverwriteOnCellEdit = true;
KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0);
KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
InputMap tableInputMap = dBTable1.getTable().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
tableInputMap.put(enterKey, tableInputMap.get(tab));

dBTable1.getTable().setSurrendersFocusOnKeystroke(true);
try
{
//connect to database & create a connection
dBTable1.connectDatabase();

//fetch the data from database to fill the table
dBTable1.refresh();
}
catch(SQLException e)
{
e.printStackTrace();
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
Column c = dBTable1.getColumn(3);
c.setPreferredWidth(60);
Hashtable h = new Hashtable();
h.put("Y", new Boolean(true));
h.put("N", new Boolean(false));
dBTable1.setCellComponent(c,Column.CHECKBOX_CELL,h);

c = dBTable1.getColumn(2);
h = new Hashtable();
h.put("V","Vv");
h.put("A","Aa");
h.put("M","Mm");
dBTable1.setCellComponent(c,Column.COMBOBOX_CELL,h);


dBTable1.getColumn(0).setReadOnly(false);
dBTable1.getColumn(1).setReadOnly(false);
dBTable1.getColumn(2).setReadOnly(false);
dBTable1.getColumn(3).setReadOnly(false);

}

public static void main(String[] args)
{
//create a new table frame
QuickTableFrame myframe = new QuickTableFrame();
}
}

thank you

--------------------
Olivier

infow
Lieutenant General

Gender: Male
Location: France
Registered: Mar 2005
Status: Offline
Posts: 38

Click here to see the profile for infow Send email to infow Send private message to infow Find more posts by infow Edit or delete this message Reply w/Quote
Posted Thursday, September 28, 2006 @ 02:42:21  

up

--------------------
Olivier

infow
Lieutenant General

Gender: Male
Location: France
Registered: Mar 2005
Status: Offline
Posts: 38

Click here to see the profile for infow Send email to infow Send private message to infow Find more posts by infow Edit or delete this message Reply w/Quote
Posted Friday, September 29, 2006 @ 06:24:02  

i found a solution.
thank for your help

JComponent jc = (JComponent)((DBTableCellEditor)colonne.getCellEditor()).getComponent();
jc.addKeyListener(
new KeyListener()
{
public void keyPressed(KeyEvent e)
{
if (e.getKeyCode() == KeyEvent.VK_ENTER)
{
e.consume(); // prevent the event from passing on
myNextFocus();
}
else if (e.getModifiers() == KeyEvent.SHIFT_MASK && e.getKeyCode() == KeyEvent.VK_TAB)
{
e.consume(); // prevent the event from passing on myPreviousFocus();
myPreviousFocus();
}

else if (e.getKeyCode() == KeyEvent.VK_TAB)
{
e.consume(); // prevent the event from passing on
myNextFocus();
}
}

public void keyReleased(KeyEvent arg0)
{
}

public void keyTyped(KeyEvent arg0)
{
}
});
}

--------------------
Olivier

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Monday, October 2, 2006 @ 16:27:37  

Thanks for your suggestion!!
Post New Topic   Post A Reply Jump to:
Contact Us | QuickTable - A Java DBGrid | Privacy Policy All times are GMT -5 Hours.
Welcome to QuickTable Forums, Guest!  
Login
Username :
Password :
In order to fully utilize the abilities of this board, you are required to register as a member. Registration is free, and allows you to do lots of things including turning on or off certain features of this board. Register now!
Powered by CuteCast v2.0 BETA 2
Copyright © 2001-2003 ArtsCore Studios