Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
8237746: Fixing compiler warnings in src/demo/share/jfc
Browse files Browse the repository at this point in the history
Reviewed-by: kizune, aivanov
  • Loading branch information
marchof authored and mrserb committed Mar 12, 2020
1 parent f3ef972 commit afe70e6
Show file tree
Hide file tree
Showing 40 changed files with 298 additions and 535 deletions.
8 changes: 4 additions & 4 deletions src/demo/share/jfc/FileChooserDemo/FileChooserDemo.java
Expand Up @@ -136,7 +136,7 @@ public String toString() {
private JRadioButton openRadioButton;
private JRadioButton saveRadioButton;
private JRadioButton customButton;
private JComboBox lafComboBox;
private JComboBox<SupportedLaF> lafComboBox;
private JRadioButton justFilesRadioButton;
private JRadioButton justDirectoriesRadioButton;
private JRadioButton bothFilesAndDirectoriesRadioButton;
Expand All @@ -158,7 +158,7 @@ public FileChooserDemo() {
for (UIManager.LookAndFeelInfo lafInfo : installedLafs) {
try {
Class<?> lnfClass = Class.forName(lafInfo.getClassName());
LookAndFeel laf = (LookAndFeel) (lnfClass.newInstance());
LookAndFeel laf = (LookAndFeel) (lnfClass.getDeclaredConstructor().newInstance());
if (laf.isSupportedLookAndFeel()) {
String name = lafInfo.getName();
SupportedLaF supportedLaF = new SupportedLaF(name, laf);
Expand Down Expand Up @@ -292,7 +292,7 @@ public Dimension getMaximumSize() {
showButton.setMnemonic('s');

// Create laf combo box
lafComboBox = new JComboBox(supportedLaFs.toArray());
lafComboBox = new JComboBox<>(supportedLaFs.toArray(new SupportedLaF[0]));
lafComboBox.setSelectedItem(nimbusLaF);
lafComboBox.setEditable(false);
lafComboBox.addActionListener(optionListener);
Expand Down Expand Up @@ -729,7 +729,7 @@ public void actionPerformed(ActionEvent e) {
frame.pack();
} catch (UnsupportedLookAndFeelException exc) {
// This should not happen because we already checked
((DefaultComboBoxModel) lafComboBox.getModel()).
((DefaultComboBoxModel<?>) lafComboBox.getModel()).
removeElement(supportedLaF);
}
}
Expand Down
45 changes: 22 additions & 23 deletions src/demo/share/jfc/Font2DTest/Font2DTest.java
Expand Up @@ -67,7 +67,6 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.EnumSet;
import java.util.StringTokenizer;
import java.util.BitSet;
import javax.swing.*;
Expand Down Expand Up @@ -101,8 +100,8 @@ public final class Font2DTest extends JPanel
private final ChoiceV2 transformMenu;
private final ChoiceV2 transformMenuG2;
private final ChoiceV2 methodsMenu;
private final JComboBox antiAliasMenu;
private final JComboBox fracMetricsMenu;
private final JComboBox<FontPanel.AAValues> antiAliasMenu;
private final JComboBox<FontPanel.FMValues> fracMetricsMenu;

private final JSlider contrastSlider;

Expand Down Expand Up @@ -151,10 +150,10 @@ public Font2DTest( JFrame f, boolean isApplet ) {
methodsMenu = new ChoiceV2( this );

antiAliasMenu =
new JComboBox(EnumSet.allOf(FontPanel.AAValues.class).toArray());
new JComboBox<>(FontPanel.AAValues.values());
antiAliasMenu.addActionListener(this);
fracMetricsMenu =
new JComboBox(EnumSet.allOf(FontPanel.FMValues.class).toArray());
new JComboBox<>(FontPanel.FMValues.values());
fracMetricsMenu.addActionListener(this);

contrastSlider = new JSlider(JSlider.HORIZONTAL, 100, 250,
Expand Down Expand Up @@ -359,7 +358,7 @@ private void setupDialog( boolean isApplet ) {
userTextDialog.pack();
userTextDialog.addWindowListener( new WindowAdapter() {
public void windowClosing( WindowEvent e ) {
userTextDialog.hide();
userTextDialog.setVisible(false);
}
});

Expand All @@ -385,7 +384,7 @@ public void windowClosing( WindowEvent e ) {
printDialog.setResizable( false );
printDialog.addWindowListener( new WindowAdapter() {
public void windowClosing( WindowEvent e ) {
printDialog.hide();
printDialog.setVisible(false);
}
});
printDialog.getContentPane().setLayout( new GridLayout( printModeCBs.length + 2, 1 ));
Expand All @@ -402,7 +401,7 @@ public void windowClosing( WindowEvent e ) {
fontInfoDialog.setResizable( false );
fontInfoDialog.addWindowListener( new WindowAdapter() {
public void windowClosing( WindowEvent e ) {
fontInfoDialog.hide();
fontInfoDialog.setVisible(false);
showFontInfoCBMI.setState( false );
}
});
Expand Down Expand Up @@ -467,7 +466,7 @@ private void setupFontList(int rangeStart, int rangeEnd) {
int style = fontStyles[styleMenu.getSelectedIndex()];
Font f;
for (int i = 0; i < listCount; i++) {
String fontName = (String)fontMenu.getItemAt(i);
String fontName = fontMenu.getItemAt(i);
f = new Font(fontName, style, size);
if ((rm.getSelectedIndex() != RangeMenu.SURROGATES_AREA_INDEX) &&
canDisplayRange(f, rangeStart, rangeEnd)) {
Expand Down Expand Up @@ -673,9 +672,9 @@ private void updateGUI() {

/// Set the visibility of User Text dialog
if ( selectedText == fp.USER_TEXT )
userTextDialog.show();
userTextDialog.setVisible(true);
else
userTextDialog.hide();
userTextDialog.setVisible(false);
/// Change the visibility/status/availability of Print JDialog buttons
printModeCBs[ fp.ONE_PAGE ].setSelected( true );
if ( selectedText == fp.FILE_TEXT || selectedText == fp.USER_TEXT ) {
Expand Down Expand Up @@ -793,10 +792,10 @@ private void loadOptions( String fileName ) {
lcdContrast, userTextOpt );
if ( showFontInfoOpt ) {
fireUpdateFontInfo();
fontInfoDialog.show();
fontInfoDialog.setVisible(true);
}
else
fontInfoDialog.hide();
fontInfoDialog.setVisible(false);
}
catch ( Exception ex ) {
fireChangeStatus( "ERROR: Failed to Load Options File; See Stack Trace", true );
Expand All @@ -819,7 +818,7 @@ public void windowClosing( WindowEvent e ) {
}
});
f.pack();
f.show();
f.setVisible(true);
}
catch ( Exception ex ) {
fireChangeStatus( "ERROR: Failed to Load PNG File; See Stack Trace", true );
Expand Down Expand Up @@ -861,7 +860,7 @@ else if ( itemName.equals( "Load PNG File to Compare..." )) {
else if ( itemName.equals( "Page Setup..." ))
fp.doPageSetup();
else if ( itemName.equals( "Print..." ))
printDialog.show();
printDialog.setVisible(true);
else if ( itemName.equals( "Close" ))
parent.dispose();
else if ( itemName.equals( "Exit" ))
Expand Down Expand Up @@ -893,19 +892,19 @@ else if ( source instanceof JButton ) {
if ( itemName.equals( "Print" )) {
for ( int i = 0; i < printModeCBs.length; i++ )
if ( printModeCBs[i].isSelected() ) {
printDialog.hide();
printDialog.setVisible(false);
fp.doPrint( i );
}
}
else if ( itemName.equals( "Cancel" ))
printDialog.hide();
printDialog.setVisible(false);
/// Update button from Usert Text JDialog...
else if ( itemName.equals( "Update" ))
fp.setTextToDraw( fp.USER_TEXT, null,
parseUserText( userTextArea.getText() ), null );
}
else if ( source instanceof JComboBox ) {
JComboBox c = (JComboBox) source;
JComboBox<?> c = (JComboBox<?>) source;

/// RangeMenu handles actions by itself and then calls fireRangeChanged,
/// so it is not listed or handled here
Expand Down Expand Up @@ -996,10 +995,10 @@ else if ( cbmi == force16ColsCBMI )
else if ( cbmi == showFontInfoCBMI ) {
if ( showFontInfoCBMI.getState() ) {
fireUpdateFontInfo();
fontInfoDialog.show();
fontInfoDialog.setVisible(true);
}
else
fontInfoDialog.hide();
fontInfoDialog.setVisible(false);
}
}
}
Expand Down Expand Up @@ -1039,7 +1038,7 @@ public static void main(String[] argv) {

f.getContentPane().add( f2dt );
f.pack();
f.show();
f.setVisible(true);
}

/// Inner class definitions...
Expand Down Expand Up @@ -1070,7 +1069,7 @@ public ButtonV2( String name, ActionListener al ) {
}
}

private final class ChoiceV2 extends JComboBox {
private final class ChoiceV2 extends JComboBox<String> {

private BitSet bitSet = null;

Expand Down Expand Up @@ -1141,7 +1140,7 @@ public ChoiceV2Renderer(ChoiceV2 choice) {
this.choice = choice;
}

public Component getListCellRendererComponent(JList list,
public Component getListCellRendererComponent(JList<?> list,
Object value,
int index,
boolean isSelected,
Expand Down
91 changes: 0 additions & 91 deletions src/demo/share/jfc/Font2DTest/Font2DTestApplet.java

This file was deleted.

0 comments on commit afe70e6

Please sign in to comment.