?
Solved

How to disable Control C....

Posted on 2004-04-23
10
Medium Priority
?
1,135 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 14

Accepted Solution

by:
Tommy Braas earned 300 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month8 days, 15 hours left to enroll

764 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