-
Bug
-
Resolution: Not an Issue
-
P3
-
9
mport java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
Reporter ofJDK-8174845 verified the bug and reported the following issue:
The problem is only partially solved. A toolbar button with an ImageIcon is
wrong scaled.
We use the follow simple test program (binary attached). Currently we see no
option to prevent this. Is there a new API?
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JToolBar;
public class Main {
public static void main(String[] args) {
JToolBar toolbar = new JToolBar();
toolbar.add( new JButton(new AbstractAction( "", new
ImageIcon(Main.class.getResource("icon.gif")) ) {
@Override
public void actionPerformed(ActionEvent e) {
}
}) );
toolbar.add( new JButton(new AbstractAction( "", new
ImageIcon(Main.class.getResource("icon2.gif")) ) {
@Override
public void actionPerformed(ActionEvent e) {
}
}) );
toolbar.add( new JButton(new AbstractAction( "", new
ImageIcon(Main.class.getResource("icon3.gif")) ) {
@Override
public void actionPerformed(ActionEvent e) {
}
}) );
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(toolbar, BorderLayout.NORTH);
frame.setSize(800, 600);
frame.setVisible(true);
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
Reporter of
The problem is only partially solved. A toolbar button with an ImageIcon is
wrong scaled.
We use the follow simple test program (binary attached). Currently we see no
option to prevent this. Is there a new API?
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JToolBar;
public class Main {
public static void main(String[] args) {
JToolBar toolbar = new JToolBar();
toolbar.add( new JButton(new AbstractAction( "", new
ImageIcon(Main.class.getResource("icon.gif")) ) {
@Override
public void actionPerformed(ActionEvent e) {
}
}) );
toolbar.add( new JButton(new AbstractAction( "", new
ImageIcon(Main.class.getResource("icon2.gif")) ) {
@Override
public void actionPerformed(ActionEvent e) {
}
}) );
toolbar.add( new JButton(new AbstractAction( "", new
ImageIcon(Main.class.getResource("icon3.gif")) ) {
@Override
public void actionPerformed(ActionEvent e) {
}
}) );
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(toolbar, BorderLayout.NORTH);
frame.setSize(800, 600);
frame.setVisible(true);