JDialog + Image + Label

Dear all,
i try to insert an animated gif into a JDialog that already contains a label. But,when the applications is running, the Dialog shows only the gif and the background color of the JDialog is grey and not the color that i chosen. Why?
Here is a code:
public class WaitDialog extends JDialog {
JPanel panel1 = new JPanel();
JLabel textLabel = new JLabel();
XYLayout xYLayout1 = new XYLayout();
Frame frame;
Vector waitDialog_language;
JPanel panelImage = new JPanel();
Toolkit toolkit = Toolkit.getDefaultToolkit();
Image imageContainer;
XYLayout xYLayout2 = new XYLayout();
public WaitDialog(Frame frame, String title, boolean modal, Vector waitDialog_language) {
super(frame, title, modal);
this.frame = frame;
this.waitDialog_language = waitDialog_language;
try {
jbInit();
//pack();
catch(Exception ex) {
ex.printStackTrace();
void jbInit() throws Exception {
panel1.setLayout(xYLayout1);
panel1.setBackground(new Color(255, 118, 79));
textLabel.setBackground(new Color(255, 118, 79));
textLabel.setFont(new java.awt.Font("Dialog", 1, 30));
textLabel.setHorizontalTextPosition(SwingConstants.LEFT);
textLabel.setText("Please wait....");
this.getContentPane().setBackground(new Color(255, 118, 79));
this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
this.setModal(true);
this.setResizable(false);
xYLayout1.setWidth(400);
xYLayout1.setHeight(150);
panelImage.setLayout(xYLayout2);
panelImage.setBackground(new Color(255, 118, 79));
panelImage.setMinimumSize(new Dimension(160, 120));
panelImage.setPreferredSize(new Dimension(160, 120));
getContentPane().add(panel1);
panel1.add(panelImage, new XYConstraints(5, 28, 123, 95));
panel1.add(textLabel, new XYConstraints(143, 56, 282, -1));
this.setSize(new Dimension(443, 150));
int x = (frame.getSize().width - this.getSize().width) / 2;
int y = (frame.getSize().height - this.getSize().height) / 2;
this.setLocation(x + frame.getLocationOnScreen().x, y + frame.getLocationOnScreen().y);
//gif animated
imageContainer = toolkit.getImage("images/wheel.gif");
validate();
pack();
public void paint(Graphics g) {
Graphics g2 = panelImage.getGraphics();
g2.drawImage(imageContainer, 0, 0, this);
public void update(Graphics g) {
paint(g);
Thanks in advance.
Angelo

label.setOpaque( true );
Check out the Swing tutorial on "Painting" for more information on why setOpaque(...) method is important:
http://java.sun.com/docs/books/tutorial/uiswing/overview/draw.html

Similar Messages

  • How can I change the color of interactive image label box background.

    Interactive image labels are a bit overwhelming in appearance. Can I change the label background color or make it partially transparent? I have tried several things and looked this up on Lynda.com training but no info.

    don't know how much this might help but you can change some colors using the Inspector as follows:
    from the text menu you can control paragraph and character colors, from the text menu you can control the text color.
    hope this helps...

  • Photomatix plug-in's HDR merged image has suddenly stopped showing up as part of the stack, yet when I repeat the merge it warns that these images are already merged. I have the merged image labeled with a HDR suffix.

    Photomatix plug-in's HDR merged image has suddenly stopped showing up as part of the stack, yet when I repeat the merge it warns that these images are already merged. I have the merged image labeled with a HDR suffix. Worked fine until now. Thanks

    I am not sure what's happening with IE9 (no live site) but I had real problems viewing your code in Live View - until I removed the HTML comment marked below. Basically your site was viewable in Design View but as soon a I hit Live view, it disappeared - much like IE9. See if removing the comment solves your issue.
    <style type="text/css">
    <!-- /*Remove this */
    body {
        margin: 0;
        padding: 0;
        color: #000;
        background:url(Images/websitebackgroundhomee.jpg) repeat scroll 0 0;
        font-family: David;
        font-size: 15px;
        height:100%;

  • Every time I try to download Java for Lion (no matter what the source) all I get is a document image labelled "unconfirmed download" and a warning that this type of file may harm my computer. What am I doin wrong?

    Every time I try to download Java for Lion (no matter what the source) all I get is a document image labelled "unconfirmed download" and a warning that this type of file may harm my computer. What am I doin wrong?

    Donna...
    Even from Apple?  >  Java for OS X Lion Update 1
    Restart your Mac before trying to download the file.
    Do you have anti virus software installed or a program like LIttle Snitch?
    If you are using Safari to download files, go to the Safari menu bar click Safari > Empty Cache
    If that doesn't help, back to the menu bar, click Safari > Reset Safari. Select the top 5 boxes then click Reset.
    If you still can't download the Java file, go to ~ / Library / Caches / com.apple.Safari
    Move the Cache.db file from the com.apple.Safari folder to the Trash and restart your Mac. Try downloading that file again.
    If it still won't download without that dialog, go to ~/Library/Safari. Move the Downloads.plist file from the Safari folder to the Trash.
    Try again.
    ~ (Tilde) character represents the Home folder.
    For Lion:   To find the Home folder in OS X Lion, open the Finder, hold the Option key, and choose Go > Library

  • Changing color of Interactive Image label?

    i'm pretty clear on how to alter the title, caption, border of an Interactive Image, but i'm wondering if there is a way to change the color, orientation and appearance (other than font) for the associated labels? any help would be great. thanks!

    fabe: i totally get that -- and you're right -- a good designer would understand that the labels shouldn't upstage the graphic to which they refer. to that end, i think that effect would be enhanced if you looked at the default screen and simply saw (unboxed) labels, and then when you clicked opn the text, you'd zoom in and the text might even get a little transparent so the graphic is even more accentuated. i also think it would be cool if you could control the default view of the label (change it's colors, characteristics, transparency, etc) and then when setting its zoomed-in view, you'd also be able to change the label's colors, characteristics, transparency, etc, as well. honestly, i'm sort of relieved to know this isn't possible in ibooks author 1.0 (maybe in 2.0?) because i looked and looked AND looked. btw, the app is INCREBIBLY intuitive -- pretty **** remarkable, in fact. you have done an amazing job, so thanks so much! bob (ps: so glad i waited for a great wysiwyg ibook tool -- and that apple released it. i plan in converting a number of my out-of-print books -- and will be using ibooks author!) http://www.bobstaake.com/page5.shtml)

  • IBook author interactive image label: graphic control is locked?

    The interactive image lets you adjust the frame and background, but not the labels nor end the point styles! The ability is there but it is locked! Here's a screen shot showing the 'greyed out' control options. Is there a trick to enable the capability? Or is it on the debug list for the next update? 

    Hello Vita,
    When I was last working with this widget and came across the same issue.
    The only way to try and control it was by adding in character returns to change the height and to stretch the box out by the handles at the left and right of the box itself. But yes it would be great to have more control over the the parameters.
    Regards,
    Nigel

  • Customizing UITableViewCell (image, label, button).

    I have an image and 4 UILabels in my tableViewCell. I need the image to be selectable and two labels to be selectable. I searched in documentation and I found nothing about writing selector for UILabel. So, I am trying to use UIButtons ( UIButtonTypeCustom) instead of the two UILabels. But, when I touch the cell the entire cell is selectable. How can I differentiate the labels, image and buttons in my UITableViewCell.
    I need the image to be selectable. I wanted to add a video in place of the image.
    How can I make all this possible.
    Thank You.

    http://www.iphonesdkarticles.com/2008/08/table-view-tutorial-tableview-cell.html
    http://iphoneincubator.com/blog/windows-views/display-rich-text-using-a-uiwebvie w
    Google is your friend...

  • Using JLabel[] to create an array of image labels

    Hello, I am quite new to Java so I am not sure if the following is even the best way to do what i am trying to do ... but please advise:
    I am making a JLayeredPane mapArea with grid lines where the user will be able to change the scale of the map and the grid lines can move along. The way I approached it is to create JLabel arrays that contains every single gird line i am going to use, add them to the map panel at the bottom-most layer and position them according to the scale. Below is the code that I wrote:
    int i = 0;     //local index variable for the for loops below
    JLabel[] vlineArray = new JLabel[50];
    JLabel[] hlineArray = new JLabel[50];
    ImageIcon[] vlineImageArray = new ImageIcon[50];
    ImageIcon[] hlineImageArray = new ImageIcon[50];
    for( i=0; i<50; i++ ){
         vlineImageArray[ i ] = new ImageIcon(GUI.class.getResource("vline.gif")); 
         hlineImageArray[ i ] = new ImageIcon(GUI.class.getResource("hline.gif")); 
    // vertical line array
         for( i=0; i<50; i++){
         vlineArray [ i ] = new JLabel(vlineImageArray[ i ]);
    mapArea.add(vlineArray[ i ],1);
    // horizontal line array
    for( i=0; i<50; i++){
         hlineArray [ i ]= new JLabel(hlineImageArray[ i ]);
         mapArea.add(hlineArray [ i ],1);
    }}I tried to position these Jlabels in the array using setBounds:
    i.e. vlineArray.setBounds(......)
    But nothing showed... But if I simple create a vline by itself and add it to the map pane and setBounds. The vline shows up fine:
    // this works
    JLabel vlineImage = new JLabel(vline);
    mapArea.add(vlineImage);
    vlineImage.setBounds(.....);I also tried to post at the java programming forum
    http://forum.java.sun.com/thread.jspa?threadID=646495&tstart=15
    But nothing worked.
    Please help! Thanks a bunch!

    if I were going to draw grid lines over a map area, I would put a component the size of the layered pane in the layered pane which is transparent and can be given a scale and can override the paint method to paint the lines directly instead of trying to handle lots of labels like you're doing.

  • Library image labels - add file size

    Library View expanded cell options - file size seems important enough a parameter to have as an option. Can I be the only one who uses that info?

    No, it should be shown in many more areas, including in the Folders panel.
    John

  • Printing image/label on DVD?

    I am in the midst of creating a handful of DVD's through iMovie/iDVD (09') from the last 3 years of filming (kids/vacations etc.). I would like to know the most straightforward way to print on the DVD itself so I have an end product that is a little nicer than using my permanent black marker and poor penmanship. In my searches I have come across the names LaCie, Lightscribe etc. but I don't quite know how it all comes together. (i.e. do I need to buy a specific printer, download specific software etc.) I'm guessing the answer is yes to both. I only plan on doing a couple of dozen DVD's so I don't want to spend lots of $ on a printer if I don't have to. I called my local Staples and they don't offer such a service. Thanks a bunch.....

    Q: I'm guessing the answer is yes to both.
    A: You guessed right. Perhaps these links might help you:
    http://discussions.apple.com/thread.jspa?messageID=10909114&#10909114
    http://smilesoftware.com/DiscLabel/
    http://www.iwascoding.com/uncoverit/index.html
    http://www.lightscribe.com/gettingstarted/index.aspx?id=87
    http://www.lacie.com/technologies/technology.htm?id=10024
    The alternative to printing your own and avoiding expensive printer, ink, and media purchases is to find a local facility willing to do this for you. But I have found from experience that after the first one or two out of house orders (depending on volume) that it's better / more cost effective to invert in my own printer and media.
    Hope this info helps. But if not just come on back for more advice.
    Message was edited by: SDMacuser

  • A A 9 Pro  PDF Editing Text/Image Labels

    Post edited, removed as of 12-29-11

    No.  But the red arrow and line tools still work.   I just tried the text highlights on a random document and it worked.. but many of my documents, it doesn't work.  All of the documents are research studies downloaded from a college library.
    Denise

  • Display image with Logout label

    Hi,
    I am trying to create logout image&label as show on this page below at the right top corner,
    http://apex.oracle.com/pls/otn/f?p=31517:227:9400289793713::NO:::
    whenever i insert image in the Logout/Navigation Bar Entries the image .gif with style=width/height=16/16 doesnt show
    any idea on this...regards

    You're going to need to supply more information.
    Perhaps compare your generated HTML with what is found on Denes' page
    <a href="apex_authentication.logout?p_app_id=31517&p_session_id=16383870403475" style="text-align:center;display:block;">
    <img src="wwv_flow_file_mgr.get_file?p_security_group_id=2381609905666412890&p_fname=sign_out.gif" width="16" height="16">
    <br>Logout</a>Do you get any browser errors?
    Scott

  • Anyway to import just labeled images from Bridge to LR?

    Is there a way to import into Lightroom, just your labeled images from Bridge?
    I navigated to a folder and LR does not even seem to show the labels at all, nor less a way to import only labled images. thanks.

    LR does not even seem to show the labels at all, nor less a way to import only labled images
    Labeling is not universal as star rating seems to be. I have several apps that read each other star rating none of them reads label. Also when having change the default name for labels often the older files with color label have still the at time assigned name but loos the color and change to white.
    Is there a way to import into Lightroom, just your labeled images from Bridge?
    Create a folder that you can easy access when importing from LR. In Bridge select the label(s) you want in the filter panel and move or copy the labeled files to that folder. Now in LR you can import them.

  • Creating an image from a panel

    Hi everybody,
    I have a panel which extends JPanel, and wrote an image() method to extract the drawn image off the panel. For some reason, though, when I call this method, I get a dialog with a black box centered in it, and not the appropriate image.
    My SSCCE is as follows:
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.image.BufferedImage;
    import javax.swing.ImageIcon;
    import javax.swing.JDialog;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.SwingUtilities;
    public class MyPanel extends JPanel {
        private BufferedImage image;
        public BufferedImage image() {
            int x = getWidth();
            int y = getHeight();
            //image = new BufferedImage(x, y, BufferedImage.TYPE_INT_RGB);
            image = new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB);
            Graphics2D g2 = image.createGraphics();
            SwingUtilities.paintComponent( g2, this, new JPanel(), 0, 0, x, y );
            g2.dispose();
            return image;
        public static void main( String args[] ) {
             MyPanel canvas = new MyPanel() {
                  public void paintComponent( Graphics g ) {
                       Graphics2D g2 = (Graphics2D)g;
                       for( int i = 1; i <= 20; i++ ) {
                            int pos = i*50;
                            g2.drawString( "This is a test", pos, pos );
             JDialog test = new JDialog();
            JLabel label = new JLabel( new ImageIcon( canvas.image() ) );
            JScrollPane scroller = new JScrollPane( label );
            scroller.setPreferredSize( new Dimension( 500, 500 ) );
            test.add( scroller );
            test.pack();
            test.setVisible( true );
    }I'm pretty sure it has something to do with the sizing of the image and the timing of the repainting--when I uncomment the commented line in image(), I get an error saying width and height can't be less than or equal to 0. But anyway, I need to paint and then show an image of what was painted, not the actual painted panel--that's what I'm having trouble with. If anyone could help me out, I'd appreciate it. Can anyone help me fix this, please?
    Thanks,
    Jezzica85
    Edited by: jezzica85 on Jun 1, 2009 6:16 AM

    Odd choice to both have the panel with a getImage() method, and also override paintComponent(Graphics).
    Here is an alternate form of your code.
    import java.awt.*;
    import java.awt.image.BufferedImage;
    import javax.swing.*;
    public class MyPanel extends JPanel {
      private BufferedImage image;
      public BufferedImage image() {
        int x = 200;
        int y = 200;
        image = new BufferedImage(x,y, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        g2.setColor(Color.yellow);
        g2.fillRect(0,0,x,y);
        g2.setColor(Color.black);
        for( int i = 1; i <= 20; i++ ) {
          int pos = i*50;
          g2.drawString( "This is a test", pos, pos );
        g2.dispose();
        return image;
      public static void main( String args[] ) {
        Runnable r = new Runnable() {
          public void run() {
            MyPanel canvas = new MyPanel();
            JDialog test = new JDialog();
            JLabel label = new JLabel( new ImageIcon( canvas.image() ) );
            JOptionPane.showMessageDialog(null, label);
            JScrollPane scroller = new JScrollPane( label );
            scroller.setPreferredSize( new Dimension( 500, 500 ) );
            JOptionPane.showMessageDialog(null, scroller);
        EventQueue.invokeLater(r);
    }

  • Crimson JAXP and JPEG Images

    Ok, I have a very weird situation...
    I am writing code that uses a commercial API that includes JAXP from Apache in the CRIMSON.JAR. I believe that this is version 1.1(?) and I am using JRE 1.3.1. I am recieving updates from a network server that includes binary information (byte array) for an image. If the image is in JPEG format, the image takes approx. 5-10 seconds to render in a JLABEL for display. However, if the image is in GIF format, the renders immediately.
    Now, the JAXP processing is independant for this function and if I remove the JAR file from the class path, the rendering of JPEG data is also immediate.
    I have tried using both JRE 1.3.1 and JRE 1.4.2_03 with the same results. I have even used the JAXP Processor that comes with 1.4.x with the same result.
    Does anyone know what is causing this?

    I seem to be going around in circles here, but through further tests, it looks like the problem is creating a new JLabel containing the Image I just created. Apparently, if the file is a JPEG, or a large Image (200x200 or greater), Swing takes a long-time to render the JDialog and its components to be displayed.
    I am building the GUI like so...
    JDialog dialog = new JDialog();
    JLabel label = new JLabel(new ImageIcon("path to file"));
    dialog.getContentPane().add(label);
    dialog.show();If the image is small, and a GIF, the JDialog is displayed almost instantly. If it is a JPEG, or a larger image (200x200 or so), Swing takes 5-10 seconds to display the Dialog. Is there a better way to do what I am doing?
    BTW: The image file is created from data transmitted across the network to the client. However, this happens after the file is created on the local disk.

Maybe you are looking for

  • Confirmed quantity in sales order level

    Hai Guru,s My client scenario is like this. He takes the order from customer. After saving the order he  decides the confirmed quantity (more or less quantity)manually in order level  without changing the order quantity.  I am trying in confirmed qua

  • File Adapter with Linux

    Hi I want to send file from linux server to XI File Adapter I cannot cr8 nfs between them ( our XI is running on AIX) there's an option of Using samba client ( which works likes FTP ) does XI Supports that option? other thing i have been thiking on i

  • My Toshiba Laptop says media failed

    Hello, I have a satellite laptop. I tried to reset it, I think I did. It was going to slow and I decided to delete everything off. I then returned to turn it on and it turns on to the "Toshiba Leading Innovation" then says all these words over and ov

  • Approval of order

    Hi all, Our client's requirement is that before release of maintenance order, it should be approved by two different authorities (i.e. one administrative approval and another is financial approval). Once the order has been approved by the two approve

  • Problem with jdbc query

    hi i have a problem in executing a query in jdbc. i.e it executes all the query but the effect of last query is not reflected in database(Ms Access). if i use one query it will work properly.this problem occurs when i use more than one query. could t