Board index » jbuilder » JdbNavToolBar button events

JdbNavToolBar button events


2005-02-22 02:50:13 PM
jbuilder24
Hi All
I am facing problem with JdbNavtoolbar buttons.
I want to set some more extra code for button "Save Changes" to put user some message when user press that specfic button of JDBNavtoolbar.. I also want to put some field data to other tables when user press the button
 
 

Re:JdbNavToolBar button events

Here is some sort of code that i use:
public class MyNavToolBar extends JdbNavToolBar {
public MyNavToolBar() {
super();
}
public void actionPerformed(ActionEvent e) {
DataSet currentDataSet = getFocusedDataSet();
if (currentDataSet != null) {
try {
JButton button = (JButton)e.getSource();
if (button == getFirstButton()) {
currentDataSet.first();
}
else if (button == getNextButton()) {
if (currentDataSet.atLast() || currentDataSet.isEditable() &&
currentDataSet.isEmpty()) {
if (currentDataSet instanceof SASQueryDataSet) {
((MyQueryDataSet)currentDataSet).insertNewRow(false);
}
else {
currentDataSet.insertRow(false);
}
}
else {
currentDataSet.next();
}
}
else if (button == getPriorButton()) {
currentDataSet.prior();
}
else if (button == getLastButton()) {
currentDataSet.last();
}
else if (button == getInsertButton()) {
if (currentDataSet instanceof MyQueryDataSet) {
((MyQueryDataSet)currentDataSet).insertNewRow(true);
}
else {
currentDataSet.insertRow(true);
}
}
else if (button == getDeleteButton()) {
currentDataSet.deleteRow();
}
else if (button == getPostButton()) {
currentDataSet.post();
}
else if (button == getDittoButton()) {
currentDataSet.dittoRow(false, true);
}
else if (button == getCancelButton()) {
if (currentDataSet.isEditing()) {
currentDataSet.cancel();
}
}
else if (button == getSaveButton()) {
currentDataSet.postAllDataSets();
currentDataSet.saveChanges();
if (currentDataSet instanceof QueryDataSet) {
QueryDataSet qds = (QueryDataSet)currentDataSet;
int currentRow = qds.getRow();
qds.getDatabase().commit(); // this is because we cannot use
autocommit.
qds.empty();
qds.refresh();
qds.goToRow(currentRow);
}
}
else if (button == getRefreshButton()) {
currentDataSet.refresh();
}
} catch (DataSetException ex) {
DBExceptionHandler.handleException(currentDataSet, ex);
}
}
}
}
"Ateeq" < XXXX@XXXXX.COM >wrote in message
Quote

Hi All

I am facing problem with JdbNavtoolbar buttons.

I want to set some more extra code for button "Save Changes" to put user
some message when user press that specfic button of JDBNavtoolbar.. I also
want to put some field data to other tables when user press the button
 

Re:JdbNavToolBar button events

OK jdbStatusLabel has "navigated"
I will remove my NavTool button traps
and try to trap StatusLabel navigated
... seems like a simpler method...
 

{smallsort}

Re:JdbNavToolBar button events

I do this the other way:
I intercept the Navtool
using this method:
==========================
jdbNavToolBar1.getLastButton().removeActionListener(jdbNavToolBar1);
jdbNavToolBar1.getLastButton().addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
bLast(e); // my method
}
}); // aalistener
void bLast(ActionEvent e) {
myDS.last();
everyrecordmethod(); // my method
} // bLast
... and similar for First Prior Next
==========================
BUT my jdbStatusLabel fails to display "x of n records"
after I have hit one of my buttons.
How do I trap or otherwise activate jdbStatusLabel
after I have trapped the NavTool buttons???
=======================
OR is there an easier way to perform a method whenever the current row
changes??