Can't show image in the center of the jscrollpane ,any one can help

i write a program to show image in the jscrollpane
i create a class called ImageLabel (it extends jlabel) then i use
ImageLabel im=new ImageLabel(imageicon)
jscrollpane.setViewportView(im);
validate();
repaint();
but it show the image in the left and top corner of the jscrollpane ,not in the center of the jscrollpane
then i change the ImageLabel to JLabel ,:
JLabel im=new JLabel(imageicon);
jscrollpane.setViewportView(im);
validate();
repaint();
it shows the image in the center of the jscrollpane,
but i want to use ImageLabel not jlabel
whats the problem ,any one can help me ,thank you:)

the ZoomLabel is the imagelabel ,and my complete code as follows:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
class ZoomLabel extends JLabel
    private ImageIcon icImage;   
    private int ph,pw,picW,picH;    
    ZoomLabel(ImageIcon ic)   
        super(ic, JLabel.CENTER); 
        icImage = ic;
        pw = picW = ic.getIconWidth(); 
        ph = picH = ic.getIconHeight();
       setSize(pw,ph);
       setPreferredSize(new Dimension(pw,ph));
       repaint();
      validate();
       public void zoom(float scale)    
           ph = Math.round(picH * scale);         
           pw = Math.round(picW * scale);          
           setPreferredSize(new Dimension(pw,ph)); 
           repaint();
         public void paint(Graphics g)     
                 update(g);     
            public synchronized void update(Graphics g)     
            {             g.drawImage(icImage.getImage(),0,0,pw,ph,this); 
  public class ImageShow extends JFrame
              ImageShow()
             ImageIcon ii=new ImageIcon("e:/download/pic/me1.JPG");
               JScrollPane js=new JScrollPane();
               zl=new ZoomLabel(ii);
              js.setViewportView(zl);
              getContentPane().add(js,"Center");
                 js.repaint();
                              js.validate();
              pack();
              setVisible(true);     
         public  static void main(String[] args)
               new ImageShow();
         ZoomLabel zl;
    }

Similar Messages

  • I have buy 4s it's unlocked and its working with different carriers in Bahrain but in Pakistan I try to use different carriers's sims but its showing sim is not valid , not compatible? any one please help me out this

    I have buy 4s it's unlocked and its working ok with different carriers in Bahrain, but in Pakistan I try to use different carriers's sims but its showing sim is not valid , not compatible? any one please help me out this?

    Try restoring the iPhone to factory settings. If you are having difficult restoring, put the iPhone into Recovery Mode and see if that then works:
    http://support.apple.com/kb/ht1808
    If not, or if a restore to factory settings does not fix the problem, then your iPhone may have a hardware problem. You can only get the iPhone serviced by Apple in Canada, so you will have to take the iPhone there or send it to someone you know in Canada who can get the iPhone serviced and send it back to you. The only option for getting service in Pakistan would be to pay some unauthorized repair shop to attempt a repair, after which Apple will no longer provide any service even in Canada.
    Regards.

  • I am using iPhone 4S , iOS 6.0.1. I can sign in using my apple password, but the App Store showing message your password is incorrect. Do any one help me?

    I am using iPhone 4S , iOS 6.0.1. I can sign in using my apple password, but the App Store showing message your password is incorrect. Do any one help me?

    Try This...
    Close All Open Apps... Sign Out of your account... Perform a Reset... Try again...
    Reset  ( No Data will be Lost )
    Press and hold the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears. Release the Buttons.
    http://support.apple.com/kb/ht1430

  • I am not able to access my photos through the photo application... when I click on the photo app, I can see the camera roll but a transparent album screen is over it and I cannot click on the photos to see it... can any one please help ???

    I am not able to access my photos through the photo application... when I click on the photo app, I can see the camera roll, but a transparent "album" screen is over it and I cannot click on the photos to see it... can any one please help ???

    Known bug.  Quit the Camera App, double-tap the home key and delete Camera from the recent apps bar. Fire it up again, should be good.

  • TS1702 I can't install and update any application, even for the free app the system ask me to sign in to the billing payment. Even though that I did sign, it still declined. Any one could help, please

    I can't install and update any application, even for the free app the system ask me to sign in to the billing payment. Even though that I did sign, it still declined. Any one could help, please

    All Apple iTunes Store accounts must have a valid form of payment set up. Even for free apps and updates. The Payment Declined message comes from your card issuer or payment source; Apple is just a pass-through for the message. You need to find out why your issuer is declining your card.

  • After backing up my iPod my applications will not reload and just shows waiting underneath the application any help?

    After backing up my iPod my applications will not reload and just shows waiting underneath the application, any help?

    http://lifehacker.com/5948155/fix-iphone-apps-stuck-waiting-during-installation
    http://alvinalexander.com/apple/iphone-waiting-apps-update-install-reinstall-del ete-ipod

  • Hi when i convert a pdf to word I get a inccorect conversion, can any one please help me

    hi when I convert a pdf to word document I get a inccorect conversion, can any one please help me

    Hey nikolays87340013,
    Thanks for your reply.
    Please let me know what version of Adobe Reader you are using.
    You might need to check for updates as well as repair installation from Reader Help menu.
    While converting scanned PDF into Word, OCR runs automatically and its quality largely depends upon the quality of scanned images and clarity of characters in the PDF.
    Please try the same conversion online after signing in at "https://cloud.acrobat.com/exportpdf" and check if the conversion quality varies.
    Let me know.
    Regards,
    Anubha

  • How to install windows 7 on my macbook pro mid 2009 using usb. right now aim using mavericks 10.9 can any one please help me. I tried to edit plist in boot camp but it went wrong please help me

    how to install windows 7 on my macbook pro mid 2009 using usb. right now iam using mavericks 10.9 can any one please help me. I tried to edit plist in boot camp but it went wrong please help me.
    Iam new to coding. please help me.

    try the solution posted by kunu here and report back
    https://discussions.apple.com/thread/5105056?tstart=0

  • I bought CS6 creative suite. As of now i need to work each application in separate separate system. Can any one please help me how to solve this problem.

    I bought CS6 creative suite. As of now i need to work each application in separate separate system. Can any one please help me how to solve this problem.
    I saw the below quote on Adobe forum
    "You may install software on up to two computers. These two computers can be Windows, Mac OS, or one each."
    If i install each application in single single system the system count is more than two. In this case, are we have any license issue? Please advice how the problem will solve?
    If possible please send the advise to my mail id: <Removed by Moderator>
    Thanks
    Uvaraj S

    I already answered that.  If you purchased a Suite then you can only install and activate it on two machines.  Even if you only insdtall one of the applications of that suite, it counts as one activation of the suite.  You cannot take the six or seven different applications that might be in a suite and install and activate them in six or seven different machines... only two machines.
    If your scenario will allow for it, one thing you can do is install the programs on all the different machines and only activate two of the machines at any given time.  If you need to activate a program on a third machine then you need to deactivate on one of the currently activate machines first so that you have an open activation to use again.  I do not remember if there is a limit to the total number of activations you can process for the life of the software.

  • Since upgrading to OS X 10.8.2 a few days ago, Safari will suddenly zoom in on web pages (happens on multiple sites) when I scroll or move the mouse -- any one know why and what to do about it? Thanks.

    Since upgrading to OS X 10.8.2 a few days ago, Safari will suddenly zoom in on web pages (happens on multiple sites) when I scroll or move the mouse -- any one know why and what to do about it? Thanks!

    It really isn't a well thought out 'gesture' when a normal scroll action can result in an unwanted zoom but disabling SmartZoom wasn't an option for me—one of those with eyes that tire easily when reading very small text on a 27" display.
    For a while I used command-+ and command-'-' to read small text but that isn't supported in some apps and for Safari it often leaves the browser in an less than perfect state when moving to the next page.  I also tried option scroll to zoom the whole display but that was not desirable, either.
    I finally settled on leaving SmartZoom enabled and remembering to double tap with one finger whenever the undesired zoom happens. It happens so often that the double tap is almost a reflex action for me.

  • I installed new 6.0.1 os it is done succesfully but after that insterted my sim it is showing sim card not supported any one plz help me

    i installed new 6.0.1 os it is done succesfully but after that insterted my sim it is showing sim card not supported any one plz help me

    That message occurs when updating a phone that was hacked to be used with your network.  Upgrading the phone has re-locked it to it's rightful carrier.  You will need a SIM from the original carrier to proceed.

  • Hi im using 4s and when i try to download apps its asking my credit card details. can any one please help me

    hi im using 4s and when i try to download apps its asking my credit card details. can any one please help me

    even when you are dowloading free app Apple needs to check that you have valid billing details but you will not be billed for downloading of free apps.  Go to settings/itunes & app store tap on ID there log in and check acocunt details there

  • We are thinking of the Ipad  - any one use one at the beach?

    We are thinking of the Ipad  - any one use one at the beach - any glare from the sun?

    They are not ideal for use in bright sunlight due to the reflectiveness of the glass. An anti-glare cover might help, but if your main use will be to read books on the beach then a dedicated ebook reader would probably be better

  • Jquery zoom plugin that shows images above the zoomed image on mouse rollover

    Hi all, after much effort and help from this forum I've managed to get a zoom effect to work on my image. It needed to be a loupe effect like this - http://www.dailycoding.com/Posts/imagelens__a_jquery_plugin_for_lens_effect_image_zooming. aspx
    This is the plugin I've used.
    Problem now is that I need images to appear above the image on mouse rollover. Currently - if I place images above this image and place my cursor over the image the zoom effect works but it ignores the images placed on top and just zooms in on the image shown below.
    I would be very appreciative of anyone who can help me with this issue.
    Thanks.
    I wondered if it was possible to stop the jquery zoom plugin working when I mouseover the image on top of the map. Maybe that would be a solution?

    > the image I have above the roll over I have just
    > inserted shows the image that should be shown when I
    roll over the image I
    > have
    > just inserted
    url address please. words will not work for this.
    random guess- check that the name and/or ID of every item on
    the page is
    unique.
    Alan
    Adobe Community Expert, dreamweaver
    http://www.adobe.com/communities/experts/

  • Show image on the form Java WS gets image. Call this WS on button click

    Hi,
    Is there a way to show an image on the form. On the form I have along with the data I have a button that when clicked get and show the image itself on the form. I have a Java WebService that gets the image from the remote location. How can I make the button click event to call this Web Service and show the image on the form itself. Any help is appreciated.
    Thanks

    WHiteSox, are you on client/server or web version.
    which version of forms are you using.
    something i can think of is.
    during the click to call the webservice, copy the image to the local system.
    next step is, using READ_IMAGE_FILE built in which reads the image from the local file system and displayed on the forms image item.

Maybe you are looking for

  • Events in Reports

    hi , can any one help me the events or any sample codes used for the below reports 1) ABAP Query Report 2) Report Writer / Report Painter 3) logical database reports thanks Edited by: Alvaro Tejada Galindo on Feb 4, 2008 2:43 PM

  • Installed Lion from AppStore-looks like running Leopard & Lion-wierd

    I installed Lion from the AppStore- by all accounts- it's running Lion. Yet when my machine is turned off and powered back on, the Snow Leopard appears and I lose Lion background. I have a suspiscion it is running both somehow because my computer is

  • Can a Button call a java script and then proceed with the creation

    Hi all, I have a simple APEX form on a table, with simple function as create and apply changes, some items of the form are computed by a "Computation" I need the create button to show the computed values, before move to the next page, then proceed wi

  • Question regarding best practice

    Hello Experts, What is the best way to deploy NWGW? We recently architected a solution to install the 7.4 ABAP stack which comes with Gateway. We chose the Central Gateway HUB scenario in a 3 -tier setup. Is this all that's required in order to conne

  • Definition of IMPORTING  IS_KEYINFO in reuse_alv_hierseq_list_display

    function reuse_alv_hierseq_list_display. *"  IMPORTING *"     VALUE(IS_KEYINFO) TYPE  SLIS_KEYINFO_ALV hi could anyone explain the purpose if this importing parameter in the FM and a definition of its usage.  PLZZ