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 > CellEditor/Renderer Post New Topic   Post A Reply
behavior select column printer friendly version
next newest post | next oldest post
Author Messages
infow
Unregistered
Edit or delete this message Reply w/Quote
Posted Tuesday, February 12, 2008 @ 09:58:33  

hi,
i have 2 problem.
I want ot use RETURN key to enter next column (right).
But when a column is not visible then it's not working (see this exemple : second column that isn't visible)

seconde problem: when i came back (shift+Tab) then the cell is selected but when i want to enter a number , i have to write 2 times the first number. For exemple to enter 122, i have to enter 1122 because the cell is writing 1 then select all and then the second number is deleting everything

sorry for my poor english ! ! !
have a nice day

import javax.swing.*;

import quick.dbtable.*;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.sql.*;

public class QuickTableFrame extends JFrame {
// create a new quicktable
quick.dbtable.DBTable dBTable1 = new quick.dbtable.DBTable();

private KeyListener myKeyListner = new KeyListener() {
public void keyPressed(KeyEvent e) {
if ((e.getModifiers() != KeyEvent.SHIFT_MASK && e.getKeyCode() == KeyEvent.VK_ENTER)
|| (e.getKeyCode() == KeyEvent.VK_TAB && (e.getModifiers() != KeyEvent.SHIFT_MASK))) {
e.consume(); // prevent the event from passing on
validate();

int sRow = dBTable1.getSelectedRow();
int sCol = dBTable1.getSelectedColumn();

if ((sCol + 1) < dBTable1.getColumnCount()) {
dBTable1.selectCell(sRow, sCol + 1);
} else if (sRow < dBTable1.getRowCount()) {
dBTable1.selectCell(sRow + 1, 0);
} else {
dBTable1.selectCell(0, 0);
}

}

}

public void keyReleased(KeyEvent arg0) {
// TODO Auto-generated method stub
}

public void keyTyped(KeyEvent arg0) {
// TODO Auto-generated method stub
}
};

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

// 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.getTable().setSurrendersFocusOnKeystroke(true);
dBTable1.enableTextOverwriteOnCellEdit = true;
dBTable1.getTable().addKeyListener(myKeyListner);
try {
// connect to database & create a connection
dBTable1.connectDatabase();
Column colonne;
dBTable1.createColumnModelFromQuery();
for (int j = 0; j < dBTable1.getColumnCount(); j++) {

colonne = dBTable1.getColumn(j);
colonne.setPreferredWidth(100);
colonne.setHeaderValue("Col" + j);

if (j!=1)
colonne.setVisible(true);
else
colonne.setVisible(false);
colonne.setReadOnly(false);
JComponent jc = (JComponent) ((DBTableCellEditor) colonne
.getCellEditor()).getComponent();
jc.addKeyListener(myKeyListner);
// colonne.setReadOnly(!isCellEditable[j]);
}
dBTable1.refresh();
dBTable1.useOldColumnProperties(true);
// fetch the data from database to fill the table
// dBTable1.refresh();
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}

}

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

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 Wednesday, February 13, 2008 @ 22:56:23  

Search the quicktable forum with word 'InputMap', you will get some answers related to this.
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