Semi-opaque panel gets more and more opaque

Hello forum members.
I'm writing a semi-opaque panel with an undesired behaviour and is hoping for clues to what I should do about it.
Desired functionality: A semiopaque panel that can change colour and opacity.
Problem: when I press the 'change colour' button in the code below, the colour changes but the panel gets more opaque for every press on the button. When I resize the panel manually, opacity and colours are drawn as they are supposed to be.
Is there som event to be fired that redraws the panel from the beginning?
import java.awt.*;
import java.awt.event.*;
import java.awt.color.*;
import javax.swing.*;
public class TransparentPanelTest implements ActionListener {
  private JDialog dialog = null;
  private Color bgColour = Color.YELLOW;
  private TransparentPanel panel = null;
  public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        new TransparentPanelTest().show();
  private void show() {
    dialog = new JDialog();
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    panel = new TransparentPanel();
    panel.add(new JLabel("Hello world"));
    dialog.add(panel, BorderLayout.CENTER);
    JButton changeButton = new JButton("change colour");
    changeButton.addActionListener(this);
    dialog.add(changeButton, BorderLayout.PAGE_END);
    dialog.pack();
    dialog.setVisible(true);
  public void actionPerformed(ActionEvent e) {
    bgColour = (bgColour == Color.YELLOW) ? Color.GREEN : Color.YELLOW;
    System.out.println("Setting colour " +
      (bgColour == Color.YELLOW ? "yellow" : "green"));
    panel.setColour(bgColour);
   * Semiopaque panel.
  private class TransparentPanel extends JPanel {
    private Color panelColour = Color.YELLOW;
    private float panelOpacity = 0.2f;
    public TransparentPanel() {
      super();
    public void setColour(Color transparentColour) {
      this.panelColour = transparentColour;
      validate();
      repaint();
    public void setOpacity(float opacity) {
      this.panelOpacity = opacity;
      validate();
      repaint();
    public void paintComponent(Graphics g) {
      Graphics2D g2d = (Graphics2D)g.create();
      g2d.setComposite(
          AlphaComposite.getInstance(AlphaComposite.SRC_OVER, panelOpacity));
      g2d.setColor(panelColour);
      g2d.fillRect(0, 0, getWidth(), getHeight());
}

your panel reports being fully opaque while in fact it isn't, thuss confusing the painting mechanism
CU
Jeanette

Similar Messages

  • I get a box that says a script is not working. The name of the script is file:///C: /Program%20files/Mozilla%20Firefox/components/nsBlocklistService.js:648 This is getting worse and more frequent. What can I do?

    This box pops up more and more frequently, and sometimes completely ties up my computer.
    If I knew any more to tell you, I could probably fix it myself!

    In Firefox Options / Privacy be sure "Remember download history" is checked. To see all of the options on that panel, "Firefox will" must be set to "Use custom settings for history".
    To find your OS information, on your Windows desktop, right-click the My Computer icon, choose Properties, under System on that small window is info about your OS.
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''

  • Optical drive on iMac at work, barely one year old, won't read CD's....disc utilities shows disc unavailable!  Rarely used and out of warranty, what a rip off!!  I have been on MACS since the 80's and things are getting more and more difficult

    Optical drive on iMac at work, barely one year old, won't read CD's....disc utilities shows disc unavailable!  Rarely used and out of warranty, what a rip off!!  I have been on MACS since the 80's and things are getting more and more difficult to deal with. Why did it quit after barely being used? Any help from Apple?

    It depends on what you mean by "barely one year old". If the iMac is only a couple of days out of warranty, Apple's been known to make exceptions and extend the warranty, though it's by no means guaranteed. If it's several days or more out of warranty, then Apple will fix it, if it's a hardware problem, but the repair won't be free. This is no different now then it would have been with a Mac purchased back in the 80s.
    Why the drive failed, if indeed it has, is impossible to say. Could have been a static shock, a weak component that failed when power was applied, or a mechanical fault in one of the tiny parts used in optical drives and hard drives that finally broke.
    Regards.

  • Why are companies getting more and more difficult to contact via phone?

    I recently had a problem with Fandango, then Roxio, and now Adobe and tried to call someone in the USA with no luck.  I am tired of getting some guy in India (or anyone anywhere else) helping me with products I purchased from a US company with US dollars, to be used in the US!  This crap to save money has GOT to end!  Now, when I ask to be transferred to someone in the Us, they say they cannot do so.  I hang up!  Sirius radio is even worse regarding this by the way!   I also tried emailing these idiots with no response.  Does ANYONE know how to contact a US customer service rep?  This country is going down the toilet, just like George Carlin said it would!
    Thanks!

    This is something that has been bothering me more and more as time moves forward.  
    The two biggest companies that I call for support, VMware and SonicWALL, have transitioned to this model.  While it has been going on for a while, the time "wasted" waiting for call backs, not being able to move away from my desk for hours on end, and not being able to get a definitive time for the call backs is hampering my ability to do my job.  I can't even start another support call with another vendor in fear of missing a call back.
    Anyone else notice this trend with other vendors?
    This topic first appeared in the Spiceworks Community

  • HT2729 I bought something in a game for 5$ and didn't get anything but I was charged. This is happening more and more and I don't know what to do. Can anyone help me?

    I bought something in a game for 5$ and didn't get anything but I was charged. This is happening more and more and I don't know what to do. Can anyone help me?

    have you contacted the developers of the games to let them know?

  • Why do i pay more and more money yet the service gets worse and worse -- all the way around.

    First of all, someone need to repair this site, because now, for the last thee times I've tried to log in, I have gotten a message that my password and user name aren't matching or some such nonesense. Mind you, I have it written down, and log in once a month to ipay the bill.
     No more. They'll get it in the mail.
     This is on verizon's end. At first I had no problems but for the life of me, I cannot log into my main account, which I only do to pay the bill.
    THAT is going to stop.
     Next, I want everyone to realize here that my cellphone is still on hold, and it's been a ONE HOUR, AND TEN MINUTES AND I ENDED THE CALL.  This is inexcuseable. Unacceptable.  I won't pay more money for that crap, quite frankly.
     I'm sure now I've been routed  to a black hole, because when I called in, I was -- AND THIS IS OUTRAGEOUS --  routed five tims, five times, five times back to the beginning cue. It is outrageous. There are customer service issues and I'll bet there are even laws against this tyupe of fraud.  I call, I expect to punch in the correct info, which I do, then get routed to the proper place. Instead five times I got booted back to the cue.
    Hey, if it were so easy as they claim this 'IN HOUSE AGENT" AND THIS LIVE CHAT -- WHICH I WAITED 15 MINUTES FOR SOMEONE NAMED ALEX WHO CUT ME OFF, IT MIGHT BE A WAY TO DO. BUT NOT WHEN THE WAIT IS JUST AS LONG, THE PERSON ON THE END IS JUST AS RUDE, THE SERVICE STINKS SO BAD, AND YOU BET I WANT TO TALK TO SOMEONE,...
     MY VOD DOESN'T WORK.
     WITH THE BILL I PAY FOR FIOS TV AND INTERNET, IT BETTER WORK. I KNOW THEY ARE ENGAGING IN THROTTLING -- THAT'S BAD ENOUGH. BUT VOD NOT WORKING? BAD, BUT NOT REACHING SOMMEONE ON THE PHONE? WORSE.
     I FAIL TO SEE WHY ANYONE SHOUDL CONTINUE TO PAY MORE AND MORE MONEY AND GET THIS CRAP SERVICE, AND THAT'S WHAT IT IS LET'S NOT HEAR FRON ANY SYCOPHANTS. 
      BUT I SEE THEY TAKE MY MONEY EACH MONEY. THEY SURE TO TAKE IT.
     WHAT GIVES WITHT HE WEBSITE AND ME CONSTANTLY HAVING TO CHANGE MY PASSWORD? DOES ANYONE KNOW WHAT IT THE ISSUE WITH THAT? BECAUSE WHEN YOU ARE AGGRAVATED, AND YOU SAY OK, LET'S SEE IF THIS WEBSITE HELP IS ANY GOOD -- HYOU WANT TO BLOODY WELL LOG IN WITHOUT HAVING TO CREATE ANOTHER PASSWORD.
      THEN YOU WANT TO GET SONEONE HWO HELPS, NOT AN **bleep**, OBVIOUSL,Y VERIZON ISN'T [PAYING MUCH YOU CAN'T GET ANYONE TO WORK NIGHTS.
      I WILL CALL BILLING TOMORROW. i WANT MY MONEY BACK FOR THIS MONTH'S PAYMENT.
      THIS IS THE WORST SERVICE I HAVE EVER EXPERIENCED. AT LEAST BRIGHTHOSUE IS HERE I TAMPA.

    What type of phone do you have? Is it a newer, 4G phone? Those phones are NOT available with one of the pre-paid plans.
    Do you have a Family plan, or only an individual plan? Family plans are not an option on pre-paid plans. You would have to manage each line separately, keeping a pool of money available in each plan to be paid when the plan renews each month.
    Several people have posted on these forums when they have forgotten to "fund" their pre-paid account and have lost their number and have to begin service again from scratch. There are also those on these forums who have forgotten the funds in their pre-paid account "expire" after a period of time and money in your account can be lost in this manner. Yes, there are upsides, but there ARE downsides to having a pre-paid account. You would have to balance the pros and cons to see which would be the best fit for you.
    Of course, pre-paid is an option, one which everyone must make for themselves. Not everyone will be happy with a pre-paid, but if price is the deciding factor in your choice, it may be the correct choice in your case.

  • I get more and more "input/output error" I erased and reinstalled

    I am getting more and more "input/output error" on a multitude of subjects . I cannot repair the problem even though I have done a complete erase and instal.
    I have a core duo intel based unit with 4 GB ram running 10.6.7.

    It sounds like your hard drive is failing. If you haven't already done so, back up as much data as you can, then take the unit to an authorized service provider for testing.

  • Adobe software is getting more and more buggier

    So, this is getting very frustating...
    I have noticed that Adobe software is featuring more and more bugs in the latest versions. (CC)
    Bug in After Effects is the following: there is this new feature that automatic reloads footage. So if you rendering a 3d sequence, AE reloads the seq.
    A very weard thing is that if you load a sequence starting from 'filename.750.jpg' to 'filename.1400.jpg' AE CANNOT find the footage on a new startup of the project.
    If you render the movie, you get those coloured bars. One can notice the bug when the footage in the project window is displaying blablag[0750]. Notice that this filename has a leading zero. The only solution to be absolutly sure that the sequence is fully loaded is to reimport that sequence. (do not replace, really import a new sequence)  (which is a pain if you a few)
    Then the filename will display no leading zeros.
    (not sure if one can disable this autoload, but even if I can, I dont want to disable that, I want that feature to work)
    Another bug: it is impossible to use the effect Timecode, AE will crash.
    btw, photoshop CC also features some bugs. Smart layers are broken, photoshop will crash. Airbrush is crashing. And all this is on very powerfull machine.
    Has anybody noticed the same thing????
    Very frustating, I have some deadlines and I cannot effort to rerender the whole bunch over and over again.
    Some machine info:
    Using the latest CC software
    on a macbook pro retina, highest model from 2013.
    Newest OSX system.
    16 gig ramm
    over 100gig is still free.

    has that been changed since AE CC?
    I never had any issues importing a sequence. Also, I noticed that I really need to pick the first frame of a sequence. In this case, blablag.750.jpg. That was never been an issue. In the previous versions, you could always pick a random frame and AE just automatic fixes the start and end frame of the sequence. Now you have to be really carefull. Also, this doesn't explain, why AE just shows up the sequence perfectly fine, but on a restart of AE of a background render, things goes wrong.
    weard....

  • TS3376 how do i unlock my phone after i find it if the code does'nt work it keep putting me off more and more minutes at a time?

    how do i unlock my phone after I find it I keep getting this phone is dialed for more and more minutes?

    Back it up and restore it in iTunes on the last computer it was synced with, as explained at the bottom of this article: http://support.apple.com/kb/HT1212.  This will remove the passcode.

  • Mail slowly eats more and more Real Memory until it's super sluggish

    My Mail had been giving me lots of problems.
    Basically it is fine when I open it and starts to become more and more slow and unresponsive the longer I have it open. I ultimately have to quit, and it always has to be a force quite because it just gets jammed.
    I started looking at Activity Monitor and have noticed that when I first run it, it uses about 150 megs of Real Memory. (I have 4gigs). Over the course of 2 hours, the Real Memory used creeps upwards and upwards, until it's over a GIG. The performance just gets worse and worse. The MB Pro's fans start whizzing away.
    Anyone know why this might be happening and what I can do to stop it?
    Thanks so much
    Scott

    Found a post in another Forum which (so far) seems to have fixed my problem:
    "I spent some time on the phone with Apple tech support today. They were very helpful and appeared to have solved the problem. They had me go to iSync in the applications directory, go the Preferences and then click on Reset Sync History. First they had me log out of MobileMe, but not sure that was important. I logged back in to MobileMe. I have now been using my Mac for an hour now with no recurrance of the safarisyncclient".
    Here's hoping.

  • How to make a text becoming more and more visible?

    Maybe I didn't use google well, but I didn't find anything in the internet what could solve my question.
    I basically want to work with a white background, where a text is on which becomes more and more visible the more it comes closer to the bottom. The tricky thing is, it's for a website, so it has to be responsive for smartphones or tablets for example (first idea: put the white background layer to the front like it makes the text behind it more and more visible/invisible?). Any ideas how to solve that? Would be so great to know.

    I'm not sure what it means to "be responsive for smartphones or tablets"...  People put complex graphics on those things all the time.  They have unprecedented power.
    Photoshop can help you do what you're describing.  What you want is no more complex than putting a gradient mask on a layer so as to create partial transparency.  You could have fading text (as a graphic) or a fading solid color fill that would overlay text rendered by a browser.
    Just some graphic ideas...
    Save as a PNG-24 to get partial transparency that a browser can render.
    -Noel

  • I have a first gen iPad, 64g, and for no apparent reason, the screen goes black and whatever app I am using is closed on me. It seems to be happening more and more frequently, especially when loading a blog, or trying to watch a YouTube video. I try to o

    I have a  iPad, 32g, and for no apparent reason, the screen goes black and whatever app I am using is closed on me. It seems to be happening more and more frequently, especially when loading apps, or trying to watch a YouTube video. I try to open safari or youtube again and it will often crash several times before it may or may not decide to load for me. It is extremely annoying and getting to the point where I can not use it

    Standard troubleshooting steps in order are as follows:
    Power the iPad off and on.
    An iPad reset, which is done by pressing and holding the home button and the sleep/wake or on/off button simultaneously until you see the Apple logo and then release.
    Restore your iPad with iTunes from your iPad's backup.
    Restore your iPad with iTunes as a new iPad or not from your iPad's backup.
    If no change after the last step, your iPad has a hardware problem.

  • Phone growing more and more lethargic and sluggish

    Over the last two weeks my 3G iPhone has grown more and more sluggish.
    Simply opening any built-in app now takes forever.
    Some apps are so slow to respond that they overlap each other when switch between them or if I get a call or a text message.
    I removed most third party apps, cleared caches, restored software, etc, but I'm still finding the phone is creeping along.
    Could this be a hardware issue?

    Zeebra wrote:
    I've now made a habit of rebooting once a day to ensure snappy performance.
    If you have to do this, perhaps you should visit the apple store. Its not normal, its not supposed to help, and you are not supposed to have to do this. Given the number of people reporting sim not registered problems after a reboot i'd be a little leery of doing this dail
    My phone takes a 5 count (1001, 1002, 1003...) to show anything on the settings screen after I select it from the main screen. Does this if I reboot the phone or not.

  • EMU 0202 USB ASIO more and more crackle until complete drop out after approx. 5 mins

    Hi!
    The subject already pretty much wraps up my issue. I have an EMU USB 0202 which I am using in ASIO mode. Indepedently of the software that is used to playback something (e.g. Fruity Loops, Ableton Live, or Virtual DJ), I get crackles in the sound after approx 5 minutes (give or take a minute). If I leave things running like this, the sound quality degrades more and more for approx another minute, up to complete silence.
    Interesting fact: This can be fixed, by simply having the software "close/release" the device. E.g. by switching to Direct Sound and back to ASIO. Pretty much everyting, that causes the software to reinitialize the ASIO driver, will fix this - for the next 5 minutes.
    I have probably already tried whatever piece of advice I could find. I have checked my system settings, incl. the stuff that one of the moderators listed here in the board (http://forums.creative.com/t5/Profes...USB-and-0202-U...).
    I have used the DPL Latency checker tool. I don't see any sparks here. The only thing I noticed is, that as sound degrades, the latency slowly rises. But we are talking of "peaks" of 500µs when the sound starts to degrade.
    I also used this PCI Latency Checker tool, but everything is set to either 0 or 64 - from what I've read, PCI latency could only be a problem if I were to see values like e.g. 128 or even max of 255.
    I don't see any load peaks on the system either - neither disk activity or anything. Though the DAWs and the VSTs can cause some pretty heavy system load, the system is pretty much idle when playing songs back with VirtualDJ. And still as said before, after a few minutes things go from good, to bad, to worse, to silence. Searching though the net, it seems like everybody else is having some kind of general USB audio problem, where they have instant/permant crackling. I have not yet found anybody else with such a gradual decrease. The only person so far which also reports a similar issue is this:
    http://forums.creative.com/t5/Profes...;jsessionid=6A...
    But seems like he also did only get the standard "try this" - text block answer. As I said, I already tried all these.
    So, what else can I do? This is really frustrating....
    Any suggestions?
    EDIT: It's too obvious (too me at least) that I forgot to mention: This happens independently of the buffer settings. I can go with 6ms or 50ms... problem is still the same. Also the "timing" of the problem is not affected by this.

    Places you need to look are are your IDE bus and PCI bus.
    Verify that the chipset drivers are up to date.
    Also verify that your USB host is not sharing with any devices like WIFI or SATA controllers.
    Have you sent a support ticket to E-MU support? You may want to for an issue like this.
    http://www.emu.com/support/askus/ema...asp?CRSStatus=

  • Our Imac becomes more and more slow

    Our Imac becomes more and more slow ("rainbow wheel" appearing most of the time. We suspect some kind of internet pollution. Dors anybody know where hidden big files could have been stored and should be deleted?
    Thanks

    DamienGD wrote:
    Our Imac becomes more and more slow ("rainbow wheel" appearing most of the time. We suspect some kind of internet pollution. Dors anybody know where hidden big files could have been stored and should be deleted?
    Thanks
    There are lots of reasons why a computer might slow down but the most common are 1) too little RAM, 2) the hard drive is too full, and 3) a 'rogue' program is using lots of CPU cycles. The first step to dealing with this problem is not to try 'cleaning' the computer.
    How much hard drive space is free on your computer? Programs need to create temporary files so the computer should have some empty space for them. You should keep something like 10%-15% free. There's a tool in the Utilities folder of your Applications folder called Activity Monitor. Drag it to your Dock so it hand, then reboot your computer and start Activity Monitor.
    The activity Monitor will let you look at what your computer is doing and you'll want to keep your eye on two things: Click on the CPU tab and you can see all the programs your computer is running. In the list you can click on the CPU column to get the list sorted by CPU usage. This is useful because it lets you see if a program is using lots of CPU cycles. If you have an application that is consistently running at 50% or higher, that is probably not good. The second thing you want to watch is RAM. Click on the System Memory tab and you can see all the programs and how much RAM each one is using. But the really important information is next to the pie chart. You'll see VM, Page ins, Page outs, etc. The Page ins number is important - a high number is not good.
    I suggested that you reboot your computer before you started the Activity Monitor. This will have reset Page Ins to 0. Now over the course of an hour, keep referring to the Page ins. If that number remains 0, you have plenty of RAM. The higher it gets, the more you need a Memory upgrade. When you restarted the computer also deleted all the temporary files, so take a look at the free space too. At this point you should see at least 10% free. If not, your drive might be too full.

  • I have an almost 3 yr old Mac Book Pro and have noticed the colorwheel pop up more and more to process anything applications I use or websites I browse.  Do I need to add more RAM? Is it possible to add more RAM?

    I have an almost 3 yr olf MacBook Pro and have noticed that my color wheel pops up more and more. I can't open a simple document sometimes w/o it popping up and spinning before it opens.  Same goes for when I'm on the web browsing different sites.  Can I do something to rectify this?

    First, back up all data immediately, as your boot drive may be failing.
    Launch the usual set of applications you use when you notice the problem.
    Step 1
    Launch the Activity Monitor application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Activity Monitor in the page that opens.
    Select the CPU tab of the Activity Monitor window.
    Select All Processes from the menu in the toolbar, if not already selected.
    Click the heading of the % CPU column in the process table to sort the entries by CPU usage. You may have to click it twice to get the highest value at the top. What is it, and what is the process? Also post the values for % User, % System, and % Idle at the bottom of the window.
    Select the System Memory tab. What values are shown in the bottom part of the window for Page outs and Swap used?
    Next, select the Disk Activity tab. What approximate values are shown for Reads in/sec and Writes out/sec?
    Step 2
    You must be logged in as an administrator to carry out this step.
    Launch the Console application in the same way as above. Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left.
    Post the 50 or so most recent messages in the log — the text, please, not a screenshot.
    Important: Some personal information, such as your name, may appear in the log. Edit it out before posting.

Maybe you are looking for

  • How to recover deleted songs from iTunes hard drive (not iPod)

    I have a Western Digital hard drive that I use to play all of my mp3 files. Tonight I was creating a playlist by dragging and dropping songs. Although I thought I was editing the playlist, it turns out that I accidently deleted a song from my library

  • How do you print a mirror image on an HP Photosmart Premium C310a?

    I cannot find anywhere on the printer, or in my computer to click on a box for mirror printing.  I'm trying to print an iron-on transfer. This question was solved. View Solution.

  • How to install windows 8.1

    I installed windows 7 in my laptop . But i want to install windows 8.1 again . I have 5 recovery disks too. Can i install windows 8.1 using recovery disks or another method .... Plz suggest.. This question was solved. View Solution.

  • Mysteriously unreadable Unix/JPEGs

    I have scores of JPEGs that I removed from my late mother's 1st gen. iMac running OS 9.2.2. They were perfectly readable/viewable when they were on her machine, however now that I am trying to see them on my PPC G5/OS10.5.5 they have morphed into "Un

  • Firelite Firewire external not mounting

    I am running OS 10.4.7 and my external hard drive will not mount. I went back to the install CD and tried that but it says that it needs a system folder in order to complete the installation. Where can I find this sort of folder? Do I need to downloa