How do I make a JTextArea invisible to the mouse?

Consider the applet below. There is a small JTextArea sitting in the glass pane. There are 3 JButtons sitting in a JPanel that is sitting in the content pane. One is completely under the JTextArea, one is half in and half out, & the last is completely outside it (at least I hope thats what it looks like on your machine.) The idea is when you click the disable button the JTextArea is disabled and you can click on the button that's underneath it.
But it doesn't work that way. even when the JTextArea is disabled the mouse still cant click through it.
Is there some way to make the JTextArea completely invisible to the mouse so I can click through it? I know setVisible(false) on the glass panel will work but I only want it to be invisible to the mouse, not my eyes.
Thanks.
/*  <applet code="MyTest14" width="400" height="100"></applet>  */
// testing glass panes
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.swing.*;
public class MyTest14 extends JApplet implements MouseListener
TextPanel textPanel;
JPanel buttonPanel;
JButton underButton, enableButton, disableButton;
JTextArea jta;
public void init()
  Container contentPane = getContentPane();
  contentPane.setLayout(new FlowLayout());
  contentPane.setBackground(Color.WHITE);
  underButton = new JButton("Under textarea");
  underButton.addMouseListener(this);
  enableButton = new JButton("Enable textarea");
  enableButton.addMouseListener(this);
  disableButton  = new JButton("Disable textarea");
  disableButton.addMouseListener(this);
  buttonPanel = new JPanel(new BorderLayout());
  buttonPanel.add(underButton, "West");
  buttonPanel.add(enableButton, "Center");
  buttonPanel.add(disableButton, "East");
  jta = new JTextArea();
  jta.setPreferredSize(new Dimension(200,80));
  jta.setOpaque(false);
  jta.setLineWrap(true);
  jta.setWrapStyleWord(true);
  textPanel = new TextPanel();
  textPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
  textPanel.add(jta);
  jta.setBorder(BorderFactory.createLineBorder(Color.black));
  contentPane.add(buttonPanel);
  setGlassPane(textPanel);
  textPanel.setVisible(true);
public void mouseClicked(MouseEvent e)
  if (e.getSource() == enableButton) { jta.setEnabled(true); }
  else if (e.getSource() == disableButton) { jta.setEnabled(false); }
  else if (e.getSource() == underButton) { System.out.println("You reached the under button!"); }
public void mouseExited(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}
public void mousePressed(MouseEvent e) {}
class TextPanel extends JPanel
  public TextPanel()
   super();
   setOpaque(false);
  public void paintComponent(Graphics g) { super.paintComponent(g); }
}

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Test extends JFrame {
  Container content = getContentPane();
  JButton jb = new JButton("Press"), disenable = new JButton("Enable");
  JTextArea jta = new JTextArea("Now is the time for all google men to come to the aid of their browser");
  public Test() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel jp = new JPanel();
    content.add(jp, BorderLayout.CENTER);
    jp.add(jb);
    jb.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ae) { System.out.println("Click!"); }
    jta.setLineWrap(true);
    jta.setWrapStyleWord(true);
    jta.setOpaque(false);
    jta.setEnabled(false);
    JScrollPane jsp = new JScrollPane(jta);
    jsp.setOpaque(false);
    jsp.getViewport().setOpaque(false);
    jsp.setPreferredSize(new Dimension(130,130));
    JPanel glass = (JPanel)getGlassPane();
    glass.add(jsp);
    glass.setVisible(true);
    jta.addMouseListener(new MouseListener() {
      public void mouseReleased(MouseEvent me) { mousy(me); }
      public void mouseClicked(MouseEvent me) { mousy(me); }
      public void mouseEntered(MouseEvent me) { mousy(me); }
      public void mouseExited(MouseEvent me) { mousy(me); }
      public void mousePressed(MouseEvent me) { mousy(me); }
    content.add(disenable, BorderLayout.SOUTH);
    disenable.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ae) {
        jta.setEnabled(!jta.isEnabled());
        disenable.setText(jta.isEnabled()?"Disable":"Enable");
    setSize(200,200);
    setVisible(true);
  void mousy(MouseEvent me) {
    if (jta.isEnabled()) return;
    Point p = SwingUtilities.convertPoint((Component)me.getSource(), me.getPoint(), content);
    Component c = content.findComponentAt(p);
    if (p!=null) c.dispatchEvent(SwingUtilities.convertMouseEvent((Component)me.getSource(), me, c));
  public static void main(String[] args) { new Test(); }
}

Similar Messages

  • How do you make a movie clip face the mouse

    How to you make a movie clip rotate so it's always facing the
    mouse?

    thanks a lot! I got the code to work, I just modified it a
    bit.

  • Is there any way to make work item invisible in the SAP inbox?

    Is there any way to make work item invisible in the SAP inbox?
    If yes , How?
    How can we delete a work item without using SAPLSINWP program?Is it possible???

    Thanks suresh, But I was a looking for a solution where as soon as the work item is created should be made invisible in the SAP inbox, is there any way for this or any other alternative?

  • How do i make it so iTunes plays the music files from where i have chosen to store them?

    how do i make it so iTunes plays the music files from where i have chosen to store them as opposed to it scattering copies of my files into a myriad different folders based on the albums they came from when i'm not even interested in keeping whole albums?
    I recently converted myself to mac after having been a windows formatted person since the beginning of time. I use last.fm and the client scrobbler only supports iTunes on the mac (scobbling since Nov 06 and i'm now heavily dependant upon it as a means of discovering new music) - if you don't know what that means then take it for granted i have no option other than to use iTunes as my media player whn using the mac. And almost immediately upon using iTunes i was filled with horror.
    My tale of woe as follows: I copy all my mp3 files to folder X on my new mac. I copy my simple playlist in to that same folder X. The simple playlist simply lists all the files in folder X in the order i want to hear them in... simple right? And what happens the moment i start playing my simple list? Well you probably all ready know; itunes throws copies of all those files in to the air, scatters them to the four winds so each of them fall into a little folder of their own representing the album they might once have come from. I don't keep whole albums. For me the 'album experience' is a ruse to trick one into listening to weaker material. I only keep the concentrated goodness. I only put up with albums in a previous lifetime because in the days of vinyl i had no other choice apart from spending hours compiling mix tapes. Now i am liberated from these restrictions and have been for the 15 or so years i've been using a computer to listen to music. Until along comes iTunes forcing me backwards in time, frog marching me back into the past.
    That simple list i mentioned is my one and only playlist. This single playlist has been evolving for 15 years as tracks are added and removed and their position in the list changes because that song sounds amazing when heard after that other song whereas hearing this song after that song would be like pouring custard over your sausages (for me shuffling is an abomination). And so here is how i've managed this list and managed synchronization of said list and listed files with my mp3 player (currently a Zen).
    Adding a new file: After deciding that song is a keeper i will copy it into that simple folder that holds all my music and drop it in to a position on the list i deem most suited for it. Incidentally over this entire 15 year (i'm pretty sure it's been around that long) my media player has been winamp but for the reason previously mentioned i am unable to use winamp in mac world.
    Removing a file: fortunately winamp has an option to simultaneously remove a file from the list and the hard drive. And naturally so because after all if i no longer like a song then i want it expunged completely from life or at least from my hard drive and playlist. In the brave new world of iTunes i have to remove from the list there then delete the file from where iTunes copied it from and then the place iTunes copied it to.
    Editing the list: drag an item in the list to it's preferred location and select to save it as i would for any other file using any other application... well desktop type application as opposed to one that uses a database as its primary means of storage.
    Syncing with the mp3 player: copy drag drop playlist file from the simple folder on the hard drive to the simple folder on the mp3 player as i would for any other file. And then also copy drag drop the most recently created files from simple folder on hard drive to simple folder on player after having ordered them by creation date so as to make it easier to select the most recently created. After a while the mp3 player will fill up with the files no longer on the list so i will delete all files from player then re-copy all flies from simple folder on hard drive to simple folder on mp3 player.
    I do not make changes to the list on the mp3 player so synchronization needs only to go one way: from laptop to player.
    So all very simple. Apart from editing the positions of files in the list everything is managed by copy drag dropping and deleting files using windows explorer.
    But i'm in a mac and circumstances have forced me in to the corner of using iTunes. And this whole iTunes situation is terrifying for me as over the years i've heard horror stories about it deleting all of someone's music files. Perhaps this may have been by using the software incorrectly but even so, the very fact that it appears possible for this to happen simply by using the software incorrectly and the fact that it happens with some degree of frequency given the number of reports of this happening that i have heard of over the years on music discussion forums fills me with dread that i have to now use this software. And given the software's blatant disregard for the user's choice as to where to store his/her files it's no surprise that this happens. The software is pointlessly doing dangerous things with my data. Please make it stop.
    Please can i just at the very least make iTunes play the music from the folder i have chosen to put my files in and not copy those files here there and everywhere without my say so? Thankyou.

    option discovered in preferences. Really this and any feature that moves deletes or edits a users data should as far as possible be OFF BY DEFAULT. It shouldn't by default and without the users specific say do this dangerous and unnecessary thing without even letting the user know what it's doing!!! And then cause me a few hours (as i'm new to mac) searching for the option so as to switch it off. If i hadn't noticed the status cage declaring that it was copying files then i might never have twigged that this insane thing was occurring. And if i hadn't of noticed i would have been left maintaining the contents of the folder i copied the files to, the folder which as far as i was informed and so believed was also the location of the music files i was playing. How does Apple justify this 'genius' piece of software non-design? Surely it will hurt no one if this was off by default for new users - overall at least i dare say it would cause a lot less distress in the future for the unsuspecting public at large. Thanks for the support.

  • How do I make an e-mail account the default account (I have 2 accts)?

    How do I make an e-mail acct the default account?  I want my contact list to come over to my iPad.

    To make it the default account- iPad settings, mail,(under signature) default account. Select it and change it. The address book, under that account make sure you have addresses ON.

  • When i burn videos to a dvd-r disc it works on my macbook but not on a windows/pc or my dvd player. How can i make it work on all the above and not just a mac product?

    when i burn videos to a dvd-r disc it works on my macbook but not on a windows/pc or my dvd player. How can i make it work on all the above and not just a mac product?

    Unfortunately, the recording & movie industry does not respect the rights of the people who make them money, and thus you can only use the paid-for content in ways they see fit. Even if I lived in a bunker where no one else could possibly see the movie I paid for, therefor I'm not 'sharing it illegally', I would still not be allowed in a blue moon to copy that movie to DVD for TV viewing. Someone will tell you to get an AppleTV. How about Apple give us one for free? Until this changes, people wanting to use their content in multiple locations will continue to download music & movies via torrents, legally or illegally.

  • How can you make your persona show on the top and bottom? Also can you make it bigger at the top to show more of the picture?

    How can you make your persona show on the top and bottom?
    Also can you make it bigger at the top to show more of the picture?

    Add extra empty toolbars if you want to see more of the persona.<br />
    You can create extra toolbars to get extra space via View > Toolbars > Customize<br />
    You have to put something on a toolbar (drag a Space item onto it) before closing the Customize window because empty toolbars are automatically removed.<br />
    See http://kb.mozillazine.org/Toolbar_customization

  • How do you make "Acrobat X Pro" open the "combine pdf" window in the foreground?

    How do you make "Acrobat X Pro" open the "combine pdf" window in the foreground?
    I am using a "Windows 7" computer at work with "Acrobat X Pro" and I'm constantly combining
    pdf's and tiff's in Acrobat.
    It would be nice if when I select 30 or 40 files to combine, the
    "Combine Supported Files in Acrobat" window would open in the
    foreground, not behind the 10 or so windows already open.
    I have been researching this for some time now with no solution.
    If the answer is that "IT CAN'T BE DONE", then that's fine. At least
    I will have an answer and can stop searching. If (as I suspect) it can
    be done, then kindly supply me with "step by step" instructions.
    Michael Jones

    Something that works  (provides Acrobat the application precedence in the OS that is requisite for this) --
    Minimize the 10 or so application windows before engaging use of Acrobat's "combine".
    That'll let the Acrobat dialog windows display front and center.
    Be well...

  • How do I make a bootable cd from the windows .iso file

    I am trying to install windows xp on my iMac. My univeristy gives me free copy of XP but I have to download the .iso file. I tried burning the .iso file to a cd but bootcamp says it can not recognize the cd for installation. How can a make a bootable copy of the windows xp .iso file so that I can install it on my iMac.

    You used Disk Utility I take it?
    http://en.wikipedia.org/wiki/ISO-9660
    http://www.ezbsystems.com/ultraiso/
    This is for creating a custom Vista SP1 EFI-enabled DVD:
    http://www.jowie.com/post/2008/02/Select-CD-ROM-Boot-Type--prompt-while-trying-t o-boot-from-Vista-x64-DVD-burnt-from-iso-file.aspx

  • How can I make a survey automatically identify the user in the results?

    How can I make a survey automatically identify the user in the results (so that it won't be anonymous)?

    I am not sure what information to provide.  Here is what I am trying to do.  I am trying to create an HR questionnaire with multiple choice questions and several multiline textboxes to capture comments.  I want to send it out by email address and/or embed the questionnaire somewhere on the company's intranet website.  But we don't want the questionnaire to be anonymous. If someone makes a particular comment, we want to be able to communicate with the person who made that particular comment.  How would we be able to trace the person? By email address, or by user ID?

  • How can I make a permanent change in the zoom level?

    I want to know how I can make a permanent change is the zoom level? I dont want to constantly have to change it from the default value of 100% every time I go to a different page. Thanks.

    Hello,
    You can also use the [https://addons.mozilla.org/en-US/firefox/addon/2592/ NoSquint] add-on to change the default zoom level for all websites at once. After setting your global zoom level, you can fine-tune the zoom on individual sites and set the options so that NoSquint remembers per-site settings.
    After installing NoSquint, go to the add-ons page to set the per-site settings:
    * Tools (or [[Image: New Fx Menu]]) > Add-ons > Extensions
    * Click the "Options" button by NoSquint

  • How can I make an appointment to see the staff to repair

    How can I make an appointment to see the staff to repair

    If in US
    http://www.apple.com/retail/storelist/

  • How do I make a settings shortcut on the iphone 5? Specifically the do not disturb function??

    How do I make a settings shortcut on the iphone 5? Specifically the do not disturb function??

    Is there an app that does it? I found a brdrck website but it is unavailable now  

  • How do you make a page scroll horizontally with mouse wheel?

    As the title says, how do you make a page scroll horizontally with mouse wheel in edge animate?

    This should get you there
    http://css-tricks.com/snippets/jquery/horz-scroll-with-mouse-wheel/
    1. Load the mousewheel min script via CDN (jquery-mousewheel - cdnjs.com - the missing cdn for javascript and css)  into the Scripts Panel;
    2. Add the provided snippet into your Stage > compositionReady event handler.
    hth
    Darrell

  • How do I make New window open maximized the way it used to?

    How do I make New window open maximized the way it used to?

    { Ctrl + B } opens and closes the Bookmarks Sidebar.

Maybe you are looking for

  • Music downloads to the wrong folder

    Hi. I'm running Mountain Lion on my MacBook Pro and understand that music, movies, TV shows, etc., should download to their respective folders within the 'iTunes Media" folder, which is located here: User --> Music --> iTunes --> iTunes Media. My pro

  • Dual Monitor Problem - Context Menus are in the wrong place

    Hey there, I've been looking all over google to try to find a solution to this problem, but to no avail. I'm currently using a second monitor together with my macbook pro on leopard. When ever i open up a context menu, the menu appears on the first s

  • DirectInput and joystick in PDF

    Hi, All ! Is there a way to use Windows DirectX DirectInput module and joystick in PDF ? Regards, Yuri Kovalev

  • Need to include Custom control in Tabstrip (which is present in selec scren

    Hi All, Is it possible to create a custom control in the selection screen of a report program.? Its not possisble to use a module pool program. Regards, Sudheer

  • Timestamp and Nonce value in SOAP header

    Hi, can you provide some guidance on how to handle this Oracle SOA suite 11g My application was calling an external web service which was just expecting the user name and password. So I was using username_token_client_policy with a csf key Now the ex