Is there a way to create a semi-transparency with Java?

I would like to be able to create a semi transparent form and I was does anyone know how to do this?

import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;
import java.io.*;
import java.net.*;
import javax.imageio.*;
import javax.swing.*;
import javax.swing.event.*;
public class CompositeTest extends JPanel {
    private BufferedImage backImage, frontImage;
    private float alpha = 1;
    public CompositeTest() throws IOException {
        backImage = ImageIO.read(new URL("http://today.java.net/jag/bio/JagHeadshot-small.jpg"));
        frontImage = ImageIO.read(new URL("http://today.java.net/jag/Image54-small.jpeg"));
    public Dimension getPreferredSize() {
        return new Dimension(backImage.getWidth(), backImage.getHeight());
    public void setAlpha(float alpha) {
        this.alpha = alpha;
        repaint();
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) g;
        int x = (getWidth() - backImage.getWidth())/2;
        int y = (getHeight()- backImage.getHeight())/2;
        g2.drawRenderedImage(backImage, AffineTransform.getTranslateInstance(x, y));
        Composite old = g2.getComposite();
        g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
        x = (getWidth() - frontImage.getWidth())/2;
        y = (getHeight()- frontImage.getHeight())/2;
        g2.drawRenderedImage(frontImage, AffineTransform.getTranslateInstance(x, y));
        g2.setComposite(old);
    public static void main(String[] args) throws IOException {
        final CompositeTest app = new CompositeTest();
        JSlider slider = new JSlider();
        slider.addChangeListener(new ChangeListener(){
            public void stateChanged(ChangeEvent e) {
                JSlider source = (JSlider) e.getSource();
                app.setAlpha(source.getValue()/100f);
        slider.setValue(100);
        JFrame f = new JFrame("CompositeTest");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container cp = f.getContentPane();
        cp.add(app);
        cp.add(slider, BorderLayout.SOUTH);
        f.pack();
        f.setLocationRelativeTo(null);
        f.setVisible(true);
}

Similar Messages

  • Is there a way to create/edit registry keys with Java?

    I'm writing a console app and I'd like to have it so the users can change values in the registry. I'm not just talking about app keys I want any key. Is there a way to do this with Java?

    Maybe a forum search on "Windows registry" would turn up some useful things. You're not the first to ask this. You might save yourself and everyone else some time if you'd simply do that.

  • Is there a way to create a flipping book with the flipping 5k adobe software?

    Am I the only one pissed with the f adobe products?
    Is there a way to create a flipping book with the flipping 5k adobe software? Is it Flash, etc?
    Thanks

    Maybe a forum search on "Windows registry" would turn up some useful things. You're not the first to ask this. You might save yourself and everyone else some time if you'd simply do that.

  • Is there a way to create a custom screensaver with pics/slides that display for different amounts of time?

    Is there a way to create a custom screensaver with pics/slides that display for different amounts of time? Or even add a "video slide" into the screensaver?
    My business has 3 TVs displayed in our lobby, each with its own apple TV and they are all linked to the same photo stream. Currently the Atv screensaver displays the photostream pictures of our products for the default 3 seconds. We just added pics/slides that now display messages and useful info for our customers but I want that info to be displayed for a longer period of time than the pictures to give people a chance to read it.
    I tried using flickr and powerpoint as a work around but no luck.  I created a slide in powerpoint with play length of 15 secs and saved it as a wmv file.  I added that file to a "screensaver" set in flickr and pointed the Atv screensaver to that flickr set.  It still displays everything, pics and the wmv file at the default 3 sec.
    I know I can increase the duration of all pics in the screensaver to display for longer but the goal is to have the pics display at 3 secs and the info slides to display at 15 secs.

    Welcome to the Apple Community.
    No that's not possible.
    If you have any suggestions that you think might enhance the Apple TV you can send Apple your feedback here 

  • Is there a way to create SQL Dev reports with validated binds?

    Is there a way to create SQL Dev reports with validated binds similar to the way user defined extensions can have <prompts> with a <value> that is a SQL statement returning a list of possible values?
    This sure would make select appropriate values for binds in reports easier and less error prone.

    Maybe a forum search on "Windows registry" would turn up some useful things. You're not the first to ask this. You might save yourself and everyone else some time if you'd simply do that.

  • Hello, is there a way for making a photo transparent with iPhoto are another software?

    Hello, is there a way for making a photo transparent with iPhoto are another software?

    Not with iPhoto, but different apps have different capabilities.
    There are a couple of considerations: How is this transparent image to be used? In a Deskop Publishing environment something like Pages' Instant Alpha might be useful. Or if you're trying to overlay one image on another on a photograph then some editor that supports layers would be required.
    Further, Jpegs as a format doesn't support transparency so you'll need to work ina  file format that does.
    But if you can explain what you're hoping to do we might be able to point you in a more useful direction.
    In order of price here are some suggestions for editors:
    Seashore (free)
    The Gimp (free)
    Graphic Coverter ($45 approx)
    Acorn ($50 approx)
    Pixelmator ($50 approx)
    Photoshop Elements ($75 approx)
    There are many, many other options. Search on MacUpdate or the App Store.
    You can set Photoshop (or any image editor) as an external editor in iPhoto. (Preferences -> General -> Edit Photo: Choose from the Drop Down Menu.) This way, when you double click a pic to edit in iPhoto it will open automatically in Photoshop or your Image Editor, and when you save it it's sent back to iPhoto automatically. This is the only way that edits made in another application will be displayed in iPhoto.

  • Is there any way to create a file compatible with Premiere Pro

    Is there any way to create a file in Premiere elements that is compatible with Premiere Pro and that can be used in Premiere Pro

    Consternation
    The important information that I do not see mentioned nor offered by you.
    1.What version of Premiere Elements are you using and on what computer operating system it is running? What version of Premiere Pro do you want to use?
    The Premiere Pro Import Supported Formats seem to indicate that it will accept the Premiere Elements project.prel (project file) on Windows Only.
    Adobe Premiere Pro Help | Supported file formats
    This may or may not be possible depending on damaged projects or outdated elements.
    2. If you want to export your Premiere Elements Timeline to a file saved to the computer hard drive and subsequently import that into your Premiere Pro version, that "should" work. You would go to the Premiere Elements Publish+Share/Computer/ and make a selection based on what the Premiere Pro Import Supported file formats are and what you need. I can help you with that. But, details first.
    But, just a "beware"...when you get to Premiere Elements 11 or 12 (if that is the version involved) Publish+Share/Computer/ there are several categories, but all you see is Adobe Flash Video, MPEG, and AVCHD. The rest of the list that includes AVI and QuickTime which both need to be scrolled to all of the time to see them, not just sometimes, with the thin scroll bar to the right of the list of choices. You can export files
    with AVI file extension, under Publish+Share/Computer/AVI
    with MOV file extension, under Publish + Share/Computer/QuickTime
    And, if you do not have QuickTime installed on your computer with Premiere Elements, you are not going to have presets for the QuickTime export.
    Remember, there is more to an export than just its file extension. Know your other export properties as well.
    In many cases, you can customize the export settings to suit your requirements.
    Problems will exist if you are trying to go from Premiere Elements Windows to Premiere Pro Mac or vice versa.
    I would be glad for the opportunity to help you with this issue, but details are needed.
    Looking forward to your follow up.
    Thanks.
    ATR

  • Is there a way to create 'Book Color's with CS Extension Builder?

    Dear all
    Is there a way to add a spot color with color mode "Book Color" as those from the swatch libary, the PANTONE color book for example.
    I see those Book Colors have fixed Lab Values and cannot be changed. So they would be fixed for the user.
    Is there a way to do this?
    thanks
    regards

    Zwired1 wrote:
    One thought is to do a pre- or post-build action VI that exports all of the revs (like you see in VI props>>revision) for the discrete VI's in the project .  You can set it to increment the rev every time the VI is saved. If the revs are the same you know nothing has changed but if they're different you won't know if the thing that's changed is significant. 
    Another thought is maybe TortoiseSVN or similar could keep track of what's-changed-and-why for you but I've never use it.  
    While that would serve the purpose of showing that the source hasn't changed (although I'm not so sure that relying onrev numbers is the best way to go about it - CRC check per file is probably better), it still doesn't gurantee that the build works.
    I just think that the whole process probably burns up several thousand dollars worth of unnecessary testing, V&V and paperwork.
    Bill
    (Mid-Level minion.)
    My support system ensures that I don't look totally incompetent.
    Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

  • Is there a way to create shared iTunes playlists with iCloud?

    For instance, if I were to create a playlist called "Playlist X" on my Macbook Pro, is there a way for iCloud to put that same playlist in my iMac's iTunes library? And if I were to add a song to the playlist on the iMac, could it appear in the playlist on the Macbook? This would be much more convenient than having to update two different playlists manually.

    This doesn't make sense. ...juat sayin'
    Location services are a part of your iOS device (or Mac). You don't "turn on" location services with iCloud. You can visit http://www.icloud.com and use Find My iPhone to see the location of the device if you want (assuming you have enabled this from the iPhone first).

  • Is there a way to create a slideshow viewable with a DVD player?

    Hi there, is there amongst the Apple programs (or else) something that would allow me to show my digital photos on TV with a DVD player? Manually commanded with the remote, or with auto time lapse, fading or transitions?

    I tested both Photo Magico and iDVD. Both produce a nice slideshow with good image quality when previewed on the computer. PhotoMagico has some really professional grade blending and zooming effects, and allows placement of multiple sound tracks, which is not possible with iDVD where you just drop one file and it plays in buckle.
    The problem with both is that when the slide show is encoded, it looses too much quality! Images loose their detail, their colour depth, and they flicker inacceptably. The worst is with PhotoMagico who sends the already compressed file to iDVD to be compressed again and burnt. The loss of quality from the very neat preview to the resulting DVD is enormous. Sent to Toast Titanium, it's a little better but aliasing effects are still very annoying.
    I then tried a slideshow made directly in iDVD. The quality is merely acceptable, still not professional. The images are so compressed that they loose their details, and the edges of the frames and every straight line in the images flicker...
    Compressing an original 5 Gb slideshow made of JPEG files to 1,5 Gb seems an enormous rate of compression. Is this the way it is with those programs, or have I missed some settings somewhere? Is there no way to preserve the initial image size when passed to DVD? Alternatively, would the pro version DVD Studio Pro have more flexibillity? It's there on my computer, but the interface is turning me away! ...
    Thanks again for any hints!
    Paul

  • Is there a way to create a collection based on the "previous import"?

    is there a way to create a collection based on the "previous import"? that would make it easy to mobile sync the last import to my ipad, and do further picking/rejecting while away from my laptop.

    well, yes, of course i could do it that way. i guess i wasn't specific enough. is there a way to create a smart collection, with the photos in the "previous import" as members of the smart collection.  earlier i mentioned about using this smart collection to mobile sync with my ipad, to do further flagging.
    so my intention, use a smart collection to mobile sync with my ipad, and the smart collection to include the photos from my previous import.
    i guess another way to ask the question, is there a way to create a smart collection, by using some rule or condition in the smart collection, to automatically include previous import photos.
    the documentation says that "previous import" is a collection, even though it shows up in the catalogue side bar section. but i see no way to choose that collection when making a smart collection.
    jd

  • Is there a way to make a flip book with the InDesin version contained in Creative Cloud?

    Is there a way to create a flip book with the InDesign version contained in Creative Cloud?

    InDesign is the same in Creative Cloud as it is as a standalone producate and it's the same as the one contained in any bundles that include it. The exception being that you have access to both the Mac and PC versions purchasing via the subscription model (Creative Cloud).
    I have not created a flip book in InDesign, but if InDesign is capable of doing it, then InDesign as purchased apart of the Creative Cloud, is capable of it.
    Download the demo of InDesign CS6 to see. If you purchase a Creative Cloud account later on, you don't need to reinstall, just authorize by logging into your Adobe account.

  • Is there a way to create a year at a glance with detail and print?

    Is there a way to create a year at a glance with detail and print?

    To do what Dave indicated you need to do, it depends on what version of Acrobat you have:
    Acrobat 8: Advanced > Enable Usage Rights in Adobe Reader
    Acrobat 9: Advanced > Extend Features in Adobe Reader
    Acrobat 10: File > Save As > Reader Extended PDF > Enable Additional Features
    Acrobat 11: File > Save as Other > Reader Extended PDF > Enable More Tools (includes form fill-in & save)
    I wonder what it will be next time?

  • Is there a way to create a PDF form that ANYONE can fill out and SAVE with their content?

    Is there a way to create a PDF form that ANYONE can fill out and SAVE with their content? By anyone, I mean someone who can download and use the free Adobe Reader, on either a Mac or PC. I have Acrobat Pro, and would like to be able to create forms that can not only be filled out and printed, but saved and emailed, which is not an option with the forms I have created to date. They can be filled out, but not saved, with Adobe Reader.
    TIA,
    Nancy

    To do what Dave indicated you need to do, it depends on what version of Acrobat you have:
    Acrobat 8: Advanced > Enable Usage Rights in Adobe Reader
    Acrobat 9: Advanced > Extend Features in Adobe Reader
    Acrobat 10: File > Save As > Reader Extended PDF > Enable Additional Features
    Acrobat 11: File > Save as Other > Reader Extended PDF > Enable More Tools (includes form fill-in & save)
    I wonder what it will be next time?

  • Is there a way to create a local package repository

    Is there a way to create a local package repository without technically being a mirror.  For example, setting up multiple AL box's on my network and having them grab all the latest packages from one AL box?
    Thanks,
    Craig

    What you most likely want is an ABS tree of your own, containing only the PKGBUILDs of those packages which you want to be included in your repository.
    You should already have heard of the gensync program. In short, the parameters are the root of PKGBUILDs, sorted in subdirectories (ie. like the ABS tree), the intented name and location of the repository database file, and the directory containing the binary packages.
    Let's assume you downloaded the current ABS tree to your hard drive, as well as all matching (same version as in the PKGBUILDs!) packages from a mirror, but you don't want the reiserfsprogs package in your repository. To achieve that, you must remove the /var/abs/base/reiserfsprogs directory, and may optionally remove the binary package, too. Since gensync analyzes the ABS tree you supplied as a parameter, removing the subdirectory of a specific package will cause this very package to not be included in the generated database. Assuming your packages lie in /home/arch/i686/current, your gensync call would look like this:
    gensync /var/abs /home/arch/i686/current/current.db.tar.gz /home/arch/i686/current
    If there are any discrepancies like
      - PKGBUILD, but no matching binary package found
      - PKGBUILD and binary package versions do not match
      - permission problems (writing the db file must be possible)
    gensync will gladly complain.
    Otherwise you should find the db file in the place you specified. Keep in mind that the name of the db.tar.gz file must be equal to the repository tag in the pacman.conf to use the repo.
    To make sure the db contains the right packages; use
    tar -tzf current.db.tar.gz | less
    to list the contents. Every package has it's own subdirectory including the metadata, which is rather obvious considering the file's generated from such a structure in the first place.
    The binary packages along with a correctly generated db file are all you need. Make the repository directory containing these files available through FTP if local availability doesn't cut it for you, edit your pacman.conf if needed, and use it!
    Adding packages works similar; All you need to have is the PKGBUILD in an ABS-like tree (it doesn't have to be the official tree; gensync doesn't care where the files come from. Just stick to one subdirectory per PKGBUILD, and you'll be fine), and the matching packages somewhere else, run gensync with the appropriate directories, and cackle with glee.
    HTH.

Maybe you are looking for