Image.getWidth(null) and image..getHeight(null)  returns -1

Hi ,
Plz tell me whats wrong with code
import java.awt.Image;
import java.awt.Toolkit;
public class ImgSize {
    public static void main(String args[]) {
        Image image = Toolkit.getDefaultToolkit().getImage("Picture.jpg");
        double width = image.getWidth(null);
        double height = image.getHeight(null);
        System.out.println("width :" + width + "-- height :" + height);
        getImageDimesion("Picture.jpg");
    public static void getImageDimesion(String abc) {
        Image image = Toolkit.getDefaultToolkit().getImage(abc);
        double width = image.getWidth(null);
        double height = image.getHeight(null);
        System.out.println("width :" + width + "-- height :" + height);
}output:
width :-1.0-- height :-1.0
width :2592.0-- height :1944.0
There is no difference in main function getWidth/ getHeight and function getImageDimension getWidth/ getHeight
If u remove getWidth and getHeigth in the main function i.e comment the 1st four lines in main function then the output is
Output
width :-1.0-- height :-1.0
Plz help in understanding this.
Thanks
Venkat

Toolkit images are not loaded until they are first drawn or you request a property from it (such as getWidth). To force the image to load and wait for it to finish loading, you can use the MediaTracker class. The ImageIcon class has one built in.
Image image = Toolkit.getDefaultToolkit().getImage("Picture.jpg");
new ImageIcon(image); //loads the image

Similar Messages

  • MySQL using Is Null and Is Not Null

    Hi
    I am using mySQL and PHP to design a web site. On one of the
    pages I want to able to display a list of records based on a date
    field either having a date inputted or not having a date inputted.
    I want the user to be able to select these options on the page via
    a list box as below
    Label Value
    Open Is Null
    Closed Is Not Null
    However I can not seem to get this to work (sql below), is
    the syntax correct and should it be a GET or POST variable eg
    $_POST['ListBox']. Hope this makes sense.
    SELECT *
    FROM tbltable
    WHERE datefield variable
    Thanks

    Change the order of your conditions
    SELECT name,
           lname,
           CASE WHEN creditcard IS NULL AND credit_used IS NULL THEN
             'Sell both'
           WHEN creditcard IS NULL THEN
             'Sell Card'
           WHEN credit_used IS NULL THEN
             'Sell Credit'
           ELSE
             'No Action'
           END "Action"
      FROM customers;

  • Images as Buttons and Image Resizing in mxml

    Sorry for all the questions but I've run into a problem when trying to create buttons that are just an image in mxml. When I first tried this I couldn't find a way to get the border around the button to dissapear so it ended up looking like my image had an extra black border around it. Then someone here suggested I just set the buttonMode property of an mx:Image to true which ended up working fine to a point. The problem I'm having is that even if I make the tabEnabled property of the image (that I'm using as a button) true, I can't tab over to it. Is there a way to either get rid of the black borders of a button or to make it so I can tab over to an image I'm using as a button?
    My second question has to do with image resizing. Lets say I have an image of a horizontal line that I want to put at the top of the mxml page, and I want it to extend the full length of the page, even after the user has resized the browser. Is there a way to do that? I've tried putting the width as 100% or giving the image a "left" and "right" value so that presumably it would be stretched to fit within those but nothing has worked so far. Is there no way to do this or am I doing something wrong?
    Thank you for any help you guys can give.

    Of course, sorry about that. So the following is a barebones example of how I currently implement buttons and images as buttons:
    <mx:Button id="facebookButton" icon="@Embed(source='image.png')" width="30"/>
    <mx:Image buttonMode="true" id="button" source="anotherimage.png" enabled="true" click="{foo()}"/>
    And within the image I've tried making the tabFocusEnabled property true but to no avail.
    The following is how I've tried stretching out an image across the whole page:
    <mx:Image source="yetanotherimage.png" width="100%" scaleContent="true"/>
    <mx:Image source="yetanotherimage.png" left="10" right="10" scaleContent="true"/>
    Is this more helpful?

  • IWeb '08 Images Not Publishing and Image Distortion in Application

    I created a website a couple of years ago and recently noticed two issues:
    1) Images I included on the site are now not showing up on the published site, but still appear in iWeb '08 app.
    2) Images and graphics in iWeb '08 app are barely showing up. It looks like images that were really over exposed, but the rest of my computer shows colors and images beautifully.
    Anyone else run into these issues? How should I fix it?
    Thanks in advance for your help!

    Actually, somehow, I just solved both problems. I opened up iWeb 9 and it seemed to resolve both issues. Sorry for any confusion.
    Message was edited by: ethouston

  • Difference between column_name is null and column_name (+) is null in where clause.

    Hi All,
    I found the below condition in one of the code of my project.
    Select *
    From table name
    Where column_name ( + )  is null .
    Could any one explain what does column_name ( + ) in where clause.
    Thanks in advance.
    Regards,
    Jagadeeah

    Hi,
    Jagadeesh R wrote:
    Hi All,
    I found the below condition in one of the code of my project.
    Select *
    From table name
    Where column_name ( + )  is null .
    Could any one explain what does column_name ( + ) in where clause.
    Thanks in advance.
    Regards,
    Jagadeeah
    The  ( + )  sign is an old way of doing outer joins.  In Oracle 8 and earlier, you couldn't say
    SELECT  *
    FROM             scott.dept  d
    LEFT OUTER JOIN  scott.emp   e   ON  e.deptno  = d.deptno
    Instead, you got those results by saying:
    SELECT  *
    FROM    scott.dept  d
    ,       scott.emp   e
    WHERE   e.deptno  ( + ) = d.deptno
    The 1 line you posted was probably part of a larger WHERE clause.  You'll have a better understanding of what that 1 line is doing if you look at it in context, considering all the join conditions between the tables involved.

  • Filter by form shows only "Is Null" and "Is Not Null" value in split database

    Hello,
    I have a SPLIT database into FE (forms, queries...) and BE (tables with data) ready for distribution.
    PROBLEM
    When "Filter by Form" is chosen
    only 2 values are available in combobox filter ("Is Null", "Is Not Null"). All other functionalities of the form work fine (data display), which means that tables are linked
    correctly.
    In the UNSPLIT database "Filter by Form" works OK (i.e. comboboxes show lists of possible values to choose from).
    All the forms (and queries) behave like this.
    Recordsource of all forms are queries.
    Type of filtered fields => text (no memo fields, no comboboxes)
    QUESTION:
    What is the reason of this behavior and how can it be fixed so that "Filter by Form" works in SPLIT database (and displays available values in comboboxes)?
    Thank you for help.

    Hi,
    this is the default behaviour with linked tables. To change it:
    open the form in design view
    select the text box you want to use for the filter
    in the properties of the text box click at the data tab and change the FilterLookUp property from "Database default" to "Always"
    See also
    https://msdn.microsoft.com/en-us/library/office/ff194556(v=office.15).aspx.
    cu
    Karl
    Access FAQ (de/it): http://www.donkarl.com
    Access Lobby: http://www.AccessDevelopers.org

  • Image processor script and image interpolation setting (cs3)

    Hi all,
    I'm using Bridge & Photoshop CS3 (mac) to process batches of photographs. I've discovered that the script "Image Processor" does not take into account the "image interpolation" setting of my General Preferences in Photoshop.
    It's very painful, because I cannot use "Image Processor" any longer, as it produces soft images where I need sharp ones (my default for "image interpolation" is "bicubic sharper".
    Any idea/workaround?
    thanks
    Patrick

    This is the change I made in CS5 fit image
        // resize the image using a good conversion method while keeping the pixel resolution
        // and the aspect ratio the same
        //app.activeDocument.resizeImage(newWidth, newHeight, resolution, ResampleMethod.BICUBIC); Commented out JJMACK
        if ( newWidth > app.activeDocument.width || newHeight > app.activeDocument.height ) {
            if (!limit) {app.activeDocument.resizeImage(newWidth, newHeight, resolution, ResampleMethod.BICUBICSMOOTHER);}
        else { app.activeDocument.resizeImage(newWidth, newHeight, resolution, ResampleMethod.BICUBICSHARPER); }
    Note: Adobe choice to use BICUBIC is probally the best choice for users in general. For I find an images has been sharpened before its downsizes, downsizimg it using BICUBICSHARPER  is not the best choice then.

  • How To know Which Columns are not null and Which are null

    Hi Freinds,
    I want to Know ,How by Wrting a Query we can get the Names of The Columns from the Table which is set to not-null or null,
    Thanks
    Shoaib

    SELECT * FROM user_tab_columns
    WHERE table_name='Your_Table_Name'Check NULLABLE column.

  • Image getWidth & getHeight

    I got this problem in getting the size of the image display on the screen. I try to used getWidth & getHeight and print it out but the value is 0. I try many time will different combination but still can't.
    This is the example:
    map = getToolkit().getImage("Map3.jpg");
    MediaTracker track=new MediaTracker(this);
    track.addImage(map,0);
    try{track.waitForID(0);}
    catch(InterruptedException ie){}
    int w=this.getWidth(map);
    int h=this.getHeight(map);
    Actually, I am trying to resize the image to which fit the JPanel I created but fail. Any idea?

    I presume you mean to be using map.getWidth(this) and map.getHeight(this)?
    It's sufficient to use map.getWidth(null) and map.getHeight(null) in this context.
    However, are you sure that the image is being loaded?
    Put the image in the root directory of your project and try using "/Map3.jpg" instead.
    Hope this helps.

  • Null and Empty Values

    Hi All,
    Is there a parameter which allows me to translate automatically the instruction
    select * from table_a where col_a = ''
    in
    select * from table_a where col_a is null
    Thanks

    Not in Oracle, no. col_a = NULL and col_a IS NULL are logically distinct clauses. If you are dealing with NULL's, you absolutely must use three-valued logic in your statements.
    Depending on what you are doing, you may be able to throw an NVL on col_a to ensure a non-NULL value is returned.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Popup Key LOV, NULL and "Invalid numeric value undefined for column"

    Hello.
    I've created an item based on database column of NUMBER type and set the following properties:
    Display As = Popup Key LOV (Displays description, returns key value)
    List of values definition=select 'display_value' d, 1 r from dual
    Null display value=%
    Null return value=
    Display Null=Yes
    When I select "%" in the LOV and try to apply changes to database I get error:
    ORA-20001: Error in DML: p_rowid=1781, p_alt_rowid=N1, p_rowid2=, p_alt_rowid2=. ORA-20001: Invalid numeric value undefined for column N2
    Error Unable to process row of table TTT.
    If I set Display As = Select List, all works fine. But I need Popup Key LOV.
    Could anybody help me?
    I use Application Express 2.2.1.00.04

    Hi all,
    I did my homework and solved this issue. First I would like to thank Patrick Wolf for the invaluable help he gives out on thread Re: Null value handling in LOVs The code presented here is just a minor edit to his code, but an essential one when dealing with Popup Key LOV items.
    Here's what I did:
    1. Create an Application Process.
    Name: RemoveNulls
    Sequence: 0
    Point: On Submit: After Page Submission - Before Computations and Validations
    Process Text:
    BEGIN
        FOR rItem IN
          ( SELECT ITEM_NAME
              FROM APEX_APPLICATION_PAGE_ITEMS
             WHERE APPLICATION_ID   = TO_NUMBER(:APP_ID)
               AND PAGE_ID          IN (TO_NUMBER(:APP_PAGE_ID), 0)
               AND LOV_DISPLAY_NULL = 'Yes'
               AND LOV_DEFINITION   IS NOT NULL
               AND LOV_NULL_VALUE   IS NULL
        LOOP
            IF (V(rItem.ITEM_NAME) = '%null' || '%' OR V(rItem.ITEM_NAME) = 'undefined')
            THEN
                Apex_Util.set_session_state(rItem.ITEM_NAME, NULL);
            END IF;
        END LOOP;
    END;Error Message: #SQLERRM#Condition: None
    2. You should be able to submit a Popup Key LOV with a NULL value now.
    Once again, THANKS, Patrick! You rock! I'm seriously thinking of trying ApexLib now :)
    Georger

  • NULL and dynamic SQL

    If table testrh2 has the following columns and data
    col1 --> NULL
    col2 --> 2
    and table testrh has the following columsn and data
    col1 --> NULL
    How could I write a dynamic SQL statement to join on the nulls? I've written the following block as a starting point.
    declare
    cursor c1 is select col1 from isis.testrh;
    lval varchar2(1000);
    lval2 varchar2(1000);
    begin
    for r1 in c1 loop
    lval := 'select col2 from isis.testrh2 where col1 = '||r1.col1;
    execute immediate lval into lval2;
    dbms_output.put_line(lval2);
    end loop;
    end;

    You can't compare null values with '=' in Oracle SQL.
    Null can only be compared with <column> is null .
    You can see it when you try these two queries:
    select * from dual where null is null;  -- you will see one row
    select * from dual where null=null;  -- you will see no rowsThat's why you have to write something like
    (<column1>=<column1>   or   (<column1> is null and <column2> is null))This should also work with null:
    decode(<column1>,<column2>,1,0)=1By the way, why do you use dynamic sql?
    lval := 'select col2 from isis.testrh2 where col1 = '||r1.col1;
    I think you could replace your two lines ( lval:= ... AND execute immediate) by this:
    begin
      select col2
      into lval
      from isis.testrh2
      where decode(col1,r1.col1,1,0)=1;
      dbms_output.put_line('lval='||lval);
    exception
    when no_data_found then
      dbms_output.put_line('no data found'); -- or whatever you want
    end;Edited by: hartmutm on 02.10.2010 23:54

  • How can I set my WebI filters to Null and not Null

    Folks,
    I have created a report in WebI and now I am to set up some filters as Null and some Not Null.
    How can I set my WebI filters to Null and not Null?
    Regards,
    Bashir Awan

    Hi,
    As you said you could do it at the report level and also at the universe level.
    One more way is to create the filters in the universe levele and add them in thequery filter.
    Ex: in the filter you need to write :
    Column1 is null and and column 2 is not null etc.
    Hope this will help.
    If this did't  solve your problem then please explain it in detail.
    Cheers,
    Ravichandra K

  • Is there any options/addons for selecting/changing image size when viewing images?

    When clicking to open images when on web pages there is no option to select size.
    I'm looking at some pages that have images (mostly jpg) I like to compare and that is very hard when all images open in a size that normally fill most of the browser window.
    So I wonder if there is some hidden options or addons for selecting image size when opening images for viewing?
    I have tried Image resizer/scaler, image zoom and show picture with mix results. Image resizer/scaler and image zoom allow resizing of images, but when opening images on same tab as web page the white image "frame" that is visible when reducing image size is left in original size. This make viewing and opening other pages a hazard.
    I'm grateful for any help...cheers :-)
    Picture of white frame
    http://s25.postimg.org/z1ubo6zun/Remove_Exterior_Fog_at_Skyrim_Nexus_mods_and_c.png

    hehe no offense, but I'm not following the version rushing from Mozilla. I'm using many customizations and addons and it is a nightmare to change to a new version and practically impossible to use last version. Also the FIrefox history have shown that earlier versions have both been more stable and had better implementation of features.
    Spending hours customizing and finding out that addons dont work with new version every time Firefox come with a new version , no thanks. For that to happen Firefox have to be more compatible across versions and more friendly toward customization in updates and new versions. I have used Firefox for at least 8-9 years with practically no security problems and one thing I have learned is: dont update or install next version if the version I have is working well.
    Maybe I should have mentioned this in this question, that Im using v26 and that my FIrefox is heavily modified with addons and customizations.
    '''Back to the subject'''
    Anyway I dont think any of my customizations or addons should create a white frame behind images, but I'm asking to find out if you guys also get this white frame when resizing pictures to a smaller size after clicking images for viewing.

  • Java.awt.Image getWidth() and getHeight() not working!

    Right- this is want I want to do.
    I have a background image which is added as a background image to a third party API class which extends Java.awt.Container. Such container is then added to the Content Pane of MyClass (which extends JFrame)
    I want to read the width and height of the image and resize MyClass accordingly.
    Problem is calling theImage.getWidth(MyClass.this) or theImage.getWidth(theThirdPartyAPIContainer) always return -1 and -1 denoting that no information is available.
    What do I need to do to obtain the height and width?

    Post here, cos don't know your email.
    Anyway
    - Can't use setPreferredSize because the Conatiner which is added to the ContentPane is a Awt Component not a Swing JComponent!
    - Also, the background is added AFTER the this.pack()and this.show().
    -I figured out that I could access Insets.top, Insets.left, Insets.right, Insets.bottom.
    I have basically the following
    |JMenuBar |
    L____________________________________________|
    | |
    | |
    | |
    | Third Party Class extending java.awt.Container |
    | containing an image of known size |
    | |
    L____________________________________________|
    I am fine for the width I do
    Insets frameInsets = this.getInsets();
    width = image.getWidth() + frameInsets.left + frameInsets.right;
    Height is the problem
    After some Trial an error it LOOKS on Solaris as if the following is right-
    height = image.getHeight()+frameInsets.top+ myJMenuBar.getSize()+getHeight+ myJMenuBar.getInsets().top + myJMenuBar.getInsets().bottom
    I cannot comprehend whether this is just a coincidence or not as I don't know why frameInsets.bottom should in any case be excluded.
    Here are the dimensions-
    frameInsets.left = 6
    frameInsets.right= 6
    frameInsets.top =28
    frameInsets.bottom = 6
    JMenuBar height = 23
    JMenuBar's Insets.top = 1
    JMenuBar's Insets.bottom = 1
    What should be the 'correct' calculations and does the Insets for the JMenuBar and the JFrame overlaps?

Maybe you are looking for

  • MSI KT3 Ultra ARU and 200gb Hard Drive

    I just bought a 200gb Hitachi Deskstar and loaded up Windows XP and noticed that the drive size is only 137GB instead of around 200. Does the KT3 Ultra Aru no support 200gb Hard Drives? What do I need to do to make this work? Thanks in advance.

  • The files in the cloud

    I do not see the files you've uploaded to the cloud. Is there any solution?

  • Different results on a SQL sort depending on the tool?

    Hi, i've a problem with sorting a column, getting different results depending on the tool. Environment: Oracle 8.1.6 on Solaris, Oracle Client on NT 4.0 (SP5) The Query: SELECT * FROM mytable ORDER BY mycolumn ASC This is the result of a query by SQL

  • Mac pro 10.4.11 will not shut down

    Since updating to 10.4.11 I am having trouble shutting down.It either hangs on the blue screen or the screen stays on half blue half grey. Can you do any damage by shutting down by holding the power button down? Many thanks

  • How to install a .exe file

    I downloaded a software file entitled Epocrates2PalmW.exe and the system defaulted to Adobe Reader 7.0.5 which would not install it. I have not found another installer or updater file to install this software. Any suggestions? Thanks! Power PC G3   M