Solved

How to disable Control C....

Posted on 2004-04-23
10
1,100 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 16

Expert Comment

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

Expert Comment

by:Mayank S
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

863 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

20 Experts available now in Live!

Get 1:1 Help Now