Skip to content

Commit

Permalink
Replace 'new ImageIcon' with ImageUtilities.loadIcon in a few Swing f…
Browse files Browse the repository at this point in the history
…orms that were constructed with the Matisse form builder.

(To render at full HiDPI resolution, Icon/Image instances must be created via the methods in ImageUtilities rather than, in particular, the constructors of ImageIcon.)

These cases were put in a separate commit since they involved re-generation of auto-generated code. To keep the patch simple, I excluded some reformatting of unrelated code that Matisse did when regenerating initComponents().
  • Loading branch information
eirikbakke committed Jan 25, 2025
1 parent d58a1b6 commit 5d2e131
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
</Component>
<Component class="javax.swing.JButton" name="stopButton">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/org/netbeans/modules/jshell/resources/stop.png"/>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="ImageUtilities.loadIcon(&quot;org/netbeans/modules/jshell/resources/stop.png&quot;)" type="code"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/netbeans/modules/jshell/editor/Bundle.properties" key="ExecutingGlassPanel.stopButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;

/**
Expand Down Expand Up @@ -77,7 +78,7 @@ private void initComponents() {
));
org.openide.awt.Mnemonics.setLocalizedText(msgLabel, org.openide.util.NbBundle.getMessage(ExecutingGlassPanel.class, "ExecutingGlassPanel.msgLabel.text")); // NOI18N

stopButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/jshell/resources/stop.png"))); // NOI18N
stopButton.setIcon(ImageUtilities.loadIcon("org/netbeans/modules/jshell/resources/stop.png"));
org.openide.awt.Mnemonics.setLocalizedText(stopButton, org.openide.util.NbBundle.getMessage(ExecutingGlassPanel.class, "ExecutingGlassPanel.stopButton.text")); // NOI18N
stopButton.setBorder(null);
stopButton.setBorderPainted(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
<Component class="javax.swing.JLabel" name="springNotOnClassPathLabel">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new ImageIcon(ImageUtilities.loadImage(&quot;org/netbeans/modules/spring/beans/resources/warning.gif&quot;)) " type="code"/>
<Connection code="ImageUtilities.loadIcon(&quot;org/netbeans/modules/spring/beans/resources/warning.gif&quot;)" type="code"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/netbeans/modules/spring/beans/wizards/Bundle.properties" key="LBL_SpringNotOnClassPath" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
}
});

springNotOnClassPathLabel.setIcon(new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/spring/beans/resources/warning.gif")) );
springNotOnClassPathLabel.setIcon(ImageUtilities.loadIcon("org/netbeans/modules/spring/beans/resources/warning.gif"));
org.openide.awt.Mnemonics.setLocalizedText(springNotOnClassPathLabel, org.openide.util.NbBundle.getMessage(SpringXMLConfigNamespacesVisual.class, "LBL_SpringNotOnClassPath")); // NOI18N

cbSpringVersion.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "No Library found" }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@
<SubComponents>
<Component class="javax.swing.JButton" name="diffButton">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/org/netbeans/modules/php/project/ui/resources/diff.png"/>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="ImageUtilities.loadIcon(&quot;org/netbeans/modules/php/project/ui/resources/diff.png&quot;)" type="code"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ private void initComponents() {
.addGap(5, 5, 5))
);

diffButton.setIcon(new ImageIcon(getClass().getResource("/org/netbeans/modules/php/project/ui/resources/diff.png"))); // NOI18N
diffButton.setIcon(ImageUtilities.loadIcon("org/netbeans/modules/php/project/ui/resources/diff.png"));
diffButton.setEnabled(false);
operationButtonsPanel.add(diffButton);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@
</Container>
<Component class="javax.swing.JButton" name="addButton">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/org/netbeans/modules/web/clientproject/ui/resources/add.png"/>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="ImageUtilities.loadIcon(&quot;org/netbeans/modules/web/clientproject/ui/resources/add.png&quot;)" type="code"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/netbeans/modules/web/clientproject/build/ui/Bundle.properties" key="AdvancedTasksPanel.addButton.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
Expand All @@ -144,8 +144,8 @@
</Component>
<Component class="javax.swing.JButton" name="removeButton">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/org/netbeans/modules/web/clientproject/ui/resources/remove.png"/>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="ImageUtilities.loadIcon(&quot;org/netbeans/modules/web/clientproject/ui/resources/remove.png&quot;)" type="code"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/netbeans/modules/web/clientproject/build/ui/Bundle.properties" key="AdvancedTasksPanel.removeButton.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
Expand All @@ -157,8 +157,8 @@
</Component>
<Component class="javax.swing.JButton" name="upButton">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/org/netbeans/modules/web/clientproject/ui/resources/up.png"/>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="ImageUtilities.loadIcon(&quot;org/netbeans/modules/web/clientproject/ui/resources/up.png&quot;)" type="code"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/netbeans/modules/web/clientproject/build/ui/Bundle.properties" key="AdvancedTasksPanel.upButton.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
Expand All @@ -170,8 +170,8 @@
</Component>
<Component class="javax.swing.JButton" name="downButton">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/org/netbeans/modules/web/clientproject/ui/resources/down.png"/>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="ImageUtilities.loadIcon(&quot;org/netbeans/modules/web/clientproject/ui/resources/down.png&quot;)" type="code"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/netbeans/modules/web/clientproject/build/ui/Bundle.properties" key="AdvancedTasksPanel.downButton.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListCellRenderer;
import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
Expand All @@ -60,6 +59,7 @@
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.awt.Mnemonics;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;


Expand Down Expand Up @@ -334,31 +334,31 @@ private void initComponents() {
tasksList.setMinimumSize(new Dimension(60, 80));
tasksScrollPane.setViewportView(tasksList);

addButton.setIcon(new ImageIcon(getClass().getResource("/org/netbeans/modules/web/clientproject/ui/resources/add.png"))); // NOI18N
addButton.setIcon(ImageUtilities.loadIcon("org/netbeans/modules/web/clientproject/ui/resources/add.png"));
addButton.setToolTipText(NbBundle.getMessage(AdvancedTasksPanel.class, "AdvancedTasksPanel.addButton.toolTipText")); // NOI18N
addButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
addButtonActionPerformed(evt);
}
});

removeButton.setIcon(new ImageIcon(getClass().getResource("/org/netbeans/modules/web/clientproject/ui/resources/remove.png"))); // NOI18N
removeButton.setIcon(ImageUtilities.loadIcon("org/netbeans/modules/web/clientproject/ui/resources/remove.png"));
removeButton.setToolTipText(NbBundle.getMessage(AdvancedTasksPanel.class, "AdvancedTasksPanel.removeButton.toolTipText")); // NOI18N
removeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
removeButtonActionPerformed(evt);
}
});

upButton.setIcon(new ImageIcon(getClass().getResource("/org/netbeans/modules/web/clientproject/ui/resources/up.png"))); // NOI18N
upButton.setIcon(ImageUtilities.loadIcon("org/netbeans/modules/web/clientproject/ui/resources/up.png"));
upButton.setToolTipText(NbBundle.getMessage(AdvancedTasksPanel.class, "AdvancedTasksPanel.upButton.toolTipText")); // NOI18N
upButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
upButtonActionPerformed(evt);
}
});

downButton.setIcon(new ImageIcon(getClass().getResource("/org/netbeans/modules/web/clientproject/ui/resources/down.png"))); // NOI18N
downButton.setIcon(ImageUtilities.loadIcon("org/netbeans/modules/web/clientproject/ui/resources/down.png"));
downButton.setToolTipText(NbBundle.getMessage(AdvancedTasksPanel.class, "AdvancedTasksPanel.downButton.toolTipText")); // NOI18N
downButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Expand Down

0 comments on commit 5d2e131

Please sign in to comment.