Getting the bounds of a windows

Hello all,
I have a jpanel application that i'm creating and i need to take -in some way- the bounds of the panel window (the window that my drawings etc are being displayed). I've tried the "getBounds" method returning a rectangle but all the values of that rectangle were 0. Do you have an idea how to get the bounds of the window at any moment i need them?
Friendly yours,
-John

JFrame.getBounds() works fine for me. Your frame must of course be visible.

Similar Messages

  • How to get the values from popup window to mainwindow

    HI all,
       I want to get the details from popup window.
          i have three input fields and one search button in my main window. when i click search button it should display popup window.whenever i click on selected row of the popup window table ,values should be visible in my main window input fields.(normal tables)
       now i am able to display popup window with values.How to get the values from popup window now.
       I can anybody explain me clearly.
    Thanks&Regards
    kranthi

    Hi Kranthi,
    Every webdynpro component has a global controller called the component controller which is visible to all other controllers within the component.So whenever you want to share some data in between 2 different views you can just make it a point to use the component controller's context for the same. For your requirement (within your popups view context) you will have have to copy the component controllers context to your view. You then will have to (programmatically) fill this context with your desired data in this popup view. You can then be able to read this context from whichever view you want. I hope that this would have made it clear for you. Am also giving you an [example|http://****************/Tutorials/WebDynproABAP/Modalbox/page1.htm] which you can go through which would give you a perfect understanding of all this. In this example the user has an input field in the main view. The user enters a customer number & presses on a pushbutton. The corresponding sales orders are then displayed in a popup window for the user. The user can then select any sales order & press on a button in the popup. These values would then get copied to the table in the main view.
    Regards,
    Uday

  • Getting the bounds of a drawn image on a panel

    Hello, I have a problem with getting the bounds of a drawn image on a panel...Since it is drawn as graphics, i tried getClipBounds and since my class extends JPanel i tried to get the bounds from the panel but neither of them worked properly. It only gets the bounds of a jframe that contains the panel.Then i tried to put the panel in a layeredpane and then a container; but this time the image disappeared completely. Hope someone can help or tell me what I am doing wrong. Thanks in advance. Here is the code below:
    By the way what I am trying to do in this code is basically zooming the image in and out by dragging or the mouse wheel. But I need to get the bounds so that I can use this.
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    * @author Admin
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Image;
    import java.awt.Point;
    import java.awt.RenderingHints;
    import java.awt.Toolkit;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import java.awt.event.MouseWheelEvent;
    import java.awt.event.MouseWheelListener;
    import java.awt.geom.AffineTransform;
    import java.awt.geom.NoninvertibleTransformException;
    import java.awt.geom.Point2D;
    import javax.swing.JFrame;
    import javax.swing.JLayeredPane;
    import javax.swing.JPanel;
    public class ZoomDemo extends JPanel {
    AffineTransform tx = new AffineTransform();
    String imagePath = "D:/Documents and Settings/Admin/Belgelerim/tsrm/resim.jpg";
    Image image = Toolkit.getDefaultToolkit().getImage(imagePath);
    int width = image.getWidth(this);
    int height = image.getHeight(this);
    int scrwidth = Toolkit.getDefaultToolkit().getScreenSize().width;
    int scrheight = Toolkit.getDefaultToolkit().getScreenSize().height;
    double zoomfac = 1.0;
    int xAdj;
    int yAdj;
    int prevY;
    double scale = 1.0;
    Point pt;
    public static int x;
    public static int y;
    public static int w;
    public static int h;
    public ZoomDemo() {
    this.addMouseWheelListener(new ZoomHandler());
    this.addMouseListener(new ZoomHandler());
    this.addMouseMotionListener(new ZoomHandler());
      repaint();
    @Override
    public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.drawImage(image, tx, this);
    // x =    (int) g2.getClipBounds().getX();
    // y=     (int) g2.getClipBounds().getY();
    // w=     (int) g2.getClipBounds().getWidth();
    // h=     (int) g2.getClipBounds().getHeight();
    // System.out.println(x+" "+y+" "+w+" "+h);
    //  public int getRectx(){
    //    return x;
    //public int getRecty(){
    //    return y;
    //public int getRectw(){
    //    return w;
    //public int getRecth(){
    //    return h;
    private class ZoomHandler implements MouseWheelListener,MouseListener, MouseMotionListener {
    public void mousePressed(MouseEvent e){
        System.out.println("Mouse Pressed");
    xAdj = e.getX();
    yAdj = e.getY();
    prevY = getY();
    public void mouseDragged(MouseEvent e){
           System.out.println("Mouse Dragged");
    boolean zoomed = false;
    if(e.getY()<prevY){
         zoomfac = zoomfac + 0.1;
         prevY = e.getY();
         zoomed = true;
    else if(e.getY()>prevY){
         zoomfac = zoomfac - 0.1;
         prevY = e.getY();
         zoomed = true;
       scale = zoomfac;
    Point2D p1 = new Point((int)xAdj-(width/2),(int)yAdj-(height/2));
    Point2D p2 = null;
    try {
    p2 = tx.inverseTransform(p1, null);
    } catch (NoninvertibleTransformException ex) {
    // should not get here
    ex.printStackTrace();
    return;
    tx.setToIdentity();
    tx.translate(p1.getX(), p1.getY());
    tx.scale(scale, scale);
    tx.translate(-p2.getX(), -p2.getY());
    tx.transform(p1, p2);
    ZoomDemo.this.revalidate();
    ZoomDemo.this.repaint();
    public void mouseWheelMoved(MouseWheelEvent e) {
    if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
    Point2D p1 = e.getPoint();
    Point2D p2 = null;
    try {
    p2 = tx.inverseTransform(p1, null);
    } catch (NoninvertibleTransformException ex) {
    // should not get here
    ex.printStackTrace();
    return;
    scale -= (0.1 * e.getWheelRotation());
    scale = Math.max(0.1, scale);
    tx.setToIdentity();
    tx.translate(p1.getX(), p1.getY());
    tx.scale(scale, scale);
    tx.translate(-p2.getX(), -p2.getY());
    ZoomDemo.this.revalidate();
    ZoomDemo.this.repaint();
            public void mouseClicked(MouseEvent e) {
                //throw new UnsupportedOperationException("Not supported yet.");
            public void mouseReleased(MouseEvent e) {
                //throw new UnsupportedOperationException("Not supported yet.");
            public void mouseEntered(MouseEvent e) {
               // throw new UnsupportedOperationException("Not supported yet.");
            public void mouseExited(MouseEvent e) {
               // throw new UnsupportedOperationException("Not supported yet.");
            public void mouseMoved(MouseEvent e) {
               // throw new UnsupportedOperationException("Not supported yet.");
    public static void main(String[] args) {
    //SwingUtilities.invokeLater(new ZoomDemo());
    int scrwidth = Toolkit.getDefaultToolkit().getScreenSize().width;
    int scrheight = Toolkit.getDefaultToolkit().getScreenSize().height;
    JFrame f = new JFrame("Zoom");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(scrwidth , scrheight);
    //JLayeredPane lp = new JLayeredPane();
    //f.add(lp);
    ZoomDemo zd = new ZoomDemo();
    zd.getBounds();
    f.add(zd);
    //int x = (int) zd.getX();
    //int y = (int) zd.getY();
    //int w = (int) zd.getWidth();
    //int h = (int) zd.getHeight();
    //System.out.println(x+" "+y+" "+w+" "+h);
    //zd.setBounds(x ,y ,w ,h );
    //lp.add(zd, JLayeredPane.DEFAULT_LAYER);
    //f.setLocationRelativeTo(null);
    f.setVisible(true);
    //lp.setVisible(true);
    //zd.setVisible(true);
    }Edited by: .mnemonic. on May 26, 2009 11:07 PM
    Edited by: .mnemonic. on May 27, 2009 11:00 AM

    You'll need a stable point in the component to track and orient to the scaling transform(s).
    From this you can construct whatever you need in the way of image location and size.
    Let's try a center&#8211;of&#8211;image tracking point:
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import javax.swing.*;
    import javax.swing.event.MouseInputAdapter;
    public class ZD extends JPanel {
        BufferedImage image;
        Point center;
        AffineTransform at = new AffineTransform();
        Point2D.Double origin = new Point2D.Double(0,0);
        public ZD(BufferedImage image) {
            this.image = image;
            center = new Point(image.getWidth()/2, image.getHeight()/2);
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                                RenderingHints.VALUE_INTERPOLATION_BICUBIC);
            g2.drawRenderedImage(image, at);
            g2.setPaint(Color.red);
            g2.fill(new Ellipse2D.Double(origin.x-1.5, origin.y-1.5, 4, 4));
            g2.setPaint(Color.blue);
            g2.fill(new Ellipse2D.Double(center.x-1.5, center.y-1.5, 4, 4));
        private void setTransform(double scale) {
            // keep image centered over Point "center"
            double x = center.x - scale*image.getWidth()/2;
            double y = center.y - scale*image.getHeight()/2;
            origin.setLocation(x, y);
            at.setToTranslation(x, y);
            at.scale(scale, scale);
        public static void main(String[] args) throws java.io.IOException {
            java.net.URL url = ZD.class.getResource("images/hawk.jpg");
            BufferedImage image = javax.imageio.ImageIO.read(url);
            ZD test = new ZD(image);
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(test);
            f.setSize(500,500);
            f.setLocation(100,100);
            f.setVisible(true);
            test.addMouseListener(test.mia);
            test.addMouseMotionListener(test.mia);
        /** MouseAdapter okay in j2se 1.6+ */
        private MouseInputAdapter mia = new MouseInputAdapter() {
            final double SCALE_INC = 0.05;
            final int SCALE_STEP = 20;
            double scale = 1.0;
            double lastStep;
            public void mousePressed(MouseEvent e) {
                Point p = e.getPoint();
                center.setLocation(p);
                //System.out.printf("center = [%3d, %3d]%n", p.x, p.y);
                setTransform(scale);
                repaint();
            public void mouseDragged(MouseEvent e) {
                // scale up/down with relative vertical motion
                int step = (e.getY() - center.y)/SCALE_STEP;
                if(step != lastStep) {
                    scale += SCALE_INC*((step < lastStep) ? -1 : 1);
                    //System.out.printf("step = %3d  scale = %.3f%n", step, scale);
                    setTransform(scale);
                    lastStep = step;
                    repaint();
    }

  • How to install when I keep getting the following massage  on windows 7 64 bit with or with firewall on and vwith or with virus protection on  here is post  This installation package could net be opened verify that the package exist and that you can access

    how to install when I keep getting the following massage  on windows 7 64 bit with or with firewall on and with or with virus protection on  here is post           " This installation package could net be opened verify that the package exist and that you can access"  same when trying to install quicktime

    I'd first try downloading an installer from the Apple website using a different web browser:
    http://www.apple.com/quicktime/download/
    If you use Firefox instead of IE for the download (or vice versa), do you get a working installer?

  • I can't Start, Uninstall or Install new iTunes. I'm getting the same error message: Window Installer Service could not be accessed.  No other programs have similar problem. Any suggestion what can be done?

    I can't Start, Uninstall of Install new iTunes. I'm getting the same error message: "Window Installer Service could not be accessed". No other programs having similar problem. Any suggestions how to fix it?

    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down the page in case one of them applies.
    The further information area has direct links to the current and recent builds in case you have problems downloading, need to revert to an older version or want to try the iTunes for Windows (64-bit - for older video cards) (not for XP) release as a workaround for installation or performance issues, or compatibility with QuickTime or third party software.
    Your library should be unaffected by these steps but there are also links to backup and recovery advice should it be needed.
    tt2

  • How to decrypt data when you can't get the private key in Windows?

    I'm very confuse. My english is poor, but I try to say my question clearly.
    When browser connects to a https website which needs client certificate to authenticate the identity, the browser will send client certificate to web server.
    Then the web server will use the certificate to encrypt some data and send it to browser.
    Then broswer should have private key to decrypt that.
    But as I know, if I install a pfx format personal certificate, I can set can't export private key, which means you can't get the private key to use it. So how can
    the browser decrypt the data without private key?
    By the way, what is CSP, use CSP's interface can we use CryptoAPI
    to decrypt data without private key?

    Answer for question is  "you cant".. 
    "How to decrypt data when you can't get the private key in Windows?"
    Read more 
    http://msdn.microsoft.com/en-us/library/windows/desktop/aa387460(v=vs.85).aspx
    http://msdn.microsoft.com/en-us/library/windows/desktop/bb427432(v=vs.85).aspx
    http://technet.microsoft.com/en-us/library/dd277320.aspx
    http://en.wikipedia.org/wiki/Public-key_cryptography

  • I am also unable to get the 551L working with Windows 8 Beta 1. Any advice?

    I am also unable to get the 551L working with Windows 8 Beta 1 and Mac OS X 10.8 Mountain Lion Developer Preview 2. Any Advice?

    It should be noted that I was previously in those Windows Beta's and I am also a member of both Microsoft Technet (Retail Subscription), and all 3 Apple Developer Programs (IOS, Mac and Safari), which is the reason why I am running Microsoft Windows 8 Beta 1 on 2 of my 3 Dell's (the oldest one has Microsoft Windows XP Service Pack 3 and Microsoft Office 2003 on it, which is the PC that I am using the 551L on), and the Mid Year 2010 Apple Mac Mini has Mac OS X 10.8 Mountain Lion Server Edition on it (something that I am technically am NOT supposed to be talking about here due to my NDA so this will be the last time I mention it here (as you can see I am known for being the type of  Computer Nerd that loves Alpha and Beta Testing)! :-)

  • TS3212 When I try to start Itunes, I get the message" program can't start because MSVCR80.dll is missing from your computer - try reinstalling the program".  When I try to reinstall I get the message Error 7 (Windows Error 126) - can you help me?

    When I try to start iTunes, I get the message "program can't start because MSVCR80.dll is missing from your computper.  Try reinstalling the program."  When I try reinstalling, I get the message Error 7 (Windows Error 126)
    Can you help me?????

    Hello Charleen,
    It sounds like you are unable to reinstall iTunes because of this error message 7. I recommend the troublehsooting found in the following article that mentions that error named:
    iTunes 11.1.4 for Windows: Unable to install or open
    http://support.apple.com/kb/TS5376
    "iTunes was not installed correctly. Please reinstall iTunes. Error 7 (Windows Error 126)”
    Follow these steps to resolve the issue:
    Check for .dll files
    Go to C:\Program Files (x86)\iTunes and C:\Program Files\iTunes and look for .dll files.
    If you find QTMovie.DLL, or any other .dll files, move them to the desktop.
    Reboot your computer.
    Note: Depending on your operating system, you may only have one of the listed paths.
    Uninstall and reinstall iTunes
    Uninstall iTunes and all of its related components.
    Reboot your computer. If you can't uninstall a piece of Apple software, try using the Microsoft Program Install and Uninstall Utility.
    Re-download and reinstall iTunes 11.1.4.
    Thank you for using Apple Support Communities.
    Take care,
    Sterling

  • I can't get ITunes to install. I get the message: Error 2 Windows. Not able to find Apple Application Support. Uninstall iTunes and reinstall.  I did that and still get the same message.  Thanks for your assistance.  I'm using a Dell Computer, Windows 8

    Can't get iTunes to install. When I download it, and go through installation, I get the message, Error 2, windows 2; can't find Apple Application Support, uninstall and reinstall iTunes.  When I do that I get the same message again. Thank you for your assistance.

    Let's try a standalone Apple Application Support install. It still might not install, but fingers crossed any error messages will give us a better idea of the underlying cause of the issue.
    Download and save a copy of the iTunesSetup.exe (or iTunes64setup.exe) installer file to your hard drive:
    http://www.apple.com/itunes/download/
    Download and install the free trial version of WinRAR:
    http://www.rarlab.com/
    Right-click the iTunesSetup.exe (or iTunes64Setup.exe), and select "Extract to iTunesSetup" (or "Extract to iTunes64Setup"). WinRAR will expand the contents of the file into a folder called "iTunesSetup" (or "iTunes64Setup").
    Go into the folder and doubleclick the AppleApplicationSupport.msi to do a standalone AAS install.
    Does it install properly for you?
    If instead you get an error message during the install, let us know what it says. (Precise text, please.)

  • HELP!! How to get the position of active windows in the desktop

    How to get the position of active windows in the desktop

    You mean, active windows other than the program you're running, or windows the program puts there? And a real desktop (like where MyComputer is), or a desktop pane?

  • How to get the bounds of single char?

    How to get the bounds of single char in text frame?
    Thanks

    I also think there is not an exiting function which can get it, but we can work around. Can you give some ideas to work around it?

  • How to get the mail item opened window?

    Hi,
    I need to get the window of the opened mail.
    Within the mailItem.Open() event tried to get the Application.ActiveExplorer() but it returns the main outlook window.
    From the load of the addin tried as follows, but hwndSource always returns null.
    activeWindow = _mailItem.Application.ActiveWindow()
    ((Microsoft.Office.Interop.Outlook.ExplorerEvents_10_Event)activeWindow).Deactivate += MyEvent
    public void MyEvent()
    System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcesses();
    foreach (System.Diagnostics.Process process in processes)
    if (process.MainWindowTitle.StartsWith (_mailItem.Subject))
    IntPtr handle = process.MainWindowHandle;
    System.Windows.Interop.HwndSource hwndSource = System.Windows.Interop.HwndSource.FromHwnd(handle);
    System.Windows.Window window = hwndSource.RootVisual as System.Windows.Window;
    Any suggestions to get the mail item opened window? Please help.
    VS2010 C# with Outlook 2007.

    Hi Damian,
    When the Open event is fired, the Inspector object
    is initialized but not yet displayed.
    You can handle the
    NewInspector event of the Inspectors class which is fired whenever a new inspector window is
    opened, either as a result of user action or through program code. Then the
    Activate event of the Inspector class is fired, when an inspector becomes the active window,
    either as a result of user action or through program code. 

  • I can't get itunes update to download and install properly.  I get the following message Error7(windows error 26) what can I do

    I recently tried to downlad the itunes update but it would not install properly and now I have no access to itunes and all my music.  I get the following messages - Error7(windows error 26) and This applicaiton has failed to start because MSVCR80.dll was not found.  Can anyone help me fix this issue.  I have a Hewlett Packard Computer and Vista. Thanks

    Similar issues here.
    I purchased five movies for download and having nothing but problems getting them downloaded. I keep receiving error messages and the download stops and I have to restart it, just to get another minute worth of download with each restart. Now Apple has my money and I have nothing.

  • I keep getting the error message "Restore Windows"  Finder application quit unexpectedly.  When I click an icon on the desktop on my Mac Book Pro it does not respond.

    I keep getting the error message "Restore Windows"  When I click an icon on  the desktop on my Mac Book Pro, it is not reaponding.

    While holding down the option key, select "Go>Library" from the Finder. Navigate to the Preferences folder and you'll find "com.apple.finder.plist". Delete that file and restart.
    Good luck,
    Clinton

  • I'm trying to install itunes on my new computer and I keep getting the error message about Windows Installer. It does not show up under "Programs".

    I'm trying to install itunes on my new computer and I keep getting the error message about Windows Installer. I've seen the other posts regarding this issue, however, I am unable to even get it to load for it to show up under "Programs".

    Repair your Apple software update.
    Go to START/ALL PROGRAMS/Apple Software Update. If it offers you a newer version of Apple Software Update, do it but Deselect any other software offered at the same time. Once done, try another iTunes install
    If you don't find ASU, go to Control Panel:
    START > CONTROL PANEL > Programs n Features / highlight ASU and click CHANGE then REPAIR,

Maybe you are looking for

  • Problems opening PDF files

    When I visit web sites using PDF I always have problems opening them. I get the following message each time: The Adobe Acrobat/Reader that is running can not be used to view PDF files in a web browser. Adobe Acrobat/Reader version 8 or 9 is required.

  • How do I import a bookmarks folder from another computer and add it to my existing list of bookmarks folders?

    I have two computers. One contains a folder of bookmarks that I want to transfer to the other computer and add it in. I don't want to replace all my bookmarks on the second computer with those from the first computer. How do I do this?

  • PC Crashes when iPhone docks

    I have a Dell M1210 notebook running WinXP(latested updates)with Norton Anti-Virus installed. The PC runs fine as does iTunes. Plug in the iPhone dock, all OK! Plug in the iPhone and just after recognizing the phone as a digicam, the whole system cra

  • Using or migrating Cognos Powerplay Cubes in/to Oracle OBIEE V 11.1.1

    Hello, is it possible somehow to use cognos cubes (used in Cognos Powerplay) in OBIEE out of the box? Or with some tricks? If not, is it possible somehow to do a elegant migration, without starting from the scratch? Any ideas or good links, informati

  • Characteristics value update in mass

    Hi Experts, I m seeking solution for characteristics value update in mass. We are already maintaining characteristics value for articles and now we have attached one additional characteristic value to article which need to be updated to all article.