Skip to content

Commit c01cb45

Browse files
committed
Replace 'new ImageIcon' with ImageUtilities.loadIcon in a few Swing forms 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().
1 parent aa80a48 commit c01cb45

8 files changed

Lines changed: 22 additions & 21 deletions

File tree

java/jshell.support/src/org/netbeans/modules/jshell/editor/ExecutingGlassPanel.form

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@
7474
</Component>
7575
<Component class="javax.swing.JButton" name="stopButton">
7676
<Properties>
77-
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
78-
<Image iconType="3" name="/org/netbeans/modules/jshell/resources/stop.png"/>
77+
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
78+
<Connection code="ImageUtilities.loadIcon(&quot;org/netbeans/modules/jshell/resources/stop.png&quot;)" type="code"/>
7979
</Property>
8080
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
8181
<ResourceString bundle="org/netbeans/modules/jshell/editor/Bundle.properties" key="ExecutingGlassPanel.stopButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>

java/jshell.support/src/org/netbeans/modules/jshell/editor/ExecutingGlassPanel.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import java.awt.event.ActionListener;
2222
import javax.swing.ImageIcon;
23+
import org.openide.util.ImageUtilities;
2324
import org.openide.util.NbBundle;
2425

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

80-
stopButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/jshell/resources/stop.png"))); // NOI18N
81+
stopButton.setIcon(ImageUtilities.loadIcon("org/netbeans/modules/jshell/resources/stop.png"));
8182
org.openide.awt.Mnemonics.setLocalizedText(stopButton, org.openide.util.NbBundle.getMessage(ExecutingGlassPanel.class, "ExecutingGlassPanel.stopButton.text")); // NOI18N
8283
stopButton.setBorder(null);
8384
stopButton.setBorderPainted(false);

java/spring.beans/src/org/netbeans/modules/spring/beans/wizards/SpringXMLConfigNamespacesVisual.form

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
<Component class="javax.swing.JLabel" name="springNotOnClassPathLabel">
135135
<Properties>
136136
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
137-
<Connection code="new ImageIcon(ImageUtilities.loadImage(&quot;org/netbeans/modules/spring/beans/resources/warning.gif&quot;)) " type="code"/>
137+
<Connection code="ImageUtilities.loadIcon(&quot;org/netbeans/modules/spring/beans/resources/warning.gif&quot;)" type="code"/>
138138
</Property>
139139
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
140140
<ResourceString bundle="org/netbeans/modules/spring/beans/wizards/Bundle.properties" key="LBL_SpringNotOnClassPath" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>

java/spring.beans/src/org/netbeans/modules/spring/beans/wizards/SpringXMLConfigNamespacesVisual.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
140140
}
141141
});
142142

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

146146
cbSpringVersion.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "No Library found" }));

php/php.project/src/org/netbeans/modules/php/project/connections/sync/SyncPanel.form

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,8 @@
325325
<SubComponents>
326326
<Component class="javax.swing.JButton" name="diffButton">
327327
<Properties>
328-
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
329-
<Image iconType="3" name="/org/netbeans/modules/php/project/ui/resources/diff.png"/>
328+
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
329+
<Connection code="ImageUtilities.loadIcon(&quot;org/netbeans/modules/php/project/ui/resources/diff.png&quot;)" type="code"/>
330330
</Property>
331331
<Property name="enabled" type="boolean" value="false"/>
332332
</Properties>

php/php.project/src/org/netbeans/modules/php/project/connections/sync/SyncPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ private void initComponents() {
12381238
.addGap(5, 5, 5))
12391239
);
12401240

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

webcommon/web.clientproject.api/src/org/netbeans/modules/web/clientproject/build/ui/AdvancedTasksPanel.form

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@
131131
</Container>
132132
<Component class="javax.swing.JButton" name="addButton">
133133
<Properties>
134-
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
135-
<Image iconType="3" name="/org/netbeans/modules/web/clientproject/ui/resources/add.png"/>
134+
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
135+
<Connection code="ImageUtilities.loadIcon(&quot;org/netbeans/modules/web/clientproject/ui/resources/add.png&quot;)" type="code"/>
136136
</Property>
137137
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
138138
<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;)"/>
@@ -144,8 +144,8 @@
144144
</Component>
145145
<Component class="javax.swing.JButton" name="removeButton">
146146
<Properties>
147-
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
148-
<Image iconType="3" name="/org/netbeans/modules/web/clientproject/ui/resources/remove.png"/>
147+
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
148+
<Connection code="ImageUtilities.loadIcon(&quot;org/netbeans/modules/web/clientproject/ui/resources/remove.png&quot;)" type="code"/>
149149
</Property>
150150
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
151151
<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;)"/>
@@ -157,8 +157,8 @@
157157
</Component>
158158
<Component class="javax.swing.JButton" name="upButton">
159159
<Properties>
160-
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
161-
<Image iconType="3" name="/org/netbeans/modules/web/clientproject/ui/resources/up.png"/>
160+
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
161+
<Connection code="ImageUtilities.loadIcon(&quot;org/netbeans/modules/web/clientproject/ui/resources/up.png&quot;)" type="code"/>
162162
</Property>
163163
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
164164
<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;)"/>
@@ -170,8 +170,8 @@
170170
</Component>
171171
<Component class="javax.swing.JButton" name="downButton">
172172
<Properties>
173-
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
174-
<Image iconType="3" name="/org/netbeans/modules/web/clientproject/ui/resources/down.png"/>
173+
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
174+
<Connection code="ImageUtilities.loadIcon(&quot;org/netbeans/modules/web/clientproject/ui/resources/down.png&quot;)" type="code"/>
175175
</Property>
176176
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
177177
<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;)"/>

webcommon/web.clientproject.api/src/org/netbeans/modules/web/clientproject/build/ui/AdvancedTasksPanel.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import javax.swing.DefaultComboBoxModel;
3636
import javax.swing.DefaultListCellRenderer;
3737
import javax.swing.GroupLayout;
38-
import javax.swing.ImageIcon;
3938
import javax.swing.JButton;
4039
import javax.swing.JCheckBox;
4140
import javax.swing.JComboBox;
@@ -60,6 +59,7 @@
6059
import org.openide.DialogDisplayer;
6160
import org.openide.NotifyDescriptor;
6261
import org.openide.awt.Mnemonics;
62+
import org.openide.util.ImageUtilities;
6363
import org.openide.util.NbBundle;
6464

6565

@@ -334,31 +334,31 @@ private void initComponents() {
334334
tasksList.setMinimumSize(new Dimension(60, 80));
335335
tasksScrollPane.setViewportView(tasksList);
336336

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

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

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

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

0 commit comments

Comments
 (0)