Solved

How to disable Control C....

Posted on 2004-04-23
10
1,115 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

837 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