Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8183289

Bad image scaling on Windows on hidpi display with Java 9ea

XMLWordPrintable

    • 2d

      mport java.awt.BorderLayout;
      import java.awt.event.ActionEvent;

      import javax.swing.AbstractAction;
      Reporter of JDK-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);

            prr Philip Race
            shadowbug Shadow Bug
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: