Solved

How to disable Control C....

Posted on 2004-04-23
10
1,105 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

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

777 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