How to make component semi-transparent?

Hi,
I want to make a component semi transparent so that i can see through component below that? is it possible in swing? if it is how can i do that?
Thanks,
Sato.

I've had limited success by specifying a background color using an alpha value.
setBackground( new Color(123, 123, 123, 128) );

Similar Messages

  • How to make a semi-transparent layer?

    Hello everyone,
    I am making my own website with Dreamwaver. I am a totally
    new user and have no IT background. So could anyone here kindly
    help me with my question:
    In the main page I would like to use two layers with images
    inserted. The second one will be a semi-transparent image which is
    made in Fireworks. I would like to let this layer cover the first
    one. Because it's semi-transparent, so i should still be able to
    see the underlying image... I did all this, but finally in the IE
    the second layer is NOT transparent at all.
    I don't know where the problem is. Please, if anyone knows
    the solutions or have any suggestion, let me know!
    Thanks!
    Inca

    I'll show it to you my way:
    1. Type the text and click the layer mask icon. The layer mask should be all white and have a small border. That indicates the mask ist active.
    The foreground color should be black and the background color white.
    2. Choose the gradient tool. Open the gradient window. Choose the first gradient, "foreground to background" = black to white.
    Change the white color to gray.
    3. Check the layer mask > is it active?
    Apply the gradient from right to left over your text.
    See the thin line in the screenshot.
    4. On your layer mask appears the gradient, left starting with gray and right ending with black.
    The advantage of this method is that you can change your text without  modifying the gradient.
    The black color on the layer mask hides the text, the gray color makes the text more or less visible and white color means full visible.
    Hope it helps.
    miss marple

  • How to make a completely transparent button in Flash Builder

    I am making a mobile application, and I am wondering how to make a completely transparent button. I've tried using
    <s:Button x="-5" y="0" width="410" height="1504"
                                    skinClass="spark.skins.mobile.TransparentNavigationButtonSkin" click="navigator.pushView(Sun)"/>
    But it still has one line on the side. I need a way to make it completely transparent.
    Thanks,
         8th grade student

    Try this alpha="0.001"
    Also add useHandCursor="true" and buttonMode="true" if you wish to have the hand cursor appear on hover.
    example  x="10" y="10" width="169" height="54" label="Button" alpha="0.001" useHandCursor="true" buttonMode="true" 
    HTH

  • How to make a JPanel transparent? Not able to do it with setOpaque(false)

    Hi all,
    I am writing a code to play a video and then draw some lines on the video. For that first I am playing the video on a visual component and I am trying to overlap a JPanel for drawing the lines. I am able to overlap the JPanel but I am not able to make it transparent. So I am able to draw lines but not able to see the video. So, I want to make the JPanel transparent so that I can see the video also... I am posting my code below
    import javax.media.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    import java.lang.Math;
    import javax.media.control.FramePositioningControl;
    import javax.media.protocol.*;
    import javax.swing.*;
    class MPEGPlayer2 extends JFrame implements ActionListener,ControllerListener,ItemListener
         Player player;
         Component vc, cc;
         boolean first = true, loop = false;
         String currentDirectory;
         int mediatime;
         BufferedWriter out;
         FileWriter fos;
         String filename = "";
         Object waitSync = new Object();
         boolean stateTransitionOK = true;
         JButton bn = new JButton("DrawLine");
         MPEGPlayer2 (String title)
              super (title);
              addWindowListener(new WindowAdapter ()
                   public void windowClosing (WindowEvent e)
                            dispose ();
                            public void windowClosed (WindowEvent e)
                         if (player != null)
                         player.close ();
                         System.exit (0);
              Menu m = new Menu ("File");
              MenuItem mi = new MenuItem ("Open...");
              mi.addActionListener (this);
              m.add (mi);
              m.addSeparator ();
              CheckboxMenuItem cbmi = new CheckboxMenuItem ("Loop", false);
              cbmi.addItemListener (this);
              m.add (cbmi);
              m.addSeparator ();
              mi = new MenuItem ("Exit");
              mi.addActionListener (this);
              m.add (mi);
              MenuBar mb = new MenuBar ();
              mb.add (m);
              setMenuBar (mb);
              setSize (500, 500);
              setVisible (true);
         public void actionPerformed (ActionEvent ae)
                        FileDialog fd = new FileDialog (this, "Open File",FileDialog.LOAD);
                        fd.setDirectory (currentDirectory);
                        fd.show ();
                        if (fd.getFile () == null)
                        return;
                        currentDirectory = fd.getDirectory ();
                        try
                             player = Manager.createPlayer (new MediaLocator("file:" +fd.getDirectory () +fd.getFile ()));
                             filename = fd.getFile();
                        catch (Exception exe)
                             System.out.println(exe);
                        if (player == null)
                             System.out.println ("Trouble creating a player.");
                             return;
                        setTitle (fd.getFile ());
                        player.addControllerListener (this);
                        player.prefetch ();
         }// end of action performed
         public void controllerUpdate (ControllerEvent e)
              if (e instanceof EndOfMediaEvent)
                   if (loop)
                        player.setMediaTime (new Time (0));
                        player.start ();
                   return;
              if (e instanceof PrefetchCompleteEvent)
                   player.start ();
                   return;
              if (e instanceof RealizeCompleteEvent)
                   vc = player.getVisualComponent ();
                   if (vc != null)
                        add (vc);
                   cc = player.getControlPanelComponent ();
                   if (cc != null)
                        add (cc, BorderLayout.SOUTH);
                   add(new MyPanel());
                   pack ();
         public void itemStateChanged(ItemEvent ee)
         public static void main (String [] args)
              MPEGPlayer2 mp = new MPEGPlayer2 ("Media Player 2.0");
              System.out.println("111111");
    class MyPanel extends JPanel
         int i=0,j;
         public int xc[]= new int[100];
         public int yc[]= new int[100];
         int a,b,c,d;
         public MyPanel()
              setOpaque(false);
              setBorder(BorderFactory.createLineBorder(Color.black));
              JButton bn = new JButton("DrawLine");
              this.add(bn);
              bn.addActionListener(actionListener);
              setBackground(Color.CYAN);
              addMouseListener(new MouseAdapter()
                             public void mouseClicked(MouseEvent e)
                   saveCoordinates(e.getX(),e.getY());
         ActionListener actionListener = new ActionListener()
              public void actionPerformed(ActionEvent aae)
                        repaint();
         public void saveCoordinates(int x, int y)
                    System.out.println("x-coordinate="+x);
                    System.out.println("y-coordinate="+y);
                    xc=x;
              yc[i]=y;
              System.out.println("i="+i);
              i=i+1;
         public Dimension getPreferredSize()
    return new Dimension(500,500);
         public void paintComponent(Graphics g)
    super.paintComponent(g);
              Graphics2D g2D = (Graphics2D)g;
              //g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f));
              g2D.setColor(Color.GREEN);
              for (j=0;j<i;j=j+2)
                   g2D.drawLine(xc[j],yc[j],xc[j+1],yc[j+1]);

    camickr wrote:
    "How to Use Layered Panes"
    http://java.sun.com/docs/books/tutorial/uiswing/components/layeredpane.html
    Add your video component to one layer and your non-opaque panel to another layer.Did you try that with JMF? It does not work for me. As I said, the movie seems to draw itself always on top!

  • How to apply a semi-transparent background to a text box

    Hi Framers,
    The cover of my doc has a full-page .png file on a master page. I want to add the title of the manual on the body page of the cover in a text box. No problem. However, I want to apply a semi-transparent effect to the background of the text box, so the graphic behind it shows in a muted way.
    I'm sure this has to do with some combination of the Tint, Fill, and Overprint settings but none of my experiments have produced anything close to the desired effect.
    I did RTFM and also searched the Help and the forum. I truly hope I didn't overlook the answer---but if I did, it wasn't for lack of trying!
    As always, your expertise is very much appreciated.
    TIA,
    Gay

    Wow, I wish I had Photoshop! I use a less sophisticated image editor, which has always served quite adequately and since it supports layers, I'll try to figure out how to do what you're suggesting.
    (I did try a "None" fill and the bottom image does show up, but I wanted it a bit muted, as would happen with perhaps a "half transparency" and that is apparently what I can't achieve in FM.)
    If I understand correctly, I need to edit the imported graphic to make a portion of it appear semi-transparent, and then when I bring it back into FM and put my text box on top of it, it will appear the same as if I had been able to put a partial transparency in the fill of the text box...
    I really, really, really hate it when I find myself thinking "Word could do this easily, why can't Frame?"
    Thanks for your helpful suggestions, guys, you're great. As always!
    Gay

  • Anyone know how to make an "Index Transparent" gif

    I have successfully made transparent PNGs and GIFusing an Alpha transparency but now I need to make images which would be the same as ueing fireworks / Photoshop to make a colour transparent. i.e. indexed transparency.
    Does anyone know how to do this.
    My code is as follows :
    // configure all of the parameters
    String text = "ABC abc XYZ xyz ["+ new Date()+"]";
    String font_file = "./tst/Maiandb.TTF";
    font_file = request.getRealPath(font_file);
    float size = 30.0f;
    Color background = Color.white;
    Color color = Color.black;
    Font font = Font.createFont(Font.TRUETYPE_FONT, new FileInputStream(font_file));
    font = font.deriveFont(size);
    buffer = new java.awt.image.BufferedImage(1,1,java.awt.image.BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = buffer.createGraphics();
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    java.awt.font.FontRenderContext fc = g2.getFontRenderContext();
    java.awt.geom.Rectangle2D bounds = font.getStringBounds(text,fc);
    // calculate the size of the text
    width = (int) bounds.getWidth();
    height = (int) bounds.getHeight();
    // prepare some output
    buffer = new java.awt.image.BufferedImage(width, height, java.awt.image.BufferedImage.TYPE_INT_ARGB);
    g2 = buffer.createGraphics();
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
    g2.setFont(font);
    // actually do the drawing
    Color transparent = new Color(0, 0, 0, 0);
    g2.setColor(transparent);
    g2.fillRect(0,0,width,height);
    g2.setColor(color);
    g2.setComposite(AlphaComposite.SrcOver);
    g2.drawString(text,0,(int)-bounds.getY());
    File file = new File ("./jsp1/tst/fred1.gif");
    com.gif4j.light.GifImage gifImage = new com.gif4j.light.GifImage();
    com.gif4j.light.GifFrame gifFrame = new com.gif4j.light.GifFrame(buffer);
    gifImage.addGifFrame(gifFrame);
    GifEncoder.encode(gifImage, file);Thanks in advance

    ^^EDIT^^
    System admins updated iMac to OS X Mountain Lion (10.8.4).

  • How to make a semi-ransparent layer?

    Hello everyone,
    I am making my own website with Dreamwaver. I am a totally
    new user and have no IT background. So could anyone here kindly
    help me with my question:
    In the main page I would like to use two layers with images
    inserted. The second one will be a semi-transparent image which is
    made in Fireworks. I would like to let this layer cover the first
    one. Because it's semi-transparent, so i should still be able to
    see the underlying image... I did all this, but finally in the IE
    the second layer is NOT transparent at all.
    I don't know where the problem is. Please, if anyone knows
    the solutions or have any suggestion, let me know!
    Thanks!
    Inca

    I'll show it to you my way:
    1. Type the text and click the layer mask icon. The layer mask should be all white and have a small border. That indicates the mask ist active.
    The foreground color should be black and the background color white.
    2. Choose the gradient tool. Open the gradient window. Choose the first gradient, "foreground to background" = black to white.
    Change the white color to gray.
    3. Check the layer mask > is it active?
    Apply the gradient from right to left over your text.
    See the thin line in the screenshot.
    4. On your layer mask appears the gradient, left starting with gray and right ending with black.
    The advantage of this method is that you can change your text without  modifying the gradient.
    The black color on the layer mask hides the text, the gray color makes the text more or less visible and white color means full visible.
    Hope it helps.
    miss marple

  • How to make opaque white transparent?

    I have a JPEB, black words, hand lettered, on white.
    When I place it into an InDesign doc, on a solid color, the white background, being opaque, covers the solid color.
    How do I make that opaque white into a transparent background? Two manuals do not give me a clue.
    Thanks.

    larry red miller wrote:
    So if I go back to the original .psd file, a transparency option will
    materialize in one of the menus?
    No.. Photoshop transparency is automatically seen in Indesign for .psd files. All you need to make the background transparent in Photoshop.
    larry red miller wrote:
    Well, uhh, that is what I wanted to k now. Where do I find those methods?
    If you Google for "remove background in Photoshop" you will literally find THOUSANDS of tutorials.

  • How to make a Frame transparent?

    Hi everyone:
    I want to make a Frame transparent,it is possible?I find all the API but no result : (
    More, I want to increate my Frame's Height ,but it can't work. code is:
    Frame f=new Frame("Test");
    for(int i=0;i<6;i++){
    f.setSize(40,i * 10);
    }If I change to code to
    f.setSize(40,10);
    f.setSize(40,20);
    f.setSize(40,30);
    ...................It can work well.But why ? It is so complicated . : (
    Please help me

    More
    How to add a hyperlink Text in Frame? When I click it which can open a web site?

  • [iPhone] How to make one color transparent on a UIImage?

    On my iPhone app I have a UIImage instance. I want to get a derived a UIImage that is the result of the first UIImage where one of its colors (e.g. magenta) is made transparent. How can I do this?
    NOTE: I cannot make the color transparent in Photoshop, the UIImage is created on the fly by the user. I need to do the "postprocessing" on the phone itself, after the user is done "drawing" the image.

    jubgb
    I still do not know your version of Premiere Elements and  your computer operating system, but here is a plan that would probably work for Premiere Elements 11, 12/12.1, and 13/13.1 on Windows 7, 8, or 8.1 64 bit.
    But you say that you are starting with a black and white image. If you could start with the color version of the image, I think we have a promising path to have the fake blood appear in color on a black and white image.
    This would be done by applying the Color Pass effect to the color photo version. Color Pass Effect is  found under fx Effects/Image Control/Color Pass.
    Then you would edit the Color Pass effect under Applied Effects Tab/Appied Effects Palette/Color Pass Panel expanded. But I find that the most effective editing of that effect is done using the Setup whose icon appear to the right of the Color Pass Panel.
    Have you used the Color Pass effect before?
    https://helpx.adobe.com/premiere-elements/using/effects-reference.html
    I will offer how to suggestion for its use if interested. As for starting with the black and white, then I need to think about that some more.
    ATR

  • How to make JPanel to transparent?

    Dear all, anyone here know how to make 2 JPanel to transparent and overlabbing? i try to use opaque(boolean), but i fail to do it, here is my code, i really need ur help.......thankx a lot
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Main extends JApplet
         public void init()
              DrawBase db=new DrawBase();
              DrawGraph dg=new DrawGraph();
              Container container=getContentPane();
              db.setOpaque(true);
              dg.setOpaque(true);
              container.add(db,BorderLayout.CENTER);
              container.add(dg,BorderLayout.CENTER);
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class DrawBase extends JPanel
         public DrawBase()
         public void paintComponent(Graphics g)
              super.paintComponent(g);
              g.setColor(new Color(0,255,0));
              g.drawOval(50,50,50,50);
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class DrawGraph extends JPanel
         public DrawGraph()
         public void paintComponent(Graphics g)
              super.paintComponent(g);
              g.setColor(new Color(255,0,0));
              g.drawOval(20,10,10,10);

    Hi,
    Dear all, anyone here know how to make 2 JPanel to
    transparent and overlabbing? i try to use
    opaque(boolean), but i fail to do it, here is my code,
    i really need ur help.......thankx a lot
    Well, the transparent part is easy. You should be calling setOpaque(false) rather than setOpaque(true). This will eliminate background painting of the JPanels.
    The overlapping can be accomplished in multiple ways, but NOT using BorderLayout. You'll either want to do as one person suggested and use no layout manager and position things absolutely, or as another suggested and use JLayeredPane.
    Personally, I would suggest a third approach that uses a single JPanel to do all of the painting. Something like this would work nicely:
    public class DrawPanel extends JPanel {
        public DrawPanel() {
            setOpaque(false);
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            drawBase();
            drawGraph();
        public void drawBase() {
            g.setColor(new Color(0,255,0));
            g.drawOval(50,50,50,50);
        public void drawGraph() {
            g.setColor(new Color(255,0,0));
            g.drawOval(20,10,10,10);
    }Regards,
    Shannon Hickey (Swing Team)

  • Code to make area semi transparent?

    Is there a way to modify the following background color code to make my background color semi-transparent so that an image in the background shows through?
    Thanks.
    #logo {
    background-image: url(img/logo.png);
    background-repeat: repeat-x;
    background-color: #FFFFFF;
    margin: 0 auto;
    width: 1100px;

    Have you got Fireworks?
    If so open a new file and make the documents background color transparent.
    Draw a small square and color it in with a solid colour which is in the same shade range as the color you want the final background of the #logo <div>.
    Select the solid color and use the transparent box in the properties inspector to adjust the colour to suit. It may be best if you bring in your image and position it behind the colored square so you can see what the color looks like when you adjust the transparency of the color.
    Once you have adjusted it to the color required delete the image and then export a small 1px x 1px piece of the colored square. Use PNG8 with alpha transparency or PNG24.
    Use the colored square as the background image to the logo <div> instead of the logo image itself and insert the logo image directly into the logo <div>

  • How to make form field transparent?

    I would like to change the blue color of the fields to transparent. How can I do it?

    Do you mean the highlight color? You can disable it via the Preferences window (under Forms).

  • How to make a JWindow transparent

    hi
    as my question describes i wants to make a transparent window. please help me. example code should be appreciated .
    thanx in advance.

    That's an imitation of the transparent window.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    public class Test {
        JScrollPane scroll;
        JPanel p=new JPanel(new BorderLayout());
        Robot robot=new Robot();
        public Test()  throws Exception {
            final TransparentFrame frame=new TransparentFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.getContentPane().add(p);
            JButton b=new JButton("Test");
            b.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
    /*                TransparentFrame frame1=new TransparentFrame();
                    frame1.setBounds(100,100,100,100);
                    frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame1.setVisible(true);*/
            frame.getContentPane().add(new JLabel("Test"));
            frame.getContentPane().add(b);
            frame.setBounds(100,100,200,200);
            frame.show();
        public static void main(String[] args) throws Exception {
            new Test();
    class TransparentFrame extends JFrame {
        Robot robot;
        BufferedImage screenImg;
        Rectangle screenRect;
        MyPanel contentPanel=new MyPanel();
        boolean userActivate=false;
        public TransparentFrame() {
            super();
            createScreenImage();
            this.setContentPane(contentPanel);
            this.addComponentListener(new ComponentAdapter() {
                public void componentHidden(ComponentEvent e) {}
                public void componentMoved(ComponentEvent e) {
                    resetUnderImg();
                    repaint();
                public void componentResized(ComponentEvent e) {
                    resetUnderImg();
                    repaint();
                public void componentShown(ComponentEvent e) {}
            this.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                public void windowClosed(WindowEvent e) {
                public void windowOpened(WindowEvent e) {
                public void windowIconified(WindowEvent e) {
                public void windowDeiconified(WindowEvent e) {
                public void windowActivated(WindowEvent e) {
                    if (userActivate) {
                        userActivate=false;
    //                    boolean f=TransparentFrame.this.isShowing();
    //                    if (f)
                            TransparentFrame.this.setVisible(false);
                        createScreenImage();
                        resetUnderImg();
    //                    if (f)
                            TransparentFrame.this.setVisible(true);
                    else {
                        userActivate=true;
                public void windowDeactivated(WindowEvent e) {
        protected void createScreenImage() {
            try {
                if (robot==null)
                    robot=new Robot();
            catch (AWTException ex) {
                ex.printStackTrace();
            Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
            screenRect=new Rectangle(0,0,screenSize.width,screenSize.height);
            screenImg=robot.createScreenCapture(screenRect);
    /*    public void show() {
            resetUnderImg();
            super.show();
        public void resetUnderImg() {
            if (robot!=null && screenImg!=null) {
                Rectangle frameRect=getBounds();
                int x=frameRect.x+4;
                contentPanel.paintX=0;
                contentPanel.paintY=0;
                if (x<0) {
                    contentPanel.paintX=-x;
                    x=0;
                int y=frameRect.y+23;
                if (y<0) {
                    contentPanel.paintY=-y;
                    y=0;
                int w=frameRect.width-10;
                if (x+w>screenImg.getWidth())
                    w=screenImg.getWidth()-x;
                int h=frameRect.height-23-5;
                if (y+h>screenImg.getHeight())
                    h=screenImg.getHeight()-y;
                contentPanel.underFrameImg=screenImg.getSubimage(x,y,w,h);
    class MyPanel extends JPanel {
        BufferedImage underFrameImg;
        int paintX=0;
        int paintY=0;
        public MyPanel() {
            super();
            setOpaque(true);
        public void paint(Graphics g) {
            super.paint(g);
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.drawImage(underFrameImg,paintX,paintY,null);
    }

  • How to make Layers NOT transparent ??

    Hey i am making an animation
    Its of a guy walking but he is transparent. I have already got like 100+ frames of him walking but he is transparent and therefore i cannot put a background or it shows through.
    Is there anyway i can make all existing frames nontransparent.

    The easiest way is to create a new layer and fill it with what ever color you choose then when your ready for a new layer just duplicate that layer with ctrl-j or cmd-j (former is windows and later is mac)

Maybe you are looking for

  • Error when opening pdf document from a website.

    Hi, I have adobe reader 9 and recently when I try to open a PDF document from a website it keeps giving me this message saying adobe PDF broker process for internet explorer has stopped working. Can someone plz tell me how to fix it? Thanks a lot.

  • Update Serial Numbers to Production Order

    Hi, Has anyone used any Function module for updating the Serial Numbers to the Production Order Header. I am using the FM - SERNR_ADD_TO_PP . The Serial Numbers needs to be assigned when doing Goods Issue in MIGO. At this point The FM is updating the

  • How to batch convert RGB images to CMYK

    Hello, Can anyone explain in a step-by-step way how to batch-convert many RGB images to CMYK? Thanks in advance

  • Error installing package on Linux using SDM.

    Hello Everyone... I am having an issue getting a package installed on RHEL using the SDM. The package I'm trying to install is BP SAP CRM 5.0 SP01. The error I'm getting is as follows (shortened for space and info reasons): DeploymentActionException:

  • Handling disconnections in stateful beans

    i have a stateful bean with some resources that it has to close after closing. I programed a close () method, marked as +@Remove+, that clients call to close the resources; and a exiting () method, marked as @PreDestroy to finish the work. but, how c