-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.2.0
-
generic
-
generic
Customer's report of the problem is as follows:
"I'm using an image in a button which may be wider than the button.
When doing this same thing in Marimba, it would adjust the image to fit into
the button. It looks like Swing just crops it off. Since in my case, the
graphics I need are aligned to the left of the image, I did a setHorizontalAlignment(LEFT) on the JButton but the left edge of the
Image was then moved almost to the center of the button leaving a big gap of plain background between the left edge of the image and the left edge of the
button. I was expecting the left edge of the Image to be aligned with the
left edge of the JButton."
I'm filing this bug so that we can have a reference for further investigation.
The following test case from Elizabeth Mezzias shows the problem:
import java.net.URL;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.applet.*;
import com.sun.java.swing.*;
import com.sun.java.swing.text.*;
/**
* A very simple applet.
*/
public class ButtonApplet extends JApplet
{
public ImageIcon button_icon;
public JButton b8;
public JTextPane textPane,textPane2,textPane3;
public void init()
{
try{
URL buttonURL = new URL(getDocumentBase(),"images/ps_button.gif");
button_icon = new ImageIcon(getImage(buttonURL));
}
catch (MalformedURLException e)
{
System.out.println("Malformed URL " + e);
}
b8 = new JButton(button_icon);
b8.setHorizontalAlignment(JButton.LEFT);
b8.setBounds(400,90,80,25);
getContentPane().add(b8);
}
}
"I'm using an image in a button which may be wider than the button.
When doing this same thing in Marimba, it would adjust the image to fit into
the button. It looks like Swing just crops it off. Since in my case, the
graphics I need are aligned to the left of the image, I did a setHorizontalAlignment(LEFT) on the JButton but the left edge of the
Image was then moved almost to the center of the button leaving a big gap of plain background between the left edge of the image and the left edge of the
button. I was expecting the left edge of the Image to be aligned with the
left edge of the JButton."
I'm filing this bug so that we can have a reference for further investigation.
The following test case from Elizabeth Mezzias shows the problem:
import java.net.URL;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.applet.*;
import com.sun.java.swing.*;
import com.sun.java.swing.text.*;
/**
* A very simple applet.
*/
public class ButtonApplet extends JApplet
{
public ImageIcon button_icon;
public JButton b8;
public JTextPane textPane,textPane2,textPane3;
public void init()
{
try{
URL buttonURL = new URL(getDocumentBase(),"images/ps_button.gif");
button_icon = new ImageIcon(getImage(buttonURL));
}
catch (MalformedURLException e)
{
System.out.println("Malformed URL " + e);
}
b8 = new JButton(button_icon);
b8.setHorizontalAlignment(JButton.LEFT);
b8.setBounds(400,90,80,25);
getContentPane().add(b8);
}
}