panel.getHeight(); panel.getPreferredSize().height;Don't seem to accurately report things: ``getHeight()`` is invariably zero, and ``getPreferredSize()`` returns numbers that don't actually have anything to do with the actual size of the panel. Any ideas? Edit: So, I took a debugger to the panel object and manually inspected the non-object properties and I didn't see anything that resembled width/height. Granted, there are sub-objects that I didn't look at. Also, maybe the window has to be visible (it isn't, at the point I'm interfacing the object) when I query for height/object? Edit 2: So, Swing classes are subclasses of AWT classes, so I imagine if you're able to find the height/width of those, the approach would generalize. I've amended the title accordingly.
以上就是Find "real" height/width of Swing/AWT object的详细内容，更多请关注web前端其它相关文章！