Question about initial size of a JComponent

My project required drawing a fancy graph on a JComponent, which is then
added to a panel on a frame with gridbag layout. The JComponent's
paint() method relies on the size of the JComponent, or it's parent panel's size. The question is how to initialize the size of the component, as the preferred size of a JComponent is (0,0), and the panel's size can only be determined at run time. I already added component listener so that it resizes correctly when the frame is resized. But when the graph appears on the panel first time, it doesn't show itself according to the size of the panel. I have to manually resize the frame to make it fit.
The following are code fragments:
public class Graph extends JComponent
int m_width;
int m_height;
public Graph()
addComponentListener(new java.awt.event.ComponentAdapter()
public void componentResized(ComponentEvent e)
Dimension graph_size = getSize();
m_width = graph_size.width;
m_height = graph_size.height;
// tried but failed
// m_width = getPrefferedSize().width; m_height = ...
// m_width = getSize().width; m_height = ...
setSize(m_width, m_height); // how to initialize m_width, m_height?
public void paint(Graphics g)
m_width and m_height are frequently used here.

Thanks for your reply Nancy,
I understand the print resolution but I'm talking about on screen usage by browsers. I know that images are most optimized when the pixel resolution (number of pixels per side) is not more or less than the pixel resolution browsers display the image with. However with more and more monitors being produced with larger screens and denser ppi a lot of people, me included, zoom in with the browsers using Ctrl and Plus keys to see the content better. My monitor is displaying images not at approx 72 ppi but 110 ppi. This makes everything more than 30% smaller and although the text and images are much more sharper than monitors with less ppi, when things become too small they are hard to see regardless how sharp they are. For example this is how this page looks on my monitor at default view and full screen of the browser - the grey on the right is the background.
Have in mind that on monitors with ppi less than 110 the image above will appear larger than on my monitor. The next image shows the rulers in Photoshop equal the size of real life rulers on my monitor while the inclosed image shows rulers that are equal to real size ruler on another guy's monitor with less ppi screen resolution.
I'm not that much of a web developer but sometimes I design web pages in Photoshop and prepare images. So, based on my experience I'm thinking that more and more people would use browsers with zoomed in view at which case images with less pixels per side than the pixels of the monitor displaying them will look bad and I wonder if this can be avoided if the images are with larger resolution than the default view. Of course I realize that then at default view the images will not look as crisp as they could.

Similar Messages

  • 3 questions about texture sizes

    Hi there all,
    I have 3 questions about texture sizes. First off, after
    doing a search in this forum, I found out how to find the maxium
    texture size my hardware can handle. However, this is only
    currently tells me what the texture size I should use for my
    computer. So basically, what my first question is, I wanted to know
    what would be the average texture size for PC's. Why I ask this is
    because arfter doing the command that finds my maxium texture size
    that my computer can handle, it says that I can handle up to
    2048x2048, but this doesn't help if lets say the standard hardware
    texture size is 1024x1024.
    My second question is, when you speak in maxium hardware
    texture size terms, is this for per object, per scene that is
    loaded into memory, or for the entire game?
    ... and my last question is, does hardware texture size also
    include basic shaders as well (meaning with no textures)? If not is
    there a limit on that as well?

    1. If you know what maximum texturesize the endusers
    graficcard can handle, you can build a switch to different *.w3d
    files with that are saved with different texturesizes. you can see
    how the hardware variates:
    http://nuttybar.drama.uga.edu/pipermail/dir3d-l/2005-September/009554.html
    but don't forget that the macs are limited at the moment to a
    maximum texturesize of 512x512. If the textures are bigger then the
    maximum texturesize they are scaled down to it. In your example a
    texture that is 2048x2048 would be scaled down to 1048x1048 if this
    is the maximum texturesize of the endusers machine.
    2. The maximum texturesize is per Texture. But the Textures
    are stored uncompressed in the VRAM of the graficcard. There is no
    way to check how much RAM is left and i am not sure what happens if
    you put a lot of data in it.
    3. A shader only layers textures like photoshop and renderes
    them depending on the settings of the shader. The maximum hardware
    texture size only limits the size of the texture, if you use no
    textures in the shader (setting all texturelayers to void) the
    model will be only rendered depending on the values that are given
    by "ambient", "emissive", "diffuse", "specular"
    Just want to add here that textures should be in this sizes:
    1x1, 2x2, 4x4, 8x8, 16x16, 32x32, 64x64, 128x128, 256x256,
    512x512, 1024x1024, 2048x2048, 4096x4096 ...
    but can be also be combined like this:
    32x1024 or 512x256 and so on. this is just good to know.
    If textures do not fit into this grid of pixel values, the
    texture will be scaled up or down to the next size that is closest
    to it.
    if you type this code into the message window and execute
    every line, you can check the resulting texturesize.
    global pImage
    pImage=image(100, 1000, 24)
    member("world").newtexture("image", #fromimageobject, pImage)
    put member("world").texture("image").width
    -- 128
    put member("world").texture("image").height
    -- 1024
    This will happen to all textures if they enter the
    graficcard.

  • Question about the size af:inputText

    can <af:inputText> grow itself automatically to avoid scrollbar?
    if user types a long text into it, the inputtext area will become bigger to fit it to avoid scrollbar. is this possible?
    another question is,i found the size of this input area are controlled by 'rows' and 'columns'.
    can i make the inputtext area stretch to 100% width of the page?
    i cannot use 'columns' to accomplish this, since the page resolution is different for users. it works on 1440x900,but fails on others.
    thanks a lot
    -Ken

    cowbell bill wrote:
    Still stumped, I've deleted all unused audio files, deleted all unused midi. Maybe a third of the project. I see nothing in the trash, Project size is still the same 3.25 GB. Bypassed all reverbs, And audio CPU level still maxing out in the red. What am I doing wrong. Thanks Bill
    When you speak about project size, do you mean the size of the project file itself? Or of the entire project folder?
    When you delete tracks or plugins from your project, you won't see anything in the trash, that is normal. Only when you delete an audio file from your disk +from within Logic+ you'll find that audio file in the trash.

  • Question about "Print Size"

    I am confused and puzzled about "Print Size." First I select the Zoom Tool, then I click "Print Size" in the upper bar. I also have chosen View > Rulers.
    What I don't understand is that one inch in the horizontal ruler actually is considerably longer than one inch on the vertical ruler.  I think this is distorting the appearance on my photos in the monitor as compared with the actual prints. The monitor version of my portrait, for example, looks fatter than the printed version. Why is this and why isn't a horizontal inch equal to a verical inch for viewing purposes.
    Thank you very much for any help on this.
    Bob

    Thank you very much. I changed my monitor to its native resolution and I think this solved the problem.  Bob
    J Maloney <[email protected]> wrote:
    Change the screen resolution setting in your PS prefs to your display resolution. Then print size will work as expected.
    http://en.wikipedia.org/wiki/List_of_displays_by_pixel_density
    More about the print size feature:
    http://help.adobe.com/en_US/Photoshop/11.0/WSfd1234e1c4b69f30ea53e41001031ab64-7935a.html
    >

  • Question about the size of my project

    3.25 GB 20 or so tracks. a few plugins each a few software drums and synths. I getting overload warnings here and there. Not the I/O level the audio level. I look at the fear lilly Allen demo which has 50 tracks all sorts of plugins and a vid. 1.45 GB. I selected and deleted unused in audio bin and still the same. What am I missing. Logic Pro, IMAC 3.06 core 2 Duo 4 GB ram. Thanks Bill

    cowbell bill wrote:
    Still stumped, I've deleted all unused audio files, deleted all unused midi. Maybe a third of the project. I see nothing in the trash, Project size is still the same 3.25 GB. Bypassed all reverbs, And audio CPU level still maxing out in the red. What am I doing wrong. Thanks Bill
    When you speak about project size, do you mean the size of the project file itself? Or of the entire project folder?
    When you delete tracks or plugins from your project, you won't see anything in the trash, that is normal. Only when you delete an audio file from your disk +from within Logic+ you'll find that audio file in the trash.

  • Beginner question about the size of the documents and fonts

    I have worked with dps a couple of years now and now that Adobe removes Single Edition I have to look at other tools. EPUB3 fixed layout appears to be an alternative solution.
    I've been reading up on the web and checked on Lynda courses, but there is one thing I wonder about.
    How should I think about the size of the InDesign document and the size of the body text when I create a EPUB3 with fixed-layout?
    Regards
    Ake

    A couple things to keep in mind with EPUB3 Fixed Layout:
    Unlike EPUB reflowable, FXL doesn't change size. You'll need to optimize your InDesign layout for the device most likely to view it—for example, an iPad, since it's the dominant device.
    Like with DPS, you'll need to pick a font size larger than you'd use for print.
    As with DPS, it's very important to do some tests on your target device to optimize both dimensions and font size.
    Final Note: If you're in North America, this is a good time to  buy an iPad since there are a lot of Black Friday sales coming up!

  • Question about file size when using "Export for Web"

    Hi!
    I created a .mov file and worked to get a great balance between file size and quality so that I could deliver it via the web and make it easier for end users to see the video on a slower connection.
    My question: When I use "Export for Web," my .mov file is converted into a very large .m4v file--more than double the size of the original file. I know that this export option is to optimize the file for a wide variety of users/internet speeds. Am I correct in guessing that the end size is not an issue? I would post the .mov file instead, but I really like the option of embedding into a html page along with the "click to play" option.
    Bottom line--is it better to post the smaller .mov file that i originally started with or to go ahead and link to the bigger .m4v file that was created with the "Export for Web" option?

    "Export for Web" is a feature of QuickTime Pro and it makes 4 files and the html page code for easy copy/paste Web page editing.
    The very first file is called a "reference movie" and it links to the other 3 files (56kbps, 900kbps and 1.5Mbps). It, and the page code, "read" the connection speed of the viewing hardware and "serve up" the correct file based on that connection speed.
    In nearly all cases the "Desktop" version would still be smaller in file size than the original source. The times the file would "increase" in file size would be when an already compressed was used as the source file. You can find out more about your source file by opening it in QuickTime Player and viewing the Movie Inspector window information.
    There are dozens of other html "tricks" that could be used if your source file is already compressed but you want a different display size:
    Page code to show "aspect" or scale="tofit". This code allows values "outside" of those found in the actual QuickTime file be used for the Web page display. A 320X240 QuickTime .mov file looks pretty good at double size (640X480) but the file size would still be that of the source file.
    "Poster Movie" is another html trick that loads the Web based file directly in the QuickTime Player application (bypassing Web page layout restrictions). These files are also known as "Presentation Movies".
    Another method is the QuickTime Media Link file (.qtl). These are simple text based files that are used as a "direct link". These use simple XML (Extensible Markup Language) and are easily created in any text editing application. The simple syntax has amazing control over a simple QuickTime .mov file. You can launch (and quit) the QuickTime Player, display at other dimensions and even embed "links" inside the display.
    Some of my files as examples:
    http://homepage.mac.com/kkirkster/Lemon_Trees/ a "Poster Movie" style.
    http://homepage.mac.com/kkirkster/.Public/RedneckTexasChristmas.qtl
    A QuickTime Media Link file. A tiny file should download to the viewing machine, launch QuickTime Player, present the movie and it even includes a "link" to my Web page.
    Edit: It appears you must now double click the .qtl download to launch QuickTime.

  • Question about image size, canvas size and Picture frame

    Hi,
    This has always been a little confusing so let me describe what my question is:
    Assume I have a created a new PSD that is 8 1/2 x 11.
    The canvas size is the same 8 1/2 x 11.
    I want to put a border around the picture (say 1/2 of an inch all around), and put the finished picture in a Picture frame.  After it is in the frame, you would be able to see the entire picture plus the border.
    Q.  Should I change (reduce image size) of the PSD to (for this example), 8 x 10 1/2.      Then increase the canvas size to 8 1/2 x 11.  After I increased the canvas size, do a  Paint Bucket fill with white (to create the White border)?  then print the changed size PSD on 8 1/2 x 11 paper so that it will fit into a 8 1/2 x 11 picture frame
    I realize I could have just created the new PSD to be 8 x 10 1/2 in the first place.
    Hope I made this somewhat clear.
    Bob

    1: Decrease the size as you describe.
    2. Go to File>New or Ctrl N
    3. Make the box 8.5x11. Make sure the other data conforms to your image.
    4. Now,holding down Ctrl-Shift, Drag the image to the new box and release the mouse. Your image will be centered in the box.
    Note: there may be a method to do this including any adjustment layers, but I usually only do this as a last step, flattening a copy of the working file.

  • Question about iMovie Sizes

    How can you tell whether an iMovie project will fit on a DVD?
    I have been creating an iMovie project. With only about 30 or so still pix (with Ken Burns effect and transitions) the movie in the "Get Info" window already shows up as about 2 gigs. If I use low resolution pix (KB but without transitions), the file size is still about 650 megs, and the resolution is noticeably poorer.
    I plan a great many more photos and some video for my final DVD, but at this rate, I'll never make it.
    What are my choices? Does iDVD import the movie at a smaller file size?

    Thanks, everybody, that's helpful. My slide show will not be much over 30 - 45 minutes. If I understand you all correctly, I need not go to the trouble of shrinking my jpegs to meet size guidelines; iDVD will do that as needed.
    I did see the size info under "Project Info."
    The Best Performance/Best Quality choice looks like they're mixing apples and oranges, though.
    If I read the iDVD materials right, Best Performance speaks not to how well the finished DVD performs but how sluggish your machine will be while you work on the project. Best Quality, by contrast, has nothing to do with the process but rather the result.
    So, why wouldn't you turn on Best Performance while working, then turn on Best Quality when ready to burn? I know that also means burning the disk may take longer, but after all that work, it seems like a small price.

  • A question about clip size....

    This might be one of those REALLY stupid questions, but I've not seen anything about it in this forum.....
    First off, I have an iMac G5, with iLife 04. I've had decent luck with iMovie, but now I have a challenge. I'm a musician, and recently, an audience member taped a show of mine- it turned out pretty good. I played a little over an hour.
    Well- I know from past experience that when I load the video from the digital recorder into iMovie, clips will be no longer than 9:28.
    So my question: what's the best strategy to take for making an iMovie project so that each song is it's own clip/chapter? (of course, this is for the purpose of then making a dvd in iDvd... :)) Is there a way that I can, in real time while the footage is loading, "manually" insert where the clips should be with a keystroke or something like that? I suppose that I could pause the player at the end of each song and "force" iMovie to see it as a clip. But I'm thinking that would lead to a somewhat disjointed viewing experience...
    All apologies if this is a truly stupid question....
    Jeff

    Hi David,
    This is good information to know- thank you!
    Once the clips are in the viewer, would I be able to insert chapter points (like at the beginning of songs), or will there be an automatic chapter point every 9 minutes?

  • Getting iPhone on Wednesday.  Question about initial setup

    Hi,
    Tomorrow I should be receiving a reconditioned iPhone. The question I have is it possible to setup the iPhone and not have it copy all your address book from MS Outlook and your favorites from MS IE?
    I don't want to load it down with information that is not needed.
    Thanks,
    Al

    While you can avoid downloading all your contacts, you will find that the contacts take up about 1% of your 8GB. So I recommend installing the contacts and trying it out. You can always take them off at the next sync.
    I have over 2000 contacts by the way.

  • New to apple, question about font sizes on show bookmarks pages

    Former windows user, trying to get used to this beautiful new imac! When I am on the safari page, in the show all bookmarks page, the font is so small, and buttons to increase the size are disabled on the page! I know there must be a way to make the print bigger but how?
    Thanks to all.. I think I'm learning more from reading these forums than with all the help pages.

    Very sound advice (as always) Barry.
    I (very briefly) considered offering the Terminal/Defaults route, but thought that Safari Enhancer was the lesser of two evils. Safari Enh does not need to be kept running after changes (like the bookmark font size) are made. & I believe most of it's functions within Safari are made by simply altering the plist file - so getting back a default configuration is very simple.... just reset safari.
    keveliz : Barry's is good advice. I wouldn't put safari enhancer in the " ...here be dragons" or 'addicted to haxies' class myself... because it's just a program that you run & close afterwards - it doesn't carry on, (possibly) brewing trouble in the background.
    I haven't been using Apples even a year now - but pc's & 6502 / 6800 & onwards micros since err, 1980..... & fwiw I personally think safari-enh is much safer than most 3rd party fixers ( which isn't saying much! - so Yep, I'd recommend it based on my usage )- there's good support, a useful discussions forum; although previous versions ( presumably sorted now?) could be annoying due to setting non-std options that you hadn't specifically checked - a problem if you're just starting & you wouldn't know what was a default setting & what wasn't.
    None of which is intended to disagree with Barry's note of caution - be careful out there.

  • Question about initial installation: WRT54GS

    Greetings!
    I am trying to install a WRT54GS... I have a Motorola SBV4200 Cable Modem (using RoadRunner) hooked into my desk-top PC...
    Here's what I'm finding:
    I plug everything in, and hit the "Secure Easy Setup" button on the Linksys, and then my laptop finds the signal, and everything's great - I get a super strong signal, and everything's hunky-dory.
    A minute or two later, however, the laptop loses that signal, and switches over to a REALLY weak signal from outside somewhere.  The Linksys signal isn't even seen by the laptop. (i.e. - it's not on the "Available Wireless Network Connections" list)
    So I started reading these boards, thinking that maybe I could find out what was going on... I thought that maybe RoadRunner has a dynamic IP Address, and that when it changed, the LinkSys and the laptop just weren't speaking anymore... So I followed everyone's reccommendations to go check the default IP  for the two...
    Here's where the next problem occurs... I tried to go to 192.168.1.1, and of course I got to the Username/Password sign in... I left the Username empty, and used "admin" for the password...
    Nothing...
    Tried EVERYTHING - Admin, ADMIN, admin, Administrator, default, DEFAULT, tried putting stuff in for the username, EVERYTHING (or at least everyhting i could think of...
    I tried resetting the LinkSys, and re-tried all those things again... Nuthin'
    Does anyone out there have any ideas where to go next?  Like i said - it's frustrating because the thing works... for about a minute.
    The nice thing is that the guy across the street is an IT guy for a HUGE company (one of the biggest in the state) - and he was stumped too!  So I know it's not just me...
    HELP!?!
    Thanks all -
    Tom

    Make sure you're hard-wired to the router when you try to access it's address.
    Check also if all LEDs are lit up properly. Power LED should always be solid.
    Check if the router's still giving you an IP address.

  • Question about page sizes

    I received a PDF file that should have letter sized pages 8.5 inches by 11 inches. The page size in the lower left hand corner says that the pages are 35.42 inches by 45.69 inches or approximately 4 times the normal size. The file is readable at 31%, but I cannot print it out. Only the center portion of the page prints. Is there a way to reduce the page back down to 8.5 by 11? The sender and I are both using adobe accrobat 8.

    George,
    Thank you so much for your prompt response. I found this out by chance late last night.
    Thank you again,
    Joe Osterfeld
    Joe Osterfeld CPA

  • Questions about the size of x-fi ca

    I recently orderd a dell d/dock for my laptop and I am aware that it is possible to plug in an x-fi xtreame music card into its PCI slot, but I was wondering if the x-fi platinum is the same size as the xtreame music version? and also if it works properly without the I/O bay plugged in, since there would be no room for that in the d/dock.
    thanks for your help.

    Yes the Xtreme Music and Platinum use the exact same PCB. The difference is tha dri've bay, which doesn't affect functionality of the card if connected or not.

Maybe you are looking for

  • How do I delete photos that have been imported from my computor

    I have tried everything but nothing seems to work in trying to clear my iphone of photos imported from my computor in error. Any help would be grateful. I am not very good with computors etc.!!!

  • Wired guest access with 5508

    Hi I have setup wireless guest access for a customer with a single 5508 and web authentication no problem at all. He then wanted to test wired guest access. The 5508 is currently connected to a single 3560 switch. The wired clients get a DHCP address

  • Process order instruction sheet

    I am creating a process order instruction sheet from transaction COHVPI and CO02. How do i check the standard SAPSCRIPT that is being printed ?? and also the PRINTPROGRAM ???

  • Error during startsap all

    Hi, I am starting the services using startsap all command in IBM aix server oracle 10g. i am getting belo error message. Wed Sep 23 15:50:38 IST 2009 LOGFILE FOR STARTING ORACLE Trying to start KBP database ... Wed Sep 23 15:50:38 IST 2009 checking r

  • WRT54G Ver 1.1 Firmware Upgrade

    I was experiencing some connection problems that were causing me to cycle the power on my router a few times a week. I decided to upgrade the firmware to 4.21.1 hoping to resolve this issue. The firmware upgrade completed and all configuration settin