Results 1 to 9 of 9
- 11-04-2008, 11:55 PM #1
Member
- Join Date
- Nov 2008
- Posts
- 4
- Rep Power
- 0
- 11-05-2008, 12:02 AM #2
Are those methods your talking about? What class are they defined in? Sun's API doc will tell you how to use them and what they return when called.
What is the "forumla" that you mention?
- 11-05-2008, 12:13 AM #3
Member
- Join Date
- Nov 2008
- Posts
- 4
- Rep Power
- 0
they are methods. Im not etirely sure what class they are supposed to be defined in a class I created but im notsure how touse them, and forget i mentioneda formula... i just ment that i wanted a generic explanation.
- 11-05-2008, 12:16 AM #4
Member
- Join Date
- Nov 2008
- Posts
- 4
- Rep Power
- 0
what i am tryingto do is figure out the width and height ofa picture so i can change the borders of the picture.
- 11-05-2008, 12:22 AM #5
Where is the picture? In a disk file like a .jpg? Have you read it into an Image object?
How are you accessing the borders to be able to change them?
Are you writing a class with the get methods? If you don't know what height and width mean, I don't know what to say. That's a pretty basic concept when describing rectangular shapes.
- 11-05-2008, 03:51 AM #6
what i am tryingto do is figure out the width and height ofa picture so i can change the borders of the picture.
The abstract Image class has getWidth and getHeight methods that have a single parameter (which can be null).
The BufferedImage class has getWidth and getHeight methods.
If your image is mounted in a JLabel you can use the JLabel method getIcon and with it use the Icon methods getIconWidth and getIconHeight.
Java Code:import java.awt.image.BufferedImage; import java.io.IOException; import java.net.URL; import javax.swing.*; public class WidthAndHeight { public static void main(String[] args) throws IOException { String path = "http://www.java-forums.org/images/ca_evo/misc/logo.gif"; URL url = new URL(path); BufferedImage image = javax.imageio.ImageIO.read(url); int width = image.getWidth(); int height = image.getHeight(); System.out.printf("width = %d height = %d%n", width, height); JOptionPane.showMessageDialog(null, new ImageIcon(image), "logo", JOptionPane.PLAIN_MESSAGE); } }
- 11-05-2008, 11:00 PM #7
Member
- Join Date
- Nov 2008
- Posts
- 4
- Rep Power
- 0
thanks forthe help hardwired. And thanks for trying norm :)
Last edited by Neomus; 11-05-2008 at 11:20 PM.
- 11-25-2010, 10:35 AM #8
Member
- Join Date
- Nov 2010
- Posts
- 1
- Rep Power
- 0
i want to change the icon of JOptionpane........Plz help me
-
Similar Threads
-
Img.getWidth(null); gives -1 why?
By willemjav in forum New To JavaReplies: 0Last Post: 02-15-2008, 02:06 PM


LinkBack URL
About LinkBacks


Bookmarks