Preventing user from selecting item in JTree

Does anyone know how to prevent the user from being able to change the cell in the tree that is currently selected?
I have a JTree that the user can select items from but I want them to be able to click on a button and no longer be able to select an item in the tree until another button is pressed.
Any ideas?

hi
i hope the code below helps ur purpose
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.tree.*;
public class Frame1 extends JFrame {
JPanel contentPane;
BorderLayout borderLayout1 = new BorderLayout();
JPanel jPanel1 = new JPanel();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
MyTree jTree1 = new MyTree();
boolean blnSelection = true;
/**Construct the frame*/
public Frame1() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
catch(Exception e) {
e.printStackTrace();
/**Component initialization*/
private void jbInit() throws Exception {
//setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
this.setSize(new Dimension(466, 319));
this.setTitle("Frame Title");
jButton1.setText("jButton1");
jButton1.setBounds(new Rectangle(83, 254, 79, 27));
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton1_actionPerformed(e);
jPanel1.setLayout(null);
jButton2.setText("jButton2");
jButton2.setBounds(new Rectangle(177, 256, 89, 23));
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton2_actionPerformed(e);
jTree1.setBounds(new Rectangle(93, 30, 252, 195));
contentPane.add(jPanel1, BorderLayout.CENTER);
jPanel1.add(jButton1, null);
jPanel1.add(jButton2, null);
jPanel1.add(jTree1, null);
/**Overridden so we can exit when window is closed*/
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
void jButton1_actionPerformed(ActionEvent e) {
blnSelection = false;
     jTree1.setSelectionPath(null);
void jButton2_actionPerformed(ActionEvent e) {
blnSelection = true;
class MyTree extends JTree implements TreeSelectionListener
     public MyTree()
          super();
          init();
     private void init()
this.getSelectionModel().setSelectionModeTreeSelectionModel.SINGLE_TREE_SELECTION);
          this.addTreeSelectionListener(this);
          this.setEditable(false);
     DefaultMutableTreeNode selectedNode = null;
     public void valueChanged(TreeSelectionEvent evt)
if(!blnSelection)
     this.setSelectionPath(null);
     else
     TreePath tpSelectedTreePath = evt.getNewLeadSelectionPath();
     this.setSelectionPath(tpSelectedTreePath);
cheers

Similar Messages

  • How to prevent user from selecting a specific printer?

    Hi there
    I have a MailFolder which has an ArrayList of Email objects inside it. Each MailFolder has an attribute called folderFile which is a reference to a folder in the operating system. Each Email has an attribute called parentFile which is a reference to a file in the operating system.
    Now, I am trying to put printing into my application.
    When I print using a normal printer like my HP Deskjet or the likes - an actual physical printer - everything works fine. But when I print using the Microsoft Office Document Image Writer, things go wierd. The following things happen;
    I call myMailFolder.getFolderFile().exists() and this = false. But if I (in the debugger) make a new file pointing to the same path, .exists() = true. Also if I look in the OS, the file exists. So somehow in the job.print() this Document Image writer seems to be messing up this file reference. The same thing happens to the myEmail.getParentFile().
    So to fix this, can anyone tell me how to prevent the user from selecting this printer, or can anyone tell me why this is happening only with the Document Image Writer?
    Many thanks!
    Rachel

    I have similar problem with our printing program. I am printing Java Tables, zoom in every column in a landscape page accross multiple pages.
    There are two fatal problems:
    1. On Dell Latitude laptop, the HP5100 printer didn't work; I have to change the code to draw the table header with 2D graphics.
    2. Crash when printing on MS document image writer, but on some computers
    it works perfectly.
    Any one have a good solution/same result for topic 2?
    Thanks,

  • Prevent user from selecting quiz answer

    I'm using CP5 and my project is predominantly quiz questions.  Each question allows infinite attempts and uses advanced answer options to 'show' audio feedback for all answers submitted (wrong and correct).
    Also, each quiz has an audio introduction.
    When a user enters a quiz slide, the audio intro plays, but the user is able to submit an answer. If they do this, the audio feedback for the question plays at the same time as the introduction audio. Similarly, if the user submits a wrong answer, then quickly submits another answer, the 2 feedback audios play concurrently.
    So, things are working as I expect them to, but it's not ideal and is a little sloppy if a user doesn't wait for audio to stop before doing their thing.
    Is there a way to prevent users from submitting answers while either the intro to the slide is playing or while another answer feedback is playing?
    I haven't been able to figure out how to do this with advanced actions.
    I also considered putting invisible, dead buttons or captions over the answers that would block a user's click until the audio is done, but there's no way that I know to put anything in front of a quiz object.
    Thanks in advance!

    Hi Guido,
    please state your specific question in the posting as well, as after quickly reading it I had to stop and read a second time to really get the meaning of it.
    So you want to know how you can prevent change of selection in certain cases:
    For simple validation a client-side javascript would be easy, this way you can even prevent the submit-event from being fired.
    For more complex validation you need the server, right. But I would not use the iterator method for this.
    The "best" place for input validation would be do_handle_data, which is executed before do_handle_event, where you can react on the incoming row-selection-event and the validation result.
    Regards,
    Max

  • Is it possible to prevent users from using the ''Purge'' option from the ''Recover deleted items'' in Office 365?

    Hi,
    After speaking with a Microsoft engineer over the phone, I've been told that there is no way to prevent users to go to their OWA and manually Purge specific items from the ''Recover deleted items''. The Microsoft tech told us to place the desired mailboxes
    on a litigation-hold and that all data will be recoverable... but only from the time you place the mailbox onto Litigation-Hold and previous items, which doesn't take effect for new-coming emails. 
    1- From what I understand, any new items coming in the mailbox after the Litigation-Hold is put in place will still be ''purgeable'', right?
    2- Is there a way (PowerShell, Security group, etc.) that can prevent a user from using the Purge option?
    We are very surprised that there is absolutely no thread that talks about this issue, which in our opinion, is a major legal and security flaw from Office 365. This is a main concern for us to actually go with Office365. For instance, this means that at
    any given time, if a user exchanges emails with a competitor, they can manually purge emails sent and receive as soon as it is sent/received, even after Litigation-Hold is in place.
    Thank you for your reply and let us know if you have more questions.
    Normand Bessette, IT support technician, Newad Media

    Thank you for the reply.
    Is there still a way to prevent users from using the Purge option, like with a Powershell script to disable Purge?

  • Is there any way to prevent users from ship confirming on a particular date?

    Hello All,
    We have a requirement to prevent users from ship confirming on a particular date. This is due to they are performing Annual Physical Inventory.
    Is it possible to restrict users performing shipping transactions on this particular date?
    I have tried adding exception to the existing Calendar set at org level and there is no customer specific Calendar defined, however it is still allowing me to perform ship confirm.
    Please let me know if you have any suggestion on this requirement.
    Thanks

    Hi,
    Yes is Possible.
    You can add An Exception in Your Shipping Calender.
    So when Some one tries to ship an Order on that date Oracle will automatically select Next possible date.
    Thanks
    Shameer

  • Sales Order - Prevent user from creating more that one schedule line

    Hello,
    Is it possible to prevent users from adding lines (rows) in the schedule line tab of VA01/VA02 ? Our requirement is that one item will have one only schedule line, the quantity cannot be split into different dates.
    Regards,
    Joã

    Hi
    There are 2 schedule lines with different dates for a single line item in a sales order because of forward scheduling done by the system
    System does backward scheduling first and if it fails then it does forward scheduling and that is why you find 2 different schedule lines
    In configuration you can restrict the system to do only backward scheduling and stop after that
    I am not infront of SAP now to tell you exactly where is the configuration available
    I think it is  Logistics execution--delivery scheduling
    But This config is definately available in standard system to avoid 2 or more schedule lines for a single line item in a sales order
    But i am not able to understand what is the business logic for such a requirement because i feel it will create a lot of problems
    with this requirement
    Regards
    Raja

  • GPO to prevent users from accessing the root folder of their profile doesn't work

    Hi,
    Here's the scenario:
    In a Windows 2012 RDS I created two groups called RemoteApp users and remote desktop users.
    These groups are defined in the collection for the corresponding RD Session hosts.
    These groups are not included in any other group, but they are located under an OU -called  Remote Users.
    In the domain controller I have created a GPO named "Restrict access to root drive"  which is linked to the Remote Users OU.
    The GPO I selected is - "Prevent users from adding files to the root of their users files folder"
    This doesn't seem to work. I have waited more than a few hours to allow the 90 minutes update, plus used the gpupdate /force
    but when a user clicks on the RemoteApp (Excel in this example) then access to the C: drive (which is the root folder of the user's profile) is enabled, and the user can create folders and save files under C:.
    I tried to run gpresult for the specific user but the GPO I created wasn't mentioned.
    I thought this would be a straight forward mechanism, but somehow it looks like something is missing.
    I have read about loopback and expanding, but not sure if this is what needs to be done, and if yes - I'd appreciate if I can get  step by step instructions. Everything I found so far was VERY vague.
    Thanks !
    One more detail that may be relevant - the DC is a Windows Server 2012, and the session host is a Windows 2012 R2.

    > These groups are not included in any other group, but they are located
    > under an OU -called  Remote Users.
    >
    > In the domain controller I have created a GPO named "Restrict access to
    > root drive"  which is linked to the Remote Users OU.
    >
    The USER accounts need to be in the OU your GPO is linked to. Despite
    their name, GPOs do NOT apply to groups, but to users (and computers).
    Groups only provide an additional layer of filtering...
    Martin
    Mal ein
    GUTES Buch über GPOs lesen?
    NO THEY ARE NOT EVIL, if you know what you are doing:
    Good or bad GPOs?
    And if IT bothers me - coke bottle design refreshment :))

  • Is it possible to prevent users from viewing a page in Edit Mode?

    Hello everyone,
    I would like to know if it is possible to prevent users from accessing a portal page in Edit Mode. Currently, the users do not have access to any links that take them to edit mode, but if they add &_mode=16 to the end, they view the page in edit mode. Granted, they don't have permissions to add or edit content, but I would like to keep them from seeing this.
    I am using 9.0.4.1
    Any help or suggestions would be greatly appreciated!
    Jim

    hi jim,
    you cannot really configure this in portal. if somebody manually appends &_mode=16 we display the default edit mode, but fully enforce security. this means that the user cannot see anything he is not allowed to see: like pending items, hidden, expired or deleted items. as you said he also cannot add, edit or delete any items.
    regards,
    christian

  • Prevent user from deleting someone else data

    I have a table
    create table T(
    infoID number primary key,
    info varchar2(4000),
    user varchar2(1)
    and users a,b,c with object priveleges on table T.
    What is the best way to prevent user from deleting someone else data?
    1. Create a view for each user to interacat with ( where user='a') and revoke privileges from table T.
    2. Use procedures or trigers to catch a bad user.
    3. ?

    Leo is certainly correct that VPD will solve the issue you have described. however another option also exists without the need to create a separate view for each user (as you described) or the use of VPD, the option would be to do something like the following.
    create user ownera identified by ownera;
    create user usera identified by usera;
    create user userb identified by userb;
    create user userc identified by userc;
    grant connect, resource to ownera;
    grant create view to ownera;
    grant connect to usera, userb, userc;
    conn ownera/ownera
    create table mytable ( id number primary key,
    userid varchar2(8) not null, mod_date date not null, text varchar2 (100));
    create sequence mytable_seq;
    create or replace trigger biu_mytable_trg
    before insert or update on mytable
    for each row
    begin
         select mytable_seq.nextval into :new.id from dual;
         :new.userid := user;
         :new.mod_date := sysdate;
    end;
    create or replace view v_mytable as
    select * from mytable where userid=user;
    grant select, insert, update, delete on v_mytable to usera, userb, userc;
    try inserting and selecting as the various userX users.
    Good luck.

  • How to prevent users from running PRC: Transaction Import from WebADI form?

    Hi,
    We are 12.1.3 and trying to create a workflow to approve Project transactions coming through web ADI before they become effective. To this end, we want to prevent users from running the PRC: Transaction Import from the Web ADI.
    I know that if the checkbox Automatically run transaction import is not checked, the program does not run. But we want to hide this checkbox and not allow the possibility that the program could get triggered.
    To this end, we updated the BNE_INTEGRATORS_B with source='C'. This allows you to edit the integrator from Desktop Integration Manager.
    UPDATE BNE_INTEGRATORS_B SET SOURCE ='C' WHERE  INTEGRATOR_CODE ='PAXTTRXB'
    In the 4th step, where the value for Uploader Parameters is set, we have set boolean value to No. These are the fields on the page:
    Parameter Name: bne:import
    Display Name: Start Transaction Upload
    Data Type: Boolean
    Category: Field
    Default Value: Boolean Flag: No
    Description: start Transaction Import Concurrent Request
    Display Options: Displayed: Unchecked
    Display Options: Enabled: Checked
    Display Options: Required: Checked
    Prompt Left: Automatically submit Transaction import
    Display Type: Check Box
    Maximun Size: 100
    Display Size:100
    Now the checkbox is not appearing for the user to check it, But the program is automatically running when you hit Upload in the WebADI. 

    Hi ,
    Try removing the PRC: Transaction Import Program from the request group for the responsibility used by customers to submit the WebADI and then check if the program launches.
    Regards,
    Raghavan

  • Hi All, We are in to Release 11.5.10.2.There is a specific requirement to Prevent users from creating Manual Sales Orders in oracle and yet users should be able to book the Sales Orders Imported from CRM system into Orcale.Please advise.

    Hi All, We are in to Release 11.5.10.2.There is a specific requirement to Prevent users from creating Manual Sales Orders in Oracle and  yet users should be able to book the Sales Orders Imported from CRM system into Orcale.Please advise.

    Thanks for your advise.
    However, I missed to mention that we have two set of users  One is for Finished Goods and another for Spares.
    Only Spares users need to be prevented from creating Direct/Manual Sales Orders in Oracle.
    As you suggested, if this will be done at Form level, that may Disallow FG users also to create Manula Sales Orders which should not be the case.
    Further, I tried to test one scenario through Processing Constraints but it did not work.
    Application
    OM
    Validation Type
    Entity
    Temp
    Short Name
    TBL
    Validation Semantics
    Created By
    Equal To
    User(Myself)
    Processing Cosntraint
    Application
    OM
    Entity
    Order Header
    Constraint
    Operation
    User Action
    Create
    Not Allowed
    Conditions
    Group
    Scope
    Validation Entity
    Record Set
    Validation Template
    101
    Any
    Order Header
    Order
    Above Created
    Please advise.

  • How do I prevent users from being able to update Firmware

    I have several users (14) with iPad 2 and they rely on an in-house developed App. we have yet to test this App on iOS 5.1 and therefore want to avoid any of the users updating the iPads at all cost!
    this question is in two parts:
    How can I prevent users from upgrading firmware themselves short of just asking nicely?
    How can I stop the iPad from automatically downloading the Upgrade when I deploy a Policy using the iPhone Configuration Utility?
    Any advice would be great!

    We've been looking at the AirWatch mdm and have been told it has this capability.  Not sure if it would be justified from an economic standpoint for you, however. 

  • How to prevent users from saving and emailing intranet documents externally

    Someone in our company needs to upload a pdf to our sharepoint intranet site for internal-only use. How can I prevent users from downloading it and emailing it externally?
    I mean, a user could screenshot it I guess, but I need to give management a due diligence answer.

    You would need to look into a reverse proxy/firewall that had the ability to block access based on content. This isn't something you can accomplish out of the box with SharePoint (even with AD RMS).
    Trevor Seward
    Follow or contact me at...
    &nbsp&nbsp
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • I can't select lines in a pdf ? illustrator has already selected a series of blue rectangles that prevent me from select?

    Hi there, I'm new to illustrator I have been using it to change line weights in pdf's. however the last time i imported a pdf it opens with a series of blue selection boxes which prevent me from selecting individual lines. any ideas? any advice would be much appreciated. Rowan

    ^^Larry could be on to something there...
    Or...
    It's likely you're trying to deconstruct a PDF that wasn't saved by/for Illustrator, so its contents are nested within clipping masks.
    With one or more of those blue boxes selected, choose Object > Clipping Mask > Release

  • How can SAP be configured to prevent users from consuming locks?

    How can SAP be configured to prevent users from consuming locks?
    The issue is that we want to prevent users to use upto maximum locks and so that we will not get lock table overflow issue. I know that we can assign parameter "enque/table_size" a good amount of value. But it is not for any specific user.
    Also want to alert in CCMS if any user reaches to its maximum speficified limit of locks.
    Thanks
    Gopesh

    You cannot set a limit of locks per user. There are two ways to reduce/control the number of locks:
    - change fewer records within one transaction
    - cover more records with one lock using wildcards
    Basically it is an application / development issue.
    Best regards, Michael

Maybe you are looking for

  • Reporting Customer Consignment values

    Hello Gurus, How can we achieve this Need the capability to report on historical customer consignment values. MB58 only shows quantity, and MB52 shows valuation but is just a current snapshot. Need reporting capability similiar to MC.9/MC.L. Can any

  • How to externalize JNDI name (setting JNDI name dynamically)

    Hi, In adapters such as ftp, database, we have to specify the jndi name. This binds the adapter to a particular jndi name. While this is certainly better than binding the adapter directly to the physical resource, I was wondering if it is possible to

  • Lightroom 4 Tethering Preset Publish -- Automation

    Hello, I have a specific need to shoot tethered in Lightroom, apply some presets, then publish (FTP to two location, publish on FaceBook), and save a copy of the file - that is save the modified file with a new name in a different directory and close

  • Control-F2 "Move Focus to Menu Bar" only works occasionally

    I don't want to use my trackpad too much due to a strain injury, hence I use the Control F2 "Move Focus to Menu Bar" a lot. However this feature only works occasionally, it can work for hours and then suddenly stop working, sometimes I can fix in the

  • Aperture 3.0.2 not working for me

    I installed the update and I get fewer crashes when printing (but still get them), however when I click print the processing box appears then disappears before showing any progress and nothing prints. The print shows up in the printer status but show