Component problem, transparency and paint custom paint

It is a little weird to describe problem so I tried to compact an example I can in small. I have a component that goes to a defined framerate, so it has a runnable interface and loop through and call repaint() on himself. If the component is not in a loop to repaint there is no problem, he draws the JInternalFrame transparent very well, but when he loop it creates a reall mess, sort of 'pulse' draw the background all wrong, and the buttons that you hover over appear in the upper right of the pane, its really weird.

In any case, I was wondering if someone could take a look at my sample code and see if they can see what's wrong with it:
import java.awt.Color;
import java.awt.Graphics;

import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;


public class Test extends JFrame
{
     public Test()
     {
          this.setVisible(true);
          this.setSize(1000, 600);
          JDesktopPane dtp = new JDesktopPane();
          this.add(dtp);
          
          JInternalFrame internalFrame1 = new  JInternalFrame("frame1",true,
                    true,true,true);
          internalFrame1.setLocation(100, 100);
          internalFrame1.setSize(300, 300);
          internalFrame1.setVisible(true);
          internalFrame1.setBackground(new Color(250,0,0,50));
          internalFrame1.setOpaque(false);
          dtp.add(internalFrame1);
          
          JInternalFrame internalFrame2 = new  JInternalFrame("frame2",true,
                    true,true,true);
          internalFrame2.setLocation(500, 100);
          internalFrame2.setSize(300, 300);
          internalFrame2.setVisible(true);
          internalFrame2.setBackground(new Color(250,0,0,50));
          internalFrame2.setOpaque(false);
          internalFrame2.add(new JLabel("check transparency on this"));
          dtp.add(internalFrame2);
          
          CustomPaintComponent cpc = new CustomPaintComponent();
          
          internalFrame1.add(cpc);
          
          this.validate();
     }
     
     public static void main(String args[])
     {
          Test t = new Test();          
     }
     
     class CustomPaintComponent extends JPanel implements Runnable
     {
          public CustomPaintComponent()
          {
               Thread thread = new Thread(this);
               thread.start();
               this.setOpaque(false);
               
          }
          
          public void paintComponent(Graphics g)
          {
               super.paintComponent(g);
               g.drawOval(0, 0, 50, 50);
               g.drawString("CustomPaintComponent", 10, 10);
          }

          @Override
          public void run()
          {
               while(true)
               {
                    try
                    {
                         System.out.println("repainting!");
                         Thread.sleep(100);
                         repaint();
                    } catch (InterruptedException e)
                    {
                         e.printStackTrace();
                    }
                    
               }
          }
     }
}

I'm under JDK 1.6.0_24 on Windows XP

CustomPaintComponent cpc = new CustomPaintComponent() {
  @Override public void paintComponent(Graphics g) {
    super.paintComponent(g);
    g.setColor( new Color(250,0,0,50) );
    g.fillRect(0, 0, getWidth(), getHeight());

    g.setColor( Color.BLACK );
    g.drawOval(0, 0, 50, 50);
    g.drawString("CustomPaintComponent", 10, 10);
  }
};
//internalFrame1.add(cpc);
internalFrame1.setContentPane(cpc);
//or
//JComponent c = (JComponent)internalFrame1.getContentPane();
//c.setOpaque(false);
//c.add(cpc);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Published by: aterai on 08/03/2011 21:59

Tags: Java

Similar Questions

  • Photoshop CS4 type tool and paint bucket

    I'm teaching my students Photoshop CS4 and have started to have problems, I've ever met.

    Problem #1 - text tool will not work. We can create a text box and type in it. Text does not appear on the document, but appears in the layers palette. I made sure the layer is on top and text is not too large for the text box font color contrast the background. I have looked at the character and paragraph palettes you are looking for something unusual but found nothing.

    Problem #2 - the paint bucket is "stuck" on one color. Any sample of the color I chose, the color does not change. I created new documents and also closed and reopened the program but that didn't help either.

    Enyone met these problems? How you solve the problem?

    1st thing I would do is put him tools. I use a Mac and CS3, but I think he's still in the same place on CS4 and Windows:

  • ADOBE CC - Customer Service fail to resolve my problem (curves) and compensate for them.

    Event history:

    23 February:

    I discovered that Adobe Photoshop 2015 CC had a problem with the program

    -J' I import my raw image

    -Apply the curve

    -Curve pen

    -Save as a PSD and JPG

    -Image on the PSD and JPG file appear with no good hard and curve lines.

    I report this problem to the Photoshop customer service, they said, it was a problem to update. I uninstall and reinstall... She still took place. Customer service suggested that I use Photoshop 2014.

    I paid over 100 dollars for old hardware? I didn't think it was just... anyway. I waited.

    March 4:

    I reinstalled 2015 and the black lines were always there.
    -J' have customer service message, they acknowledged the problem (bug) and assured me that the problem could be solved on the next update.
    -The update for adobe Photoshop was in November... (at this point I'm still paying)

    -They recognized this was not my fault and gave me a 30 day extension.


    30 days after I requested additional since an extension I was using a lower quality product. They do not allow this. Now, I'm upset.
    Not only am I paying full price, I pay for something less.

    They referred me to a (top team) B.S. that would respond to my inquiries about the problem...
    A came response where I was told that I was unable to get the extension... The end.

    What kind of service is that? Still, I have black lines on my jpg files and cannot produce impressions of Adobe Photoshop 2015! I will not be satisfied with something obsolete! What is the point of subscription if I don't get to use the latest software?

    I have attached a picture for example, nothing special. It's not supposed to be a hard line on my image, but each image that I recorded with changes product LINES TOUGH! * Note This is a PSD file, but jpg files save and print the same!
    Photoshop Fail.png

    If you have a solution... I'm all ears, because the Adobe creative team can't do anything for me and will not compensate for me either.
    If you are interested in the transcripts between service customer and I have... I have them.

    Just out of curiosity, you reset the Photoshop preferences? Worth a try.

    Manually; course may be cancelled:

    http://TV.Adobe.com/watch/the-complete-picture-with-Julieanne-Kost/how-to-reset-Photoshop-Le file-Preferences-cs6s.

    Fast; cannot be undone:

    Win: Press and hold the keys Ctrl + Alt + Shift immediately after the launch of Photoshop starting. A box will appear asking if you want to continue with the reset, select 'yes '. If you don't see this, you're not fast enough... Try again.

    Mac: Press Cmd + Opt + shift then launch Photoshop. A box will appear, asking you if you want to continue with the reset, select 'yes '.

    In addition, as Warunicorn says, check updates of system which may include new graphics drivers.

    If you continue to see the problem, you could post a bug in the feedback.photoshop.com report

  • Hey, I just wanted to buy a package complete apps for creative cloud every time that I enter the stage at the confirmation stage its tells me there is a problem procedure and I need to contact customer service

    Hey, I just wanted to buy a package complete apps for creative cloud every time that I enter the stage at the confirmation stage its tells me there is a problem procedure and I need to contact customer service

    Make sure that you are logged on the Adobe site, having cookies enabled, clearing your cookie cache.  If he continues to not try to use a different browser.

  • Problem with transparency and gradient in several forms

    preview.jpg

    Hello guys,.

    I have problem very stange (am have been strugling with four hours), I'm desperate and I hope I'll find help here. Thanks in advance...

    Here's the deal... I created this shape in photoshop (see the image attached). It's 6 circles with equal to 47 alpha / then I merged the circles and applied degraded (#f7c105 to #f4480b) and the angle set - 145

    Now, I try to recreate this shape in Illustrator... As you can see the image it sympathy ' e close but not the same thing. I do not know how to merge circles but to preserve transparency and then set the gradient.

    If someone has an idea, I'll be very grateful.

    Thank you.

    Yet a similar but variant method if you have 4 CS and later versions.

    http://www.wadezimmerman.com/videos/TransparentGradientCircles2.mov

    In addition if you adjust the Annotator degraded, then you can change the way in which the gradient fades as well.

  • Custom particle problem, transparency is not in generated particle projection?

    Using After Effects CS5 and Trapcode particular:

    I want to use a custom for the generated particle particle.

    So I imported a .gif image of a grain of pollen, which have a transparent background.

    Transparency does not show any automagically after importation, but I found (via Internet) I can

    Select the image imported into After Effects and follow these steps:

    Effects > masking > color key and then use the pipette out the color I want to be transparent?
    Then the imported image transparent where it should (more or less), but generated particles still show white background instead of the newly added transparency... How can I do to ensure transparency in the imported image, visible in the generated particles?

    I also probably want to get a better look 3D particles, so I'm considering buying a 3D model of a pollen grain.

    Which 3D format is supported out of the box to be used with AE and Trapcode particular and is there something I should in particular
    aware of the purchase of these files?

    Didi you make sure to use the Move attributes option when the composition before? Other than this can be due to some quirks with the GIF itself. If you can open it in Photoshop, convert it to RGB mode, create transparency and then save it as a PSD, PNG or TIF. This may be easier than spending hours endles trying to make it work in AE...

    Mylenium

  • Brush Tip in CS4 and paint brush w advanced icons icons

    Why in Photoshop CS4 is no icons tip brush paint on the edges of the line wiped out icon. They all paint pixels (etc.) 4 to 5 behind the line of brush tip. CS2 and painted 3 deaths on the dotted line of brush if you want. -What I am missing how to do? in CS4? I'm not painting with the brush and the BRUSH. I expect the brush tip icon to show me exactly what area I'm going to paint. Am I wrong?

    This could be a case where someone has changed

    System Preferences > universal access > mouse > cursor size

    "to something else than ' normal '?

  • Transparent background gif leaving no transparency and little dots

    I am a newbie and has successfully done once and decided on a new logo and did the same thing and now it does not work.  I am running vista, created a logo in a Gif file and edited in paint.  Then I open it in PS, use the background Eraser registered for the web, made sure it was even the gif.  ploaded it to my Web site and bam, it shows a white rectangle with a bunch of dots.  I tried with the eyedropper tool, thereby ensuring that the background was transparent color and without success.  I got my site up and running and has decided to do, and now you don't even know that your facility site because I don't have a logo to the top.

    However, I left a page up to see what he does.  Any help would be greatly appreciated as I am at end of the last week and a half.

    Thanks in advance,

    Lisa

    Hello Lisa!

    Try this:

    Remember what background you use on your website.

    -Open your GIF image in Photoshop

    -File---> save for Web & devices (this opens the possibility to optimize the files for the web)

    -Top left of new screen click "2up" (shows you the original and a version optimized in a split screen)

    -Top right of new screen scroll to the types of files and Select GIF (others are PNG-8, JPEG, WBMP, PNG-24)

    -Just below the selection GIF, click the arrow of the "Matte" button, it opens a menu, choose your color of original background (if white, blue etc..)

    - Transparency of box (optional)

    -Click Save at the bottom. Select the destination. Fact!

    I hope that answers your question. You will have to do with your png images as I think.

    Note also that you can reduce the size of the image (and quality) in the upper right by reducing the colors.

    P.S. (usually transparent and sRGB are selected)

    Let me know if it worked!

  • FireFox has gone completely transparent and nothing works

    I was in the middle of surfing when suddenly, Firefox went completely transparent and there is nothing I could do. Only minimize, restore and close works.

    I tried to update flash, re-installing of Firefox and nothing works.

    http://ImageShack.us/a/img5/8683/75930925.jpg
    http://ImageShack.us/a/img18/1740/89238227.jpg

    Hello yAxOr, can you try to start firefox in safe mode by pressing the SHIFT key during startup of this and see if the problem occurs there too? Maybe a theme or hardware acceleration intrudes here...

    If safe mode does not work, you can try to disable hardware acceleration in firefox > options > advanced > general and or disable addons that could cause the problem. It would also be interesting what graphics hardware (description of the adapter, driver date and version of the driver) you use - you can access this information in firefox > help > correct information to the bottom of this page... Thank you

    Troubleshoot extensions, themes, and issues of hardware acceleration to resolve common problems of Firefox

  • Facing a problem with writing the custom for WLS identity assertion provider

    I am facing a problem with writing the custom for WLS identity assertion provider.

    Requirement:

    Asserter identity configured in WLS should get called when the following cookie is sent in a request by my application
    cookie name: OAMAuthnCookie_blr1234567.idc.oracle.com:7777

    I added the name of the cookie as a token of support and Active token in WeblogicCustomIdentityAsserter.xml

    < MBeanAttribute
    Name = "SupportedTypes.
    Type = "java.lang.String [].
    Writeable = "false".
    Default = "new String() {& quot; OAMAuthnCookie_blr1234567.idc.oracle.com:7777 & quot ;}.
    / >
    <!-ActiveTypes attribute contains the subset of your mbean SupportedTypes who are active in the area. ->
    < MBeanAttribute
    Name = "ActiveTypes".
    Type = "java.lang.String [].
    Default = "new String() {& quot; OAMAuthnCookie_blr1234567.idc.oracle.com:7777 & quot ;}.
    / >

    Problem:

    Identity asserter provider is not invoked for the request that has the cookie named OAMAuthnCookie_blr1234567.idc.oracle.com:7777.

    I did some experiments with the cookie name, to see where the problem could be

    Identity asserter provider is triggered for the following cookies:
    OAMAuthnCookie_blr1234567.idc.oracle.com7777.
    blr1234567. IDC. Oracle
    blr12_XXX. IDC. Oracle.com

    and it does not work for cookie name - OAMAuthnCookie_blr1234567.idc.oracle.com:7777

    I think that the name of the token supports not the colon. I don't have control over the name of the cookie, two points will always be

    Tried it with giving the name of the cookie after the encoding of the colon

    < MBeanAttribute

    Name = "SupportedTypes.

    Type = "java.lang.String [].

    Writeable = "false".

    Default = "new String() {& quot; OAMAuthnCookie_blr2211441.idc.oracle.com & #58;. 7777 & quot ;} »

    / >


    But still does not work
    Am I missing something? Any help will be appreciated.
    Help, please!

    colon ': ' is an illegal character in the name of the cookie.

    RFC 2616, Section 2.2 says:

    token = 1 *.

    separators = "(" | ")" | " <" |="" "="">" | " @"

    | "," | ";" | ":" | " \" |<">

    | "/" | "[" | "]" | "?" | "="

    | "{" | "}" | SP | HT

    It is clear ":" a "separator" and thus not allowed in a token or a cookie name.

  • Custom skin of RH9 WebHelp: problem opening PDF of custom button

    Hi, I have been troubleshooting and audit forums, trying to figure out how to get a PDF file to open it from a custom button on my skin to WebHelp. This worked for me once, but I changed something in the document and tried to download the new version and there out wrong since then.

    PDF Issue 2.png

    I want to be able to open the PDF file in a new window and the custom button (called 'Printable PDF' on my skin), so I use the JavaScript code customized in the field "click on" the components of the custom button: window.open ('print_test.pdf "printWindow," "," menu bar = 0, resizable = 0, width = 900, height = 500, scr ollbars = 1');  I know that the script is good because I have the same script for custom support button and it works fine. The only difference between these scripts is the support script calls a .html instead of a PDF file and the names of window says "supportWindow" instead of "printWindow.

    .PDF Issue.png

    I tried to delete and recreate the custom button, change the JavaScript with the help of the developer, generating assistance on another machine, thinking it was a little problem with my browser (using IE8) or license RoboHelp and comb through the help files for many times. I also made sure that the PDF file is stored in project and records of the skin as well as the other project files/files. I have used previous versions of RoboHelp and had no problem attaching a document Word and PDF, so I wonder if it is a bug in RH9? So much more than that worked for me at first. Any help or ideas are welcome! Thank you!

    Hello again

    Try disabling MOTW and generate again. Test it and jump through the hoops THAT MOTW you don't have to jump through. (Yellow information and stuff toolbar)

    My guess is that MOTW is inhibiting things. Once you publish this content on a server, you should be good.

    See you soon... Rick

    Useful and practical links

    Wish to RoboHelp form/Bug report form

    Begin to learn RoboHelp HTML 7, 8 or 9 in the day!

    Adobe Certified RoboHelp HTML Training

    SorcerStone blog

    RoboHelp EBooks

  • Printing problem transparent .png

    I'm still a bit new to Indesign, and I worked to create a printable product Catalogue Indesign CS5.

    For different logos, product images, etc I was by cutting the background in Photoshop to make them transparent and saved as .png, then I import in the Indesign file. The problem is that when I print (PDF or directly from Indesign), these .png images do not have transparent backgrounds. Instead, there is a shaded box the size of the image/object. This check box does not appear on the screen as a PDF or in Indesign, but only when I print.

    Any ideas how to solve this problem?

    Before I posted, I've actually tested.

    A. PNG created in current versions of Photoshop with an ICC profile (I tested with other than sRGB or AdobeRGB) and/or transparency fully and properly place in current versions of InDesign, maintaining the correct ICC profile or transparency.

    -Dov

  • I have a component as follows and it completely blocks the design view in flex builder

    I have a component as follows and it completely blocks the design view in flex builder. I see anything in the page layout. All that fine compliles and seems normal in schema view. Any ideas what is wrong. If I remove the all looks fine AdvancedDataGridColumnGroup

    <? XML version = "1.0" encoding = "utf-8"? >
    < mx:Panel x = "353" y = "34" width = "1159" height = "505.7" maxWidth = "663" allowDrag = "true" allowResize = 'true' allowClose = "true" allowMaximize = "true" = "true" = "Resize" = moveEffect resizeEffect allowMinimize close = "parent.removeChild (this) 'Move'" maxHeight = "680" layout = "absolute" title = xmlns:mx "Back office list" =" " http://www.Adobe.com/2006/MXML ">
    < mx:AdvancedDataGrid id = "Treaty" displayItemsExpanded = "true" dataProvider = "{tradesResult}" width = "100%" height = "373" sortExpertMode = "true" variableRowHeight = "true" headerStyleName = "smallHeader" editable = "false" fontWeight = 'normal' >

    < mx:columns >

    < mx:AdvancedDataGridColumn width = "75" >

    < / mx:AdvancedDataGridColumn >
    < mx:AdvancedDataGridColumnGroup headerText = "Side customer" >
    < mx:AdvancedDataGridColumn dataField = "Reference" headerText = "My Ref" width = "60" editable = "true" wordWrap = "true" showDataTips = "true" textAlign = "center" / >
    < mx:AdvancedDataGridColumn dataField = "side customer" headerText = "MC Pr" textAlign = "center" wordWrap = "true" width = "70" >
    < / mx:AdvancedDataGridColumn >
    < / mx:AdvancedDataGridColumnGroup >
    < mx:AdvancedDataGridColumnGroup headerText = "Bank side" >
    < mx:AdvancedDataGridColumn dataField = "bankDealRef" headerText = "Bank Ref" width = "70" editable = "true" wordWrap = "true" dataTipFunction = "dataTipFuncNotes" showDataTips = "true" textAlign = "center" / >


    < mx:AdvancedDataGridColumn dataField = "Premium2" headerText = "Bank Pr" width = "55" editable = "true" wordWrap = "true" showDataTips = "true" textAlign = "center" / >

    < / mx:AdvancedDataGridColumnGroup >


    < / mx:columns >

    < / mx:AdvancedDataGrid >


    < / mx:Panel >

    Nikos,

    When you use grouped columns, you should change the to , I ran this example in a sandbox app and it works fine.

    EXAMPLE:


    sortExpertMode = "true" variableRowHeight = "true" headerStyleName = "smallHeader" editable = "false" fontWeight = 'normal' >
          
               
               

               
                   
                   
                   

               

               
                   
    showDataTips = "true" textAlign = "center" / >
                   
               

           
       

    HTH,

    Kenny Yates

  • Flash CS3 V3 component problem

    I use the component 'button' and then I manually with the skin it Flash CS3 when I change the color of the 'up' movieclip and doing a "CFC" the new component I created works correctly, but when I do a second component "button" (CFC) and use it on the scene to with one another 'up' color of movieclip. He always uses the "old" color on both. It's like the 'library' is shared for both. Has anyone have the same problem?

    The answer is 'skins' just search under "Creating skins for some instances" in the Flash CS3 help file.

  • Define and raise custom events

    I am designing and building a library of reusable Cast that can be included in a variety of other Director projects. This library will provide an interface to joint Code readers barcode that appear as a keyboard on the computer and also provides interfaces for interacting with external software.

    My problem is finding how to set and trigger custom of this Cast library events. Currently I set him up in a Global Script within the library. However, all it seems I can do the script is call a predefined function that implemented the film container. He can't really have several event listeners.

    There are two events that I am trying to define and raise:
    1. the notification when a label barcode is scanned
    2. the notification when a server database search ends

    The typical application flow is that a film's Director parent will sit idle waiting for a TagScan event mode is triggered. After the TagScan event, a request is sent to a central server to retrieve the associated information in the barcode that has been analyzed. Because we don't want UI suspended pending data to return, there was an another event notification when data are available for use.

    So my question is really in two parts:
    1. is my approach to the use of a global script in an external library to Cast the best way to put in place a reusable module?
    2. is there a way to define and trigger custom since a global script events?

    Thanks in advance,
    Shawn.

    1. the best way to create reusable code is to use behaviors and parent scripts. Some 98% of your code should be one of these two types - not movie scripts.

    2. by "global script" I assume you mean a set of functions in a movie script. If so, then it is not a good approach.

    Here is the skeleton of how I would approach. A system of events at its basic level is nothing more reminders with an object that queries the status set up other objects. A reminder is when an object passes a reference on behalf of one of its names of Manager to another object. This allows the second object to make a call to the first object. When he made that call, belongs to the second object.

    What you need is an object that monitors stocks asynchronous data recovery and drive barcode from the server. Create a Parent script with the following code.

    -Barcode monitor

    property pEvents - list of events and the saved objects that is called when an event occurs.
    property pTimeOb - timeout object used for the periodic polling/verification of the status of various asynchronous actions.

    the new me
    pEvents = [#BarcodeScanned: [], #DataReady: []]
    pTimeOb = timeout () .new ("BarcodeMonitor", 200, #CheckAsyncStatus, me)-means "200" we check five times per second.
    return to me
    new end

    on addEventListener, CallbackObject, CallbackHandler, event - script instance, symbol, symbol
    -can add validation of argument here.

    CallBackInfo = [#CallbackObject:CallbackObject, #CallbackHandler:CallbackHandler]
    pEvents [Event] .add (CallBackInfo)
    end addEventListener

    on me, removeEventListener CallbackObject, CallbackHandler, event - script instance, symbol, symbol
    -code that walks the list and deletes all corresponding combinations object and handler for the specified event.
    end removeEventListener

    on CheckAsyncStatus me, Timeob
    -check the status of various asynchronous barcode things happening.

    -Callback sample
    -At this point, some data is ready and has been recovered
    Data = "everything data".
    EventCallBacks = pEvents.DataReady
    Repeat with CallBackInfo in EventCallBacks
    call (CallBackInfo.CallbackHandler, CallBackInfo.CallbackObject, data)
    end repeat
    end CheckAsyncStatus
    ----------------------------------------------------------------------

    The above code sets up a mechanism for registering callbacks with the subject "bar code monitor" and uses a timeout object to periodically check the State of the asynchronous actions.

    Now any object who wishes to be notified of an event fits simply by using the addEventListener method. Or let's say that we want our object of global struggle to listen to the returned data. The next Parent script would be created things.

    -control

    global gBarCodeMonitor

    the new me
    gBarCodeMonitor.addEventListener (I, #processData, #DataReady)
    return to me
    new end

    processData me, given
    -do something with the data
    end processData
    -------------------------------------------------------------------------

    You then create your objects in preparemovie.

    global gBarCodeMonitor
    global gControl

    on prepareMovie
    -installation Global Singletons

    If gBarCodeMonitor.voidP then
    gBarCodeMonitor = script ("Monitor Bar Code") .new)
    end if

    If gControl.voidP then
    gControl = script("Control").new)
    end if
    end prepareMovie
    ---------------------------------------------------------------------

    With this configuration, you can have several objects to register for an event and a unique object with several events.

    If you are not familiar with the scripts of Parent. So take the time to learn. The programming of your life will become much easier the day you're going to OOP.

    I have not test the code, so there may be a typo or something. But the basic idea is there.

Maybe you are looking for