KeyBoard Control for deleting

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
cdn
Newbie
Newbie
Posts: 29
Joined: Wed Sep 19, 2007 12:00 am

KeyBoard Control for deleting

Post by cdn » Tue Oct 02, 2007 5:52 am

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Oct 02, 2007 10:17 am

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.

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)
        {
        }

//........
Hope this helps!
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply