Disappearing Images on JButtons using JDK 1.4.0

Here is the Java Swing Button example from java.sun.com:
import java.awt.*;
import java.awt.event.*;
import javax.swing.AbstractButton;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.ImageIcon;
public class ButtonDemo extends JPanel
implements ActionListener {
protected JButton b1, b2, b3;
public ButtonDemo() {
ImageIcon leftButtonIcon = new ImageIcon("images/right.gif");
ImageIcon middleButtonIcon = new ImageIcon("images/middle.gif");
ImageIcon rightButtonIcon = new ImageIcon("images/left.gif");
b1 = new JButton("Disable middle button", leftButtonIcon);
b1.setVerticalTextPosition(AbstractButton.CENTER);
b1.setHorizontalTextPosition(AbstractButton.LEFT);
b1.setMnemonic(KeyEvent.VK_D);
b1.setActionCommand("disable");
b2 = new JButton("Middle button", middleButtonIcon);
b2.setVerticalTextPosition(AbstractButton.BOTTOM);
b2.setHorizontalTextPosition(AbstractButton.CENTER);
b2.setMnemonic(KeyEvent.VK_M);
b3 = new JButton("Enable middle button", rightButtonIcon);
//Use the default text position of CENTER, RIGHT.
b3.setMnemonic(KeyEvent.VK_E);
b3.setActionCommand("enable");
b3.setEnabled(false);
//Listen for actions on buttons 1 and 3.
b1.addActionListener(this);
b3.addActionListener(this);
b1.setToolTipText("Click this button to disable the middle button.");
b2.setToolTipText("This middle button does nothing when you click it.");
b3.setToolTipText("Click this button to enable the middle button.");
//Add Components to this container, using the default FlowLayout.
add(b1);
add(b2);
add(b3);
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("disable")) {
b2.setEnabled(false);
b1.setEnabled(false);
b3.setEnabled(true);
} else {
b2.setEnabled(true);
b1.setEnabled(true);
b3.setEnabled(false);
public static void main(String[] args) {
JFrame frame = new JFrame("ButtonDemo");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
frame.getContentPane().add(new ButtonDemo(), BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
Do the following:
1. Compile and run this example using JDK 1.4.0.
2. While the frame is up hit the Control + Alt + Delete key sequence.
3. Now hit the Escape Key.
4. You will notice that atleast one of the buttons on the Java Swing Example will not have the image painted.
Now if you force a repaint then the image(s) gets painted correctly.
Any ideas?

i've got exactely the same problem in a gui application running on windows nt 4, service pack 6. the problem of the disappearing icons occurs also after returning from the screen lock.
if you got a solution in the mean time please let me know, thanks a lot
matthiaszimmermann at yahoo.com

Similar Messages

  • Need to save the image saved in the System Clipboard in using JDK 1.3.1

    Does anyone know how to use JDK 1.3.1 to take an image saved in the System clipboard and save it to a file using the JPG format?
    I know how it is done in JDK 1.4 using the following code. Unfortunately, the same code does not recognize the image in the clipboard in JDK 1.3.1
    I am using jai-1_1_2_01.
    package clipboard;
    import java.awt.datatransfer.Clipboard;
    import java.awt.datatransfer.DataFlavor;
    import java.awt.datatransfer.Transferable;
    import java.awt.image.RenderedImage;
    import java.awt.Toolkit;
    import java.awt.datatransfer.UnsupportedFlavorException;
    import java.io.IOException;
    import java.io.FileOutputStream;
    import java.io.BufferedOutputStream;
    import java.io.File;
    import javax.media.jai.JAI;
    import javax.media.jai.RenderedOp;
    public class clipboard
    {  private File tempFile = null;
    * @param args
    static int BUFFER_SIZE = 65536;
    public static void main(String[] args)
    {  clipboard clip = new clipboard();
    clip.writeImageFromClipboard();
    public void writeImageFromClipboard()
    {  Clipboard            clip = Toolkit.getDefaultToolkit().getSystemClipboard();
    Transferable transferable = clip.getContents(null);
    RenderedImage img = null;
    FileOutputStream fileOutStr = null;
    BufferedOutputStream bufOutStr = null;
    DataFlavor [] dataFlavors;
    File tempFile;
    int
    byteCount;
    String [] strArr;
    dataFlavors = transferable.getTransferDataFlavors();
    System.out.println("clip=" + clip.getName());
    System.out.println("Transferable=" + transferable);
    for (int i = 0; i < dataFlavors.length; i++)
    {  System.out.println("dataFlavours[" + i + "]=" + dataFlavors.toString());
    if (transferable.isDataFlavorSupported(new DataFlavor("image/x-java-image; class=java.awt.Image", "Image")))
    { try
    { img = (RenderedImage) transferable.getTransferData(new DataFlavor("image/x-java-image; class=java.awt.Image", "Image"));
    if (this.tempFile == null)
    { this.tempFile = File.createTempFile("__TMP_IMG__", ".jpg");
    System.out.println(this.tempFile.getCanonicalPath());
    fileOutStr = new FileOutputStream(this.tempFile);
    bufOutStr = new BufferedOutputStream(fileOutStr);
    // Encode the file as a JPG image.
    JAI.create("encode", img, bufOutStr, "JPEG", null);
    catch (UnsupportedFlavorException e)
    { e.printStackTrace();
    catch (IOException e)
    { e.printStackTrace();
    finally
    { if (bufOutStr != null)
    { try
    { bufOutStr.flush();
    bufOutStr.close();
    catch (IOException e)
    if (fileOutStr != null)
    { try
    { fileOutStr.flush();
    fileOutStr.close();
    catch (IOException e)
    else
    { System.out.println("Not an image!");

    The login  you connected to the server  and run the above statement does not have permissions to operate  on this path "C:\Users\ISLLCdba\Desktop\MAA
    PROFILE PICTURES\"
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Using JDK 1.5 in frame font is appearing different as it is coming in 1.4

    When I am going to compile my application using jdk 1.4 and 1.5 both,in 1.5 fonts in my application component like frame,dialog fonts are appearing in different manner means in 1.5 it is appearing in bolder manner.
    We are developing framework application and we have to give release for jdk 1.5 version but it is giving font difference.
    Please resolve this issue because it is very urgent and critical.
    this is not our framework problem i have developed one below simple application and compiled it in jdk 1.4 and 1.5 it is showing font difference.
    Fonts like times new roman and arial etc are coming in bolder manner means more width but height and style is same.
    i have snapshot also but i am not able to paste becasue editor is not accepting images.
    I am giving you small program that will reproduce defect apart from my application.
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.FontMetrics;
    import java.awt.Frame;
    import java.awt.Graphics;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JTextArea;
    import javax.swing.SwingConstants;
    public class WizardDemo14
    public static void main(String[] args)
    JFrame dlg = new JFrame("COMPILED IN 1.5");
    JLabel jLabel1 = new JLabel();
    jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 50));
    jLabel1.setForeground(Color.blue);
    jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
    jLabel1.setHorizontalTextPosition(SwingConstants.CENTER);
    jLabel1.setText("Finish...");
    dlg.getContentPane().setLayout(new BorderLayout());
    dlg.getContentPane().add(jLabel1);
    dlg.setSize(400 ,400);
    dlg.setVisible(true);
    dlg.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Please help me
    Edited by: umesh3077 on Apr 2, 2008 6:44 AM

    Below taken directly from the v1.6x API java.awt.Font class doco:he Java Platform distinguishes between two kinds of fonts: physical fonts and
    logical fonts.
    Physical fonts are the actual font libraries containing glyph data and tables to
    map from character sequences to glyph sequences, using a font technology
    such as TrueType or PostScript Type 1. All implementations of the Java
    Platform must support TrueType fonts; support for other font technologies is
    implementation dependent. Physical fonts may use names such as Helvetica,
    Palatino, HonMincho, or any number of other font names. Typically, each
    physical font supports only a limited set of writing systems, for example, only
    Latin characters or only Japanese and Basic Latin. The set of available
    physical fonts varies between configurations. Applications that require specific
    fonts can bundle them and instantiate them using the createFont method.
    Logical fonts are the five font families defined by the Java platform which must
    be supported by any Java runtime environment: Serif, SansSerif, Monospaced,
    Dialog, and DialogInput. These logical fonts are not actual font libraries.
    Instead, the logical font names are mapped to physical fonts by the Java
    runtime environment. The mapping is implementation and usually locale
    dependent, so the look and the metrics provided by them vary. Typically, each
    logical font name maps to several physical fonts in order to cover a large range
    of characters.
    Peered AWT components, such as Label and TextField, can only use logical
    fonts.
    For a discussion of the relative advantages and disadvantages of using
    physical or logical fonts, see the Internationalization FAQ document.

  • Flash MX2004 - Disappearing Images

    I am having a problem with images disappearing from the
    library (and therefore from the stage/movie). Hopefully someone can
    help me.
    Here's what is happening: I imported several (~20) jpgs to
    the library (bitmap properties: allow smoothing, jpeg compression,
    use imported jpeg data) - then convert to symbol (graphic). I use
    the symbol (graphic) in the movie, not the bitmap. Everything seems
    to work ok and I save and close my file (.fla). Then, when I open
    the file again, images randomly disappear from the library (both
    the bitmap and the symbol). The places in the movie where I had
    instances of the image, are now blank with the circle in the middle
    of where the image was and the crosshair in the upper left of where
    the image was supposed.
    My naming convention - All bitmaps begin with bmp_. All
    graphics begin with gfx_. There are no spaces in the image name...
    I use the underscore _ when I need to separate words in the image
    name.
    I've used motion tweening on all of the graphics - the ones
    that disappeared and also on the ones that are still there.
    I've checked the properties of the disappeared images - and
    the alpha is not changed to 0... I did not lock the W/H/X/Y.
    The images that disappeared are not all on the same scene.
    I don't know what is causing this... and I'm about to pull my
    hair out trying to figure it out!! Any ideas?
    Thanks for helping.

    bai1ey;
    Never seen such a thing, butcheck to be certain that the
    images are
    "flash import compatable" (non-progressive, rgb--simple flat
    jpegs).
    Alternatively you might try importing pngs and do the jpeg
    compression in
    flash. -Tom Unger

  • How do I use jdk 1.4 with weblogic 6.1?

    Want to use jdk 1.4 features(logging and regular expression) in a weblogic
              application I am developing. How do I get weblogic 6.1 to run with jdk1.4
              

              This is off topic but see the url below on edocs.
              You will need to make sure that your classpath points to the 1.4 jdk. Changing
              your $JAVA_HOME in the startup script is pretty much it.
              When developing your application, make sure your classpath is set properly .For
              example in the setExamplesSever.sh script you point to the 1.4 jdk.
              FYI This is not yet a supported platform.
              -frank
              http://e-docs.bea.com/wls/docs61/faq/java.html#251151
              "alt.cybercafes" <[email protected]> wrote:
              >Want to use jdk 1.4 features(logging and regular expression) in a weblogic
              >application I am developing. How do I get weblogic 6.1 to run with jdk1.4
              >
              >
              >
              

  • I am getting a error IO when trying to upload multiple images within wordpress using the flash uploader. I do not get the error when uploading using explorer. The error only appears if I try uploading using firefox....any ideas?

    I am getting a error IO when trying to upload multiple images within wordpress using the flash uploader. I do not get the error when uploading using explorer. The error only appears if I try uploading using firefox....any ideas?

    Logged the call with SAP who directed me to 'Define settings for attachments' in IMG and setting the 'Deactivate Java Applet' & 'Deactivate Attachment versioning' checkboxes - problem solved.

  • How to obtain date of creation if image is obtained using getImage()

    When Image is obtained using getImage() method , how to
    obtain date of creation or another header value if image is
    obtained using getImage method.

    Actually, some formats do indeed have creation or modification dates built in. e.g. http://www.w3.org/TR/PNG-Chunks.html#C.tIME. (Of course since most programs save a new copy of the file every time, the two dates are the same.) However, just because formats have this data doesn't mean it's reliable or even present. Your best bet is to pass creation dates in an Applet param tag for applets (assuming you were referring to Applet.getImage()) or to parse out a filename from a classloader URL and use a File object to check (assuming you were instead referring to Toolkit.getImage(URL)). That's the best answer I have without knowing more about what you are trying to accomplish.

  • My dock disappears when I am using Word. How can I get it back on the screen?

    My dock disappears when I am using Word.  How can I get it back on the screen?  Thanks very much.
    Bill

    You may have blundered into "Full Screen" mode, an abomination ported from iOS, the iPhone Operating System, land of tiny screens and one-at-a-time Applications.
    Try clicking the double-arrows in the extreme upper right of the MenuBar or Window.

  • Error in importing image into SAP using SE78

    Hi to all,
    I was trying to upload a '.bmp" image into SAP using SE78 but I failed.
    Se78 -> BMAP Bitmap Image -> Graphic -> Import -> Specified the complete path ->given name desc and type .
    Ended up with the following message.
    Graphic TRF_LOGO_REV could not be saved
    (2TRF_LOGO_REV)
    Pls. help as I am not sure whether I missed any step.
    Thankx in advance.

    Hi,
    Go to SE78 Transaction ie Aministration of form graphics,
           there select GRAPHICS General Graphics,under this BMAP Bitmap Images will come.
           select that,then a sub window will appear.
    There give the name of your logo and select the import button which is at the extreme left.
           Then again a sub window appears,there give the path name and name of the logo,and some description then press enter.
    Now the logo is uploaded,for preview you can select last button which is print preview.
    Now goto the form,select the window where you want to print the logo.
           Then in that window place the cursor at tag coloumn and select command line.
           Now go to INSERT and select GRAPHICS.A subwindow appers click on 'stored on Document Server',
           give the name of the logo and press enter.
           Then the image information will be displayed on the form.Save the form and activate it.
    Go to se38 transaction write the print program and execute.
    Regards,
    jaya

  • How to add an image over another using af:image

    How to add an image over another using af:image
    Thanks,
    Veera

    i have a image which is black strip. i have added that to af:image
    <af:image source="image1" id="image" />
    on the black strip, i need to add company logo.
    how to achieve it.
    Thanks,
    Veera.

  • Display the images in excel using jsp

    Hi
    I am unable to display the images in excel using jsp. I can display the data. but cannot display the images. It is simply showing the icon without the image. Is there any way to display the images. Pls give some sample code to display the images in excel.
    Thanks in advance.

    Presumably whoever created the images in that Excel document just put links to somewhere on their hard drive. Those links don't mean anything when you put the document on somebody else's computer, which is what you are doing. At least, that is my guess.
    You could spend some time looking at the Excel file to see how the images were put in there. Or you could ask the person who put the images in there.

  • Can I attach a link to one image and then use that linked image multiple times in my site?

    Hi,
    Is it possible to attach a link to an image and then use that image (with link attached) multiple times in my site.
    Thanks,
    Ally

    Use 'Find and Replace'>under the 'Edit' menu.
    Select from 'Find in'- Folder and browse to the folder your website files are kept in to select it.
    Search: Source Code
    In the Find box (but obviously use YOUR image code):
    <img src="images/imageName.jpg" width="200" height="200" alt="" />
    In the Replace box: (use YOUR link and image code)
    <a href="yourLink.html"><img src="images/imageName.jpg" width="200" height="200" alt="" /></a>
    Then select 'Replace All'

  • How to send images through PI using SOAP adapter

    hi,
    Can anybody tell me how to send images through PI using SOAP adapter.
    Regards ,
    Loveena

    Hi Loveena,
    only as attachments of a SOAP message.
    Regards,
    Udo

  • Background image  for JPanel using UI Properties

    Is there any way to add background image for JPanel using UI Properties,
    code is
    if (property.equals("img")) {
    System.out.println("call image file in css"+comp);
    //set the background color for Jpanel
    comp.setBackground(Color.decode("#db7093"));
    here the comp is JPanel and we are setting the background color,
    Is there any way to put the Background image for the JPanel ????

    KrishnaveniB wrote:
    Is there any way to put the Background image for the JPanel ????Override the paintComponent(...) method of JPanel.
    e.g.
    import javax.swing.*;
    import java.awt.*;
    import java.io.*;
    import javax.imageio.ImageIO;
    public class ImagePanel {
        public void createAndShowUI() {
            try {
                JFrame frame = new JFrame("Background Image Demo");
                final Image image = ImageIO.read(new File("/home/oje/Desktop/icons/yannix.gif"));
                JPanel panel = new JPanel() {
                    protected void paintComponent(Graphics g) {
                        g.drawImage(image, 0, 0, null);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setSize(new Dimension(400, 400));
                frame.setContentPane(panel);
                frame.setLocationRelativeTo(null);
                frame.setVisible(true);
            } catch (IOException ex) {
                ex.printStackTrace();
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    new ImagePanel().createAndShowUI();
    }

  • Image won't use full width of page in Standard Report

    Using LabVIEW 2012 in both Windows XP and Win7
    Specifically, I'm trying to use a cluster control  with strings and numerics for a generic report page.  I stuff the strings and numerics with the info that's needed to create the desired page content.
    I am creating a standard report.  The use of Word or Excel is not considered due to compatibility issues when either NI or Microsoft release version upgrades.
    I have tried setting the report margins as well as leaving them at default; the results are the same.
    I set the header text and footer text to indicate where the report generation function believes the margins to be.  Both header and footer honor the margin settings and appear on the report page as they are expected.
    When I "append control image to report" using the reference to the cluster control, the resulting image is 6.2" wide and hugs the left margin regardless of what size the control actually is.  If the control is widened, it is rescaled to 6.2" wide.  I tried using picture and array controls; results are the same.  I tried using the "append front panel image to report"; same results.  The "Alignment" input seems to have no effect.  The issue seems to be with the way images are handled in the report generation.
    Oddly enough, the height seems to behave quite normally.  If the object is too large in height, it is simply truncated at the bottom margin.
    I tried using landscape orientation which functionally exhibits the same issue; object hangs on left margin and will not fill the width of the page.
    I tried HTML which centers the image on the page but doesn't honor margins and prints info at top and bottom that I can't get rid of.
    I contacted NI support and generated an active support question reference# 7369484.  So far, no solution.
    Any help would be appreciated!

    Similar problem using LV2011. I have to print labels on a 100x70 mm paper without borders. No chance to scale the control image to fit.
    Calculating the size of the initial picture (480x360 pixels) scaled at 96 DPI would result in a size of 127x95 mm.
    Actually the height printed is exactly this, but the width shrinked to about 45-50 mm.
    A part of the solution might be to create an image (use 'create/invoke node/get image') and send this to the printer (how to do this?). Actually the HTML report creates an 96 DPI image together with the html page.
    In my case I should create an image of at least 150 DPI (300 or 600 DPI prefered). But there are no options in either the 'get image' or append control image to standard report to set the resolution.
    Bad thing!
    Attachments:
    CT0181860494.jpg ‏26 KB

Maybe you are looking for

  • Down payment request based on purchase order

    Dear all, How to make down payment request(F-47) based on purchase order(not line item wise) ?, Currently in F-47 it is asking to enter amounts purchase order line item wise,because downpayment is made only for entire purchase order value not line it

  • Originating document number not updated for one invoice line item

    Hi, We have a invoice document number in which the originating document number is not updated for one of the line items ,this is order related down payment invoice .May be this is due to system inconsistency so is there any SAP note to overcome this

  • All Web Browsers Broken

    i posted this under the safari cat but haven't had any luck, but since it's not just safari i decided to try my luck here. recently i've been having problems with ALL of my webbrowsers, i've tried to use safari, firefox and opera and they're all doin

  • Getting first and last records of sql using a analytical function query

    hi all! Thanks in advance for looking at my problem! I have a query that runs against a table that keep all records of changes on another table (journal table kind of thing). I wrote a sql that would tell what the status of that requisition was, what

  • SRM-ECC PO Business Content

    We are implementing SRM -EXtended Classic Scenario. The PO is created in SRM and a copy is sent back to ECC. Therefore PO is avialable in both the SRM & ECC systems to be pulled into BI. In BI we have serperate content available for Procurement Analy