Solved

How to disable Control C....

Posted on 2004-04-23
10
1,095 Views
Last Modified: 2008-02-01
HI i have a JTable and i will like that the user can not copy the info that is beeing display in the JTable .
i will like to disble
control c\
control x
control prtScrn
alt prtscrn
it is posible ?
0
Comment
Question by:dentrita
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 14

Accepted Solution

by:
Tommy Braas earned 75 total points
ID: 10901358
You can disable Ctrl+C and Ctrl+X by implementing your own handler. See http://java.sun.com/developer/technicalArticles/releases/data/   for more information.

Disabling Ctrl+prt sc and Alt+prt sc would require you to write native code using JNI, if at all possible.
0
 
LVL 23

Expert Comment

by:rama_krishna580
ID: 10901568
0
 
LVL 1

Author Comment

by:dentrita
ID: 10902204
rama krishna

the document that you send me is about
How to Use Drag and Drop and Data Transfer
the thing that i want to do is to disable Control + C, Control + X, Control +PrtScrn, Alt+PrtScrn.

0
 
LVL 1

Author Comment

by:dentrita
ID: 10902245
orangehead911
 the ariticule is good but it do  not help me how to disable the copy and and the paste of the info or to disable the print screen
thank you
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 16

Expert Comment

by:gnoon
ID: 10906998
How about jtable.setEnabled(false);?
0
 
LVL 30

Expert Comment

by:mayankeagle
ID: 10911265
>> jtable.setEnabled(false);

Seems to be good enough ;-)
0
 
LVL 1

Author Comment

by:dentrita
ID: 10911789
Yes if i use jtable.setEnabled(false); odcourse i can not do a copy off the cells becouse i can not select the cells , but that is not my question , my quiestion is

i want to can select the rows and columns but if the user press
Control + c or
Control +PrtScrn or
Alt+PrtScrn.
 the user can not copy the information that is beeing display in the jtable
 its posible to disable this combinations of keys?

Control + C, Control + X, Control +PrtScrn, Alt+PrtScrn.
Thank you a lot
0
 
LVL 16

Expert Comment

by:gnoon
ID: 10915110
This can prevent Ctrl+C and Ctrl+X. However, it's not editable table.
If you want user can select a part of text in a cell, you should write your own TableCellEditor.

import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;

public class TableNoCopy extends JFrame {
    JTable table;

    public TableNoCopy() {
        super("Customer Information");
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setSize(400,400);
        setLocationRelativeTo(null);

        Object cnames[] = {"Data"};
        Object data[][] = {{"a@host"},
                         {"b@host"},
                         {"c@host"}};
        table = new JTable(new DefaultTableModel(data,cnames)){
            public TransferHandler getTransferHandler() {
                // overide getTransferHandler in class JComponent
                return null;
            }
            public boolean isCellEditable(int row,int col) {
                // no such editable cell
                return false;
            }
        };

        getContentPane().setLayout(new BorderLayout());
        getContentPane().add(new JScrollPane(table));
    }

    public static void main(String[] args) {
        new TableNoCopy().setVisible(true);
    }
}
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 11154311
Sounds good to me
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now