File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JComboBox on Background Image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JComboBox on Background Image" Watch "JComboBox on Background Image" New topic

JComboBox on Background Image

Kaveh Ghahremani

Joined: Aug 16, 2001
Posts: 1
Can someone please give me a piece of sample code that places a JComboBox on top of a background picture.
I've been trying with a number of different layout managers and panels and JDektopPanes etc. but I had no luck.
Thank you in advance
Meghna ks
Ranch Hand

Joined: Mar 15, 2001
Posts: 122
Hi Try this piece of code. I dould'nt get it if you wanted the combobox to have a background image or if the combobox needed to be placed on a container that has a Background image. The code is for the latter one.
import java.awt.*;
import javax.swing.*;
import symantec.itools.multimedia.ImageViewer;
import symantec.itools.awt.ImagePanel;
* A basic extension of the javax.swing.JApplet class
public class JApplet1 extends JApplet
public void init()
// Take out this line if you don't use or symantec.itools.awt.util.StatusScroller

// This line prevents the "Swing: checked access to system event queue" message seen in some browsers.
getRootPane().putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);

// This code is automatically generated by Visual Cafe when you add
// components to the visual environment. It instantiates and initializes
// the components. To modify the code, only use code syntax that matches
// what Visual Cafe can generate, or Visual Cafe may be unable to back
// parse your Java file into its visual environment.
try {
catch ( error) { }
catch(java.beans.PropertyVetoException e) { }
try {
catch(java.beans.PropertyVetoException e) { }
image.setLayout(new BorderLayout(0,0));
image.add(box, BorderLayout.NORTH);
javax.swing.JComboBox box = new javax.swing.JComboBox();
symantec.itools.awt.ImagePanel image = new symantec.itools.awt.ImagePanel();
Amit Rosner

Joined: Dec 03, 2001
Posts: 22
Here a small sample that does that:
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.JApplet;
import javax.swing.JComboBox;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
public class TestApplet extends JApplet
public void init()
String[] test = {"test"};
JComboBox button = new JComboBox(test);

ImagePanel ip = new ImagePanel(new ImageIcon("test.jpg").getImage());
class ImagePanel extends JPanel
private Image image;

public ImagePanel(Image image)
this.image = image;

public void paintComponent(Graphics g)
if (image != null)
g.drawImage(image, 0, 0, getSize().width, getSize().height, this);
subject: JComboBox on Background Image
It's not a secret anymore!