Hi:
We have looked at the example for deleting a selected line through a button control. Unfortunately, it will not work for the current setup. What we would like to do is use the "DEL" key through KeyListener to be able to delete a line from the chart. Is this possible? We have tried creating KeyListener event and it does not work. I was wondering whether anyone has any insights. Appreciate any information. Thank you.
best regards,
vasu
KeyBoard Control for deleting
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi vasu,
Probably a Java expert may know of a way to achieve this much easily. However, we found one way to add keyboard events is like in the code snippet below. Please notice that other controls (as JButton) may interfere on those events so notice the KeyListener code necessary for the buttons.
Hope this helps!
Probably a Java expert may know of a way to achieve this much easily. However, we found one way to add keyboard events is like in the code snippet below. Please notice that other controls (as JButton) may interfere on those events so notice the KeyListener code necessary for the buttons.
Code: Select all
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
public class JFrameDemo extends javax.swing.JFrame
implements KeyListener
{
private TChart tChart = new TChart();
private javax.swing.JToggleButton jToggleButton1;
private javax.swing.JToggleButton jToggleButton2;
public JFrameDemo() {
initComponents();
jToggleButton1.addKeyListener(this);
jToggleButton2.addKeyListener(this);
}
public void keyReleased(KeyEvent e)
{
}
//
public void keyTyped(KeyEvent e)
{
tChart.getHeader().setText("KeyTyped!");
}
//
public void keyPressed(KeyEvent e)
{
}
//........
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |