Skip to content
Advertisement

Tag: awt

Java – FontMetrics without Graphics

How to get FontMetrics without use Graphics ? I want to get FontMetrics in constructor, now I do this way: Answer Hmm… It is quite logical that you need graphics to get FontMetrics. Font height, width etc. can differ on various displays. If you have some Component, you can use it for getting FontMetrics:

Why does my icon handling code throw a NullPointerException?

I have added an image for my button,but when I run that frame this exception will be thrown .why?please help me. line 138: line91: I use this poor checking (Peter Lang recommended)which is:System.out.println(getClass().getResource(“/Images/yahoo_1.gif”)); and it returns null,why? please help me. Answer This means, that getClass().getResource(“/Images/yahoo_1.gif”) returns null. JavaDoc states that this happens if the resource could not be found or

Advertisement