GetHeight(), getWidth(),,,

Advertisement
hi
Are thes values returned by the getHeight(), getWidth() and others methods in pixels or not ?
thank you
Advertisement

Replay

import java.awt.*;
import javax.swing.*;
public class Example {
    public static void main(String[] args) {
        JWindow w = new JWindow();
        JLabel label = new JLabel("just a label");
        w.getContentPane().add(label, BorderLayout.CENTER);
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gd = ge.getDefaultScreenDevice();
        try {
            gd.setFullScreenWindow(w);
            gd.setDisplayMode(new DisplayMode(640,480, 8, DisplayMode.REFRESH_RATE_UNKNOWN));
            System.out.println(label.getSize());
            try { Thread.sleep(2000); } catch(InterruptedException e) {}
            gd.setDisplayMode(new DisplayMode(800,600, 8, DisplayMode.REFRESH_RATE_UNKNOWN));
            System.out.println(label.getSize());
            try { Thread.sleep(2000); } catch(InterruptedException e) {}
        } finally {
            gd.setFullScreenWindow(null);
            System.exit(0);
}

Not able to get Image dimensions

I am using this code to get the java.awt.Image object Image inImage = Jimi.getImage(inputStream, Jimi.SYNCHRONOUS); I am using Jimi because I am running my code on jdk 1.3 and cannot use JAI. For some images, when I do inImage.getHeight(null); I get

Image getwidth() getheight() problem

When i run the code below first time it returns like; width=-1 height=-1 but when i refresh the page and runing code for secad time width and height returns correct; why this happen, i couldnt solve....need help,any advice?thank you Image resmim = To

Jpanel.getHeight() or getWidth returning 0?

I am not sure why they are doing that. I initially set the size of the panel to a specific height and width, wouldn't get height and get width return that height or width? My code is below... gameWindow()           super();           JButton button =

Applying color to grayscale bitmaps?

Hi, This is more of a "how does InDesing do it" kind of question vs scripting, but since the InDesign developers hop on here once and a while, I thought I'd ask.  How does InDesign colorize grayscale images - is it doing a HSL transformation on

Bilinear interpolation on single pixels

Hi friends, Could I ask a question about Bilinear interpolation on grayscale pixels. I scanned Point2D in a triangle on a grayscale image. Then I used PerspectiveTransform to get pixel position in target triangle. Now I am trying to use bilinear inte

Auto image size update

here is the code that displays an image...i want the size of the window that displays the image to automatically sized to the size of the image...any ideas ?? import javax.swing.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.

ScrollBars not showing up for the JPanel [urgent]

Hi, I have a frame in which i have two nested split panes i.e one horizontal splitpane and in that i am having one more split pane on the right side and a JTree on the left side.In the second split pane (which is a vertical split) ,as a top component

Display 2 images - one on top of the other

I am currently overriding paint and using createImage to pull images from files, and Graphics.drawImage to display the 2 images in a panel, with one completely on top of the other, obscuring it. There is a significant "flash" because it looks li

Changing size of the image

I am trying to change the size of an image using setPreferredSize(int width, int height) The API says that if the size specified is less than the minimum width and height, the minimum width and height is used. But they have told that if the width and

Can't run this bit of code

i cn't get this bit of code to work, it was working fine at home and now when i want to run it on another computer i can't, can anyone help me???? import javax.swing.*; import java.awt.*; import java.awt.event.*; public class TestCheckBox extends JPa

My appplets flicker

I have developed an applet which has an image in the background and there is another image over it, user can move the forground image by mouse, the problem is when the image is moved by the mouse , the background flicker as it is repainting. I am usi

May be silly mistake .... please help me

Hi Friends, I have jframe which contains a toggle button, when toggle button is pressed, I am trying to add a JText Field dynamically when user drags mouse. I am getting nullpointer exception. Can some one please tell me how can I solve this problem

Axis Network Camera Jpeg mess

I am trying to read the MJPGs from an Axis camera. I can get each image as a bufferedimage, but I need to also get them as a byte[] buffer. I need to pass on that byte[] buffer to other listeners. I am having a fun time trying to convert the image to

Image does not appear in applet.

I am reading the book, Teach Yourself Java in 21 Days. There is an example in Ch.11 that shows how to load an image into the applet. I have tried to use the code provided as is along with an image as defined in the code. I have also uploaded the html

Window works, fullscreen does not

Hi. I wrote a class representing a surface to do drawing operations on. It can display as a Window and in fullscreen. So the constructor is the really only method different from the rest of my aplication. But still, it doesnt work right: public Playg

How to Zoom the Image in JAI

Hi, I need to zoom the image during the each button click.I have done 1 program ,but i coulnt able to change the parameter block's value each time.Take this program and just change the pic's path and run it ll show the pic,smaller than its actual siz

Help with Creating a simple leaderboards

Hello, im new to java and im trying to make a simple leaderboards that just saves these messages in a new java class: g2.drawString("PLAYER " + winningPlayer + " WINS!", (this.getWidth() / 2), this.getHeight() / 2); g2.drawString("

Capturing an image from webcam

hi, i'm trying to capture a image from a webcam, but i don't have a clue of how to do this, could anyone help me with samples or books. thanks.hi so as i understood u want to access the USB and make whats called camera interaction i worked with my we

Component resize, paint and AffineTransform

Hello, I am resizing a JInternalFrame that contains a JPanel. When I call: MyJPanel.repaint();The paint function gets the dimensions of the JPanel using getWidth() and getHeight(), once, at the start of the paint function. The function then proceeds