--- old/src/demo/share/jfc/FileChooserDemo/FileChooserDemo.java 2020-01-22 16:03:15.000000000 -0800 +++ new/src/demo/share/jfc/FileChooserDemo/FileChooserDemo.java 2020-01-22 16:03:14.000000000 -0800 @@ -136,7 +136,7 @@ private JRadioButton openRadioButton; private JRadioButton saveRadioButton; private JRadioButton customButton; - private JComboBox lafComboBox; + private JComboBox lafComboBox; private JRadioButton justFilesRadioButton; private JRadioButton justDirectoriesRadioButton; private JRadioButton bothFilesAndDirectoriesRadioButton; @@ -158,7 +158,7 @@ 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); @@ -292,7 +292,7 @@ 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); @@ -729,7 +729,7 @@ frame.pack(); } catch (UnsupportedLookAndFeelException exc) { // This should not happen because we already checked - ((DefaultComboBoxModel) lafComboBox.getModel()). + ((DefaultComboBoxModel) lafComboBox.getModel()). removeElement(supportedLaF); } } --- old/src/demo/share/jfc/Font2DTest/Font2DTest.java 2020-01-22 16:03:16.000000000 -0800 +++ new/src/demo/share/jfc/Font2DTest/Font2DTest.java 2020-01-22 16:03:16.000000000 -0800 @@ -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.*; @@ -101,8 +100,8 @@ private final ChoiceV2 transformMenu; private final ChoiceV2 transformMenuG2; private final ChoiceV2 methodsMenu; - private final JComboBox antiAliasMenu; - private final JComboBox fracMetricsMenu; + private final JComboBox antiAliasMenu; + private final JComboBox fracMetricsMenu; private final JSlider contrastSlider; @@ -151,10 +150,10 @@ 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, @@ -359,7 +358,7 @@ userTextDialog.pack(); userTextDialog.addWindowListener( new WindowAdapter() { public void windowClosing( WindowEvent e ) { - userTextDialog.hide(); + userTextDialog.setVisible(false); } }); @@ -385,7 +384,7 @@ 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 )); @@ -402,7 +401,7 @@ fontInfoDialog.setResizable( false ); fontInfoDialog.addWindowListener( new WindowAdapter() { public void windowClosing( WindowEvent e ) { - fontInfoDialog.hide(); + fontInfoDialog.setVisible(false); showFontInfoCBMI.setState( false ); } }); @@ -467,7 +466,7 @@ 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)) { @@ -673,9 +672,9 @@ /// 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 ) { @@ -793,10 +792,10 @@ 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 ); @@ -819,7 +818,7 @@ } }); f.pack(); - f.show(); + f.setVisible(true); } catch ( Exception ex ) { fireChangeStatus( "ERROR: Failed to Load PNG File; See Stack Trace", true ); @@ -861,7 +860,7 @@ 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" )) @@ -893,19 +892,19 @@ 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 @@ -996,10 +995,10 @@ else if ( cbmi == showFontInfoCBMI ) { if ( showFontInfoCBMI.getState() ) { fireUpdateFontInfo(); - fontInfoDialog.show(); + fontInfoDialog.setVisible(true); } else - fontInfoDialog.hide(); + fontInfoDialog.setVisible(false); } } } @@ -1039,7 +1038,7 @@ f.getContentPane().add( f2dt ); f.pack(); - f.show(); + f.setVisible(true); } /// Inner class definitions... @@ -1070,7 +1069,7 @@ } } - private final class ChoiceV2 extends JComboBox { + private final class ChoiceV2 extends JComboBox { private BitSet bitSet = null; @@ -1141,7 +1140,7 @@ this.choice = choice; } - public Component getListCellRendererComponent(JList list, + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, --- old/src/demo/share/jfc/Font2DTest/FontPanel.java 2020-01-22 16:03:17.000000000 -0800 +++ new/src/demo/share/jfc/Font2DTest/FontPanel.java 2020-01-22 16:03:17.000000000 -0800 @@ -392,7 +392,7 @@ setTransformG2( g2transform ); // ABP setDrawMethod( method ); setRenderingHints(AAValues.getValue(aa), FMValues.getValue(fm), - new Integer(contrast)); + Integer.valueOf(contrast)); } /// Writes the current screen to PNG file @@ -434,7 +434,7 @@ private int canvasInset_X = 5, canvasInset_Y = 5; /// LineBreak'ed TextLayout vector - private Vector lineBreakTLs = null; + private Vector lineBreakTLs = null; /// Whether the current draw command requested is for printing private boolean isPrinting = false; @@ -800,7 +800,7 @@ if ( textToUse == FILE_TEXT ) { if ( !isPrinting ) f2dt.fireChangeStatus( "LineBreaking Text... Please Wait", false ); - lineBreakTLs = new Vector(); + lineBreakTLs = new Vector<>(); for ( int i = 0; i < fileText.length; i++ ) { AttributedString as = new AttributedString( fileText[i], g2.getFont().getAttributes() ); @@ -929,7 +929,7 @@ float xPos, yPos = (float) canvasInset_Y; g2.drawRect( 0, 0, w - 1, h - 1 ); for ( int i = drawStart; i <= drawEnd; i++ ) { - TextLayout oneLine = (TextLayout) lineBreakTLs.elementAt( i ); + TextLayout oneLine = lineBreakTLs.elementAt( i ); xPos = oneLine.isLeftToRight() ? canvasInset_X : ( (float) w - oneLine.getAdvance() - canvasInset_X ); @@ -992,9 +992,9 @@ /// Back up metrics and other drawing info before printing modifies it int backupDrawStart = drawStart, backupDrawEnd = drawEnd; int backupNumCharAcross = numCharAcross, backupNumCharDown = numCharDown; - Vector backupLineBreakTLs = null; + Vector backupLineBreakTLs = null; if ( textToUse == FILE_TEXT ) - backupLineBreakTLs = (Vector) lineBreakTLs.clone(); + backupLineBreakTLs = new Vector<>(lineBreakTLs); printPageNumber = pageIndex; isPrinting = true; @@ -1137,7 +1137,7 @@ zoomAreaWidth / 2, (int) ( maxAscent * ZOOM )); g2.dispose(); if ( !nowZooming ) - zoomWindow.show(); + zoomWindow.setVisible(true); /// This is sort of redundant... since there is a paint function /// inside zoomWindow definition that does the drawImage. /// (I should be able to call just repaint() here) @@ -1176,7 +1176,7 @@ public void mouseReleased( MouseEvent e ) { if ( textToUse == RANGE_TEXT || textToUse == ALL_GLYPHS ) { if ( nowZooming ) - zoomWindow.hide(); + zoomWindow.setVisible(false); nowZooming = false; } this.setCursor( Cursor.getDefaultCursor() ); @@ -1246,7 +1246,7 @@ } public static Object getValue(int ordinal) { if (valArray == null) { - valArray = (FMValues[])EnumSet.allOf(FMValues.class).toArray(new FMValues[0]); + valArray = EnumSet.allOf(FMValues.class).toArray(new FMValues[0]); } for (int i=0;i implements ActionListener { private static final int[][] UNICODE_RANGES = getUnicodeRanges(); private static final String[] UNICODE_RANGE_NAMES = getUnicodeRangeNames(); @@ -181,12 +181,12 @@ Object source = e.getSource(); if ( source instanceof JComboBox ) { - String rangeName = (String)((JComboBox)source).getSelectedItem(); + String rangeName = (String)((JComboBox)source).getSelectedItem(); if ( rangeName.equals("Custom...") ) { useCustomRange = true; customRangeDialog.setLocationRelativeTo(parent); - customRangeDialog.show(); + customRangeDialog.setVisible(true); } else { useCustomRange = false; @@ -195,7 +195,7 @@ } else if ( source instanceof JButton ) { /// Since it is only "OK" button that sends any action here... - customRangeDialog.hide(); + customRangeDialog.setVisible(false); } } --- old/src/demo/share/jfc/J2Ddemo/java2d/DemoPanel.java 2020-01-22 16:03:20.000000000 -0800 +++ new/src/demo/share/jfc/J2Ddemo/java2d/DemoPanel.java 2020-01-22 16:03:20.000000000 -0800 @@ -64,7 +64,7 @@ try { if (obj instanceof String) { className = (String) obj; - obj = Class.forName(className).newInstance(); + obj = Class.forName(className).getDeclaredConstructor().newInstance(); } if (obj instanceof Component) { add((Component) obj); --- old/src/demo/share/jfc/J2Ddemo/java2d/GlobalControls.java 2020-01-22 16:03:21.000000000 -0800 +++ new/src/demo/share/jfc/J2Ddemo/java2d/GlobalControls.java 2020-01-22 16:03:21.000000000 -0800 @@ -63,7 +63,7 @@ "USHORT_x555_RGB", "BYTE_GRAY", "USHORT_GRAY", "BYTE_BINARY", "BYTE_INDEXED", "BYTE_BINARY 2 bit", "BYTE_BINARY 4 bit", "INT_RGBx", "USHORT_555x_RGB" }; - public final JComboBox screenCombo; + public final JComboBox screenCombo; public TextureChooser texturechooser; public JCheckBox aliasCB, renderCB, toolBarCB; public JCheckBox compositeCB, textureCB; @@ -83,7 +83,7 @@ textureCB = createCheckBox("Texture", false, 2); compositeCB = createCheckBox("AlphaComposite", false, 3); - screenCombo = new JComboBox(); + screenCombo = new JComboBox<>(); screenCombo.setPreferredSize(new Dimension(120, 18)); screenCombo.setLightWeightPopupEnabled(true); screenCombo.setFont(font); --- old/src/demo/share/jfc/J2Ddemo/java2d/Tools.java 2020-01-22 16:03:23.000000000 -0800 +++ new/src/demo/share/jfc/J2Ddemo/java2d/Tools.java 2020-01-22 16:03:23.000000000 -0800 @@ -94,7 +94,7 @@ protected boolean focus; public JToggleButton toggleB; public JButton printB; - public JComboBox screenCombo; + public JComboBox screenCombo; public JToggleButton renderB, aliasB; public JToggleButton textureB, compositeB; public JButton startStopB; @@ -167,7 +167,7 @@ toolbar.setPreferredSize(new Dimension(6*25, 26)); } - screenCombo = new JComboBox(); + screenCombo = new JComboBox<>(); screenCombo.setPreferredSize(new Dimension(100, 18)); screenCombo.setFont(font); for (String name : GlobalControls.screenNames) { --- old/src/demo/share/jfc/J2Ddemo/java2d/demos/Clipping/Areas.java 2020-01-22 16:03:25.000000000 -0800 +++ new/src/demo/share/jfc/J2Ddemo/java2d/demos/Clipping/Areas.java 2020-01-22 16:03:25.000000000 -0800 @@ -151,7 +151,6 @@ Areas demo; JToolBar toolbar; - JComboBox combo; public DemoControls(Areas demo) { super(demo.name); --- old/src/demo/share/jfc/J2Ddemo/java2d/demos/Fonts/Tree.java 2020-01-22 16:03:27.000000000 -0800 +++ new/src/demo/share/jfc/J2Ddemo/java2d/demos/Fonts/Tree.java 2020-01-22 16:03:27.000000000 -0800 @@ -51,8 +51,8 @@ public class Tree extends AnimatingSurface { private char theC = 'A'; - private Character theT = new Character(theC); - private Character theR = new Character((char) (theC + 1)); + private Character theT = Character.valueOf(theC); + private Character theR = Character.valueOf((char) (theC + 1)); public Tree() { setBackground(WHITE); @@ -65,9 +65,9 @@ @Override public void step(int w, int h) { setSleepAmount(4000); - theT = new Character(theC = ((char) (theC + 1))); - theR = new Character((char) (theC + 1)); - if (theR.compareTo(new Character('z')) == 0) { + theT = Character.valueOf(theC = ((char) (theC + 1))); + theR = Character.valueOf((char) (theC + 1)); + if (theR.compareTo(Character.valueOf('z')) == 0) { theC = 'A'; } } --- old/src/demo/share/jfc/J2Ddemo/java2d/demos/Images/ImageOps.java 2020-01-22 16:03:28.000000000 -0800 +++ new/src/demo/share/jfc/J2Ddemo/java2d/demos/Images/ImageOps.java 2020-01-22 16:03:28.000000000 -0800 @@ -188,20 +188,20 @@ static class DemoControls extends CustomControls implements ActionListener { ImageOps demo; - JComboBox imgCombo, opsCombo; + JComboBox imgCombo, opsCombo; Font font = new Font(Font.SERIF, Font.PLAIN, 10); @SuppressWarnings("LeakingThisInConstructor") public DemoControls(ImageOps demo) { super(demo.name); this.demo = demo; - add(imgCombo = new JComboBox()); + add(imgCombo = new JComboBox<>()); imgCombo.setFont(font); for (String name : ImageOps.imgName) { imgCombo.addItem(name); } imgCombo.addActionListener(this); - add(opsCombo = new JComboBox()); + add(opsCombo = new JComboBox<>()); opsCombo.setFont(font); for (String name : ImageOps.opsName) { opsCombo.addItem(name); --- old/src/demo/share/jfc/J2Ddemo/java2d/demos/Mix/Balls.java 2020-01-22 16:03:30.000000000 -0800 +++ new/src/demo/share/jfc/J2Ddemo/java2d/demos/Mix/Balls.java 2020-01-22 16:03:29.000000000 -0800 @@ -71,7 +71,7 @@ private boolean active; protected Ball[] balls = new Ball[colors.length]; protected boolean clearToggle; - protected JComboBox combo; + protected JComboBox combo; public Balls() { setBackground(WHITE); @@ -279,7 +279,7 @@ addTool("B", demo.balls[4].isSelected); addTool("I", demo.balls[5].isSelected); addTool("V", demo.balls[6].isSelected); - add(combo = new JComboBox()); + add(combo = new JComboBox<>()); combo.addItem("10"); combo.addItem("20"); combo.addItem("30"); --- old/src/demo/share/jfc/J2Ddemo/java2d/demos/Mix/BezierScroller.java 2020-01-22 16:03:32.000000000 -0800 +++ new/src/demo/share/jfc/J2Ddemo/java2d/demos/Mix/BezierScroller.java 2020-01-22 16:03:31.000000000 -0800 @@ -60,7 +60,6 @@ import java2d.AnimatingControlsSurface; import java2d.CustomControls; import javax.swing.AbstractButton; -import javax.swing.JComboBox; import javax.swing.JToggleButton; import javax.swing.JToolBar; @@ -320,7 +319,6 @@ BezierScroller demo; JToolBar toolbar; - JComboBox combo; public DemoControls(BezierScroller demo) { super(demo.name); --- old/src/demo/share/jfc/J2Ddemo/java2d/demos/Paint/GradAnim.java 2020-01-22 16:03:34.000000000 -0800 +++ new/src/demo/share/jfc/J2Ddemo/java2d/demos/Paint/GradAnim.java 2020-01-22 16:03:33.000000000 -0800 @@ -266,13 +266,13 @@ class DemoControls extends CustomControls implements ActionListener { GradAnim demo; - JComboBox combo; + JComboBox combo; @SuppressWarnings("LeakingThisInConstructor") public DemoControls(GradAnim demo) { super(demo.name); this.demo = demo; - combo = new JComboBox(); + combo = new JComboBox<>(); combo.addActionListener(this); combo.addItem("2-color GradientPaint"); combo.addItem("3-color LinearGradientPaint"); --- old/src/demo/share/jfc/J2Ddemo/java2d/demos/Paint/TextureAnim.java 2020-01-22 16:03:35.000000000 -0800 +++ new/src/demo/share/jfc/J2Ddemo/java2d/demos/Paint/TextureAnim.java 2020-01-22 16:03:35.000000000 -0800 @@ -299,7 +299,7 @@ TextureAnim demo; JToolBar toolbar; - JComboBox combo; + JComboBox combo; JMenu menu; JMenuItem[] menuitems; int iconSize = 20; @@ -318,7 +318,7 @@ addTool("RO", "rotate", false); addTool("SX", "shear x", false); addTool("SY", "shear y", false); - add(combo = new JComboBox()); + add(combo = new JComboBox<>()); combo.addActionListener(this); combo.addItem("8"); combo.addItem("16"); --- old/src/demo/share/jfc/Metalworks/MetalworksPrefs.java 2020-01-22 16:03:36.000000000 -0800 +++ new/src/demo/share/jfc/Metalworks/MetalworksPrefs.java 2020-01-22 16:03:36.000000000 -0800 @@ -162,7 +162,7 @@ JPanel protoPanel = new JPanel(); JLabel protoLabel = new JLabel("Protocol"); - JComboBox protocol = new JComboBox(); + JComboBox protocol = new JComboBox<>(); protocol.addItem("SMTP"); protocol.addItem("IMAP"); protocol.addItem("Other..."); @@ -171,7 +171,7 @@ JPanel attachmentPanel = new JPanel(); JLabel attachmentLabel = new JLabel("Attachments"); - JComboBox attach = new JComboBox(); + JComboBox attach = new JComboBox<>(); attach.addItem("Download Always"); attach.addItem("Ask size > 1 Meg"); attach.addItem("Ask size > 5 Meg"); --- old/src/demo/share/jfc/Notepad/ElementTreePanel.java 2020-01-22 16:03:38.000000000 -0800 +++ new/src/demo/share/jfc/Notepad/ElementTreePanel.java 2020-01-22 16:03:38.000000000 -0800 @@ -115,7 +115,7 @@ if (as != null) { StringBuilder retBuffer = new StringBuilder("["); - Enumeration names = as.getAttributeNames(); + Enumeration names = as.getAttributeNames(); while (names.hasMoreElements()) { Object nextName = names.nextElement(); --- old/src/demo/share/jfc/Stylepad/Stylepad.java 2020-01-22 16:03:39.000000000 -0800 +++ new/src/demo/share/jfc/Stylepad/Stylepad.java 2020-01-22 16:03:39.000000000 -0800 @@ -255,8 +255,8 @@ w.loadDocument(); } - JComboBox createFamilyChoices() { - JComboBox b = new JComboBox(); + JComboBox createFamilyChoices() { + JComboBox b = new JComboBox<>(); String[] fontNames = GraphicsEnvironment.getLocalGraphicsEnvironment(). getAvailableFontFamilyNames(); for (String fontName : fontNames) { --- old/src/demo/share/jfc/SwingSet2/ButtonDemo.java 2020-01-22 16:03:41.000000000 -0800 +++ new/src/demo/share/jfc/SwingSet2/ButtonDemo.java 2020-01-22 16:03:40.000000000 -0800 @@ -61,12 +61,12 @@ JPanel radioButtonPanel = new JPanel(); JPanel toggleButtonPanel = new JPanel(); - Vector buttons = new Vector(); - Vector checkboxes = new Vector(); - Vector radiobuttons = new Vector(); - Vector togglebuttons = new Vector(); + Vector buttons = new Vector<>(); + Vector checkboxes = new Vector<>(); + Vector radiobuttons = new Vector<>(); + Vector togglebuttons = new Vector<>(); - Vector currentControls = buttons; + Vector currentControls = buttons; JButton button; JCheckBox check; @@ -466,12 +466,12 @@ String command = cb.getActionCommand(); if(command == "Enabled") { for(int i = 0; i < currentControls.size(); i++) { - c = (Component) currentControls.elementAt(i); + c = currentControls.elementAt(i); c.setEnabled(cb.isSelected()); c.invalidate(); } } else if(command == "PaintBorder") { - c = (Component) currentControls.elementAt(0); + c = currentControls.elementAt(0); if(c instanceof AbstractButton) { for(int i = 0; i < currentControls.size(); i++) { b = (AbstractButton) currentControls.elementAt(i); @@ -480,7 +480,7 @@ } } } else if(command == "PaintFocus") { - c = (Component) currentControls.elementAt(0); + c = currentControls.elementAt(0); if(c instanceof AbstractButton) { for(int i = 0; i < currentControls.size(); i++) { b = (AbstractButton) currentControls.elementAt(i); @@ -489,7 +489,7 @@ } } } else if(command == "ContentFilled") { - c = (Component) currentControls.elementAt(0); + c = currentControls.elementAt(0); if(c instanceof AbstractButton) { for(int i = 0; i < currentControls.size(); i++) { b = (AbstractButton) currentControls.elementAt(i); @@ -549,7 +549,7 @@ } } - public Vector getCurrentControls() { + public Vector getCurrentControls() { return currentControls; } } --- old/src/demo/share/jfc/SwingSet2/ColorChooserDemo.java 2020-01-22 16:03:42.000000000 -0800 +++ new/src/demo/share/jfc/SwingSet2/ColorChooserDemo.java 2020-01-22 16:03:42.000000000 -0800 @@ -128,7 +128,7 @@ okListener, null); - dialog.show(); + dialog.setVisible(true); if(e.getSource() == outerColorButton) { bezAnim.setOuterColor(chosen); --- old/src/demo/share/jfc/SwingSet2/ComboBoxDemo.java 2020-01-22 16:03:43.000000000 -0800 +++ new/src/demo/share/jfc/SwingSet2/ComboBoxDemo.java 2020-01-22 16:03:43.000000000 -0800 @@ -57,13 +57,13 @@ Face face; JLabel faceLabel; - JComboBox hairCB; - JComboBox eyesCB; - JComboBox mouthCB; + JComboBox hairCB; + JComboBox eyesCB; + JComboBox mouthCB; - JComboBox presetCB; + JComboBox presetCB; - Hashtable parts = new Hashtable(); + Hashtable parts = new Hashtable<>(); /** * main method allows us to run as a standalone demo. @@ -111,28 +111,28 @@ JLabel l = (JLabel) comboBoxPanel.add(new JLabel(getString("ComboBoxDemo.presets"))); l.setAlignmentX(JLabel.LEFT_ALIGNMENT); - presetCB = (JComboBox) comboBoxPanel.add(createPresetComboBox()); + presetCB = (JComboBox) comboBoxPanel.add(createPresetComboBox()); presetCB.setAlignmentX(JComboBox.LEFT_ALIGNMENT); l.setLabelFor(presetCB); comboBoxPanel.add(Box.createRigidArea(VGAP30)); l = (JLabel) comboBoxPanel.add(new JLabel(getString("ComboBoxDemo.hair_description"))); l.setAlignmentX(JLabel.LEFT_ALIGNMENT); - hairCB = (JComboBox) comboBoxPanel.add(createHairComboBox()); + hairCB = (JComboBox) comboBoxPanel.add(createHairComboBox()); hairCB.setAlignmentX(JComboBox.LEFT_ALIGNMENT); l.setLabelFor(hairCB); comboBoxPanel.add(Box.createRigidArea(VGAP15)); l = (JLabel) comboBoxPanel.add(new JLabel(getString("ComboBoxDemo.eyes_description"))); l.setAlignmentX(JLabel.LEFT_ALIGNMENT); - eyesCB = (JComboBox) comboBoxPanel.add(createEyesComboBox()); + eyesCB = (JComboBox) comboBoxPanel.add(createEyesComboBox()); eyesCB.setAlignmentX(JComboBox.LEFT_ALIGNMENT); l.setLabelFor(eyesCB); comboBoxPanel.add(Box.createRigidArea(VGAP15)); l = (JLabel) comboBoxPanel.add(new JLabel(getString("ComboBoxDemo.mouth_description"))); l.setAlignmentX(JLabel.LEFT_ALIGNMENT); - mouthCB = (JComboBox) comboBoxPanel.add(createMouthComboBox()); + mouthCB = (JComboBox) comboBoxPanel.add(createMouthComboBox()); mouthCB.setAlignmentX(JComboBox.LEFT_ALIGNMENT); l.setLabelFor(mouthCB); comboBoxPanel.add(Box.createRigidArea(VGAP15)); @@ -217,36 +217,36 @@ return face; } - JComboBox createHairComboBox() { - JComboBox cb = new JComboBox(); + JComboBox createHairComboBox() { + JComboBox cb = new JComboBox<>(); fillComboBox(cb); cb.addActionListener(this); return cb; } - JComboBox createEyesComboBox() { - JComboBox cb = new JComboBox(); + JComboBox createEyesComboBox() { + JComboBox cb = new JComboBox<>(); fillComboBox(cb); cb.addActionListener(this); return cb; } - JComboBox createNoseComboBox() { - JComboBox cb = new JComboBox(); + JComboBox createNoseComboBox() { + JComboBox cb = new JComboBox<>(); fillComboBox(cb); cb.addActionListener(this); return cb; } - JComboBox createMouthComboBox() { - JComboBox cb = new JComboBox(); + JComboBox createMouthComboBox() { + JComboBox cb = new JComboBox<>(); fillComboBox(cb); cb.addActionListener(this); return cb; } - JComboBox createPresetComboBox() { - JComboBox cb = new JComboBox(); + JComboBox createPresetComboBox() { + JComboBox cb = new JComboBox<>(); cb.addItem(getString("ComboBoxDemo.preset1")); cb.addItem(getString("ComboBoxDemo.preset2")); cb.addItem(getString("ComboBoxDemo.preset3")); @@ -261,7 +261,7 @@ return cb; } - void fillComboBox(JComboBox cb) { + void fillComboBox(JComboBox cb) { cb.addItem(getString("ComboBoxDemo.brent")); cb.addItem(getString("ComboBoxDemo.georges")); cb.addItem(getString("ComboBoxDemo.hans")); @@ -279,15 +279,15 @@ public void actionPerformed(ActionEvent e) { if(e.getSource() == hairCB) { - String name = (String) parts.get((String) hairCB.getSelectedItem()); + String name = (String) parts.get(hairCB.getSelectedItem()); face.setHair((ImageIcon) parts.get(name + "hair")); faceLabel.repaint(); } else if(e.getSource() == eyesCB) { - String name = (String) parts.get((String) eyesCB.getSelectedItem()); + String name = (String) parts.get(eyesCB.getSelectedItem()); face.setEyes((ImageIcon) parts.get(name + "eyes")); faceLabel.repaint(); } else if(e.getSource() == mouthCB) { - String name = (String) parts.get((String) mouthCB.getSelectedItem()); + String name = (String) parts.get(mouthCB.getSelectedItem()); face.setMouth((ImageIcon) parts.get(name + "mouth")); faceLabel.repaint(); } else if(e.getSource() == presetCB) { --- old/src/demo/share/jfc/SwingSet2/DemoModule.java 2020-01-22 16:03:47.000000000 -0800 +++ new/src/demo/share/jfc/SwingSet2/DemoModule.java 2020-01-22 16:03:46.000000000 -0800 @@ -51,7 +51,7 @@ * * @author Jeff Dinkins */ -public class DemoModule extends JApplet { +public class DemoModule extends JFrame { // The preferred size of the demo private int PREFERRED_WIDTH = 680; @@ -190,7 +190,7 @@ frame.getContentPane().add(getDemoPanel(), BorderLayout.CENTER); getDemoPanel().setPreferredSize(new Dimension(PREFERRED_WIDTH, PREFERRED_HEIGHT)); frame.pack(); - frame.show(); + frame.setVisible(true); } public JPanel createHorizontalPanel(boolean threeD) { --- old/src/demo/share/jfc/SwingSet2/DirectionPanel.java 2020-01-22 16:03:49.000000000 -0800 +++ new/src/demo/share/jfc/SwingSet2/DirectionPanel.java 2020-01-22 16:03:49.000000000 -0800 @@ -92,9 +92,9 @@ } public void setSelection( String selection ) { - Enumeration e = group.getElements(); + Enumeration e = group.getElements(); while( e.hasMoreElements() ) { - JRadioButton b = (JRadioButton)e.nextElement(); + AbstractButton b = e.nextElement(); if( b.getActionCommand().equals(selection) ) { b.setSelected(true); } @@ -147,10 +147,7 @@ getAccessibleContext().setAccessibleName(direction); getAccessibleContext().setAccessibleDescription(description); setSelected(selected); - } - - public boolean isFocusTraversable() { - return false; + setFocusable(false); } public void setBorder(Border b) { --- old/src/demo/share/jfc/SwingSet2/ExampleFileView.java 2020-01-22 16:03:50.000000000 -0800 +++ new/src/demo/share/jfc/SwingSet2/ExampleFileView.java 2020-01-22 16:03:50.000000000 -0800 @@ -59,9 +59,9 @@ * @author Jeff Dinkins */ public class ExampleFileView extends FileView { - private Hashtable icons = new Hashtable(5); - private Hashtable fileDescriptions = new Hashtable(5); - private Hashtable typeDescriptions = new Hashtable(5); + private Hashtable icons = new Hashtable<>(5); + private Hashtable fileDescriptions = new Hashtable<>(5); + private Hashtable typeDescriptions = new Hashtable<>(5); /** * The name of the file. Do nothing special here. Let @@ -85,7 +85,7 @@ * @see FileView#getDescription */ public String getDescription(File f) { - return (String) fileDescriptions.get(f); + return fileDescriptions.get(f); }; /** @@ -111,7 +111,7 @@ * @see FileView#getTypeDescription */ public String getTypeDescription(File f) { - return (String) typeDescriptions.get(getExtension(f)); + return typeDescriptions.get(getExtension(f)); } /** @@ -149,7 +149,7 @@ Icon icon = null; String extension = getExtension(f); if(extension != null) { - icon = (Icon) icons.get(extension); + icon = icons.get(extension); } return icon; } --- old/src/demo/share/jfc/SwingSet2/FileChooserDemo.java 2020-01-22 16:03:52.000000000 -0800 +++ new/src/demo/share/jfc/SwingSet2/FileChooserDemo.java 2020-01-22 16:03:51.000000000 -0800 @@ -273,7 +273,7 @@ dialog.getContentPane().add(custom, BorderLayout.CENTER); dialog.pack(); dialog.setLocationRelativeTo(getDemoPanel()); - dialog.show(); + dialog.setVisible(true); } }; return createButton(a); --- old/src/demo/share/jfc/SwingSet2/InternalFrameDemo.java 2020-01-22 16:03:53.000000000 -0800 +++ new/src/demo/share/jfc/SwingSet2/InternalFrameDemo.java 2020-01-22 16:03:52.000000000 -0800 @@ -59,9 +59,9 @@ ImageIcon icon1, icon2, icon3, icon4; ImageIcon smIcon1, smIcon2, smIcon3, smIcon4; - public Integer FIRST_FRAME_LAYER = new Integer(1); - public Integer DEMO_FRAME_LAYER = new Integer(2); - public Integer PALETTE_LAYER = new Integer(3); + public Integer FIRST_FRAME_LAYER = Integer.valueOf(1); + public Integer DEMO_FRAME_LAYER = Integer.valueOf(2); + public Integer PALETTE_LAYER = Integer.valueOf(3); public int FRAME0_X = 15; public int FRAME0_Y = 280; --- old/src/demo/share/jfc/SwingSet2/LayoutControlPanel.java 2020-01-22 16:03:54.000000000 -0800 +++ new/src/demo/share/jfc/SwingSet2/LayoutControlPanel.java 2020-01-22 16:03:53.000000000 -0800 @@ -104,7 +104,7 @@ // Make sure the controls' text position and label alignment match // the initial value of the associated direction panel. for(int i = 0; i < demo.getCurrentControls().size(); i++) { - Component c = (Component) demo.getCurrentControls().elementAt(i); + Component c = demo.getCurrentControls().elementAt(i); setPosition(c, RIGHT, CENTER); setAlignment(c,CENTER,CENTER); } @@ -173,7 +173,7 @@ } for(int i = 0; i < demo.getCurrentControls().size(); i++) { - Component c = (Component) demo.getCurrentControls().elementAt(i); + Component c = demo.getCurrentControls().elementAt(i); int hPos, vPos, hAlign, vAlign; if( c instanceof AbstractButton ) { hPos = ((AbstractButton)c).getHorizontalTextPosition(); @@ -228,7 +228,7 @@ hPos = RIGHT; vPos = BOTTOM; } for(int i = 0; i < demo.getCurrentControls().size(); i++) { - Component c = (Component) demo.getCurrentControls().elementAt(i); + Component c = demo.getCurrentControls().elementAt(i); setPosition(c, hPos, vPos); } demo.invalidate(); @@ -267,7 +267,7 @@ hPos = RIGHT; vPos = BOTTOM; } for(int i = 0; i < demo.getCurrentControls().size(); i++) { - Component c = (Component) demo.getCurrentControls().elementAt(i); + Component c = demo.getCurrentControls().elementAt(i); setAlignment(c,hPos,vPos); c.invalidate(); } --- old/src/demo/share/jfc/SwingSet2/ListDemo.java 2020-01-22 16:03:55.000000000 -0800 +++ new/src/demo/share/jfc/SwingSet2/ListDemo.java 2020-01-22 16:03:55.000000000 -0800 @@ -59,7 +59,7 @@ * @author Jeff Dinkins */ public class ListDemo extends DemoModule { - JList list; + JList list; JPanel prefixList; JPanel suffixList; @@ -69,7 +69,7 @@ GeneratedListModel listModel; - Vector checkboxes = new Vector(); + Vector checkboxes = new Vector<>(); /** * main method allows us to run as a standalone demo. @@ -103,7 +103,7 @@ centerPanel.add(Box.createRigidArea(HGAP30)); // Create the list - list = new JList(); + list = new JList<>(); list.setCellRenderer(new CompanyLogoListCellRenderer()); listModel = new GeneratedListModel(this); list.setModel(listModel); @@ -293,12 +293,12 @@ } - class GeneratedListModel extends AbstractListModel { + class GeneratedListModel extends AbstractListModel { ListDemo demo; Permuter permuter; - public Vector prefix = new Vector(); - public Vector suffix = new Vector(); + public Vector prefix = new Vector<>(); + public Vector suffix = new Vector<>(); public GeneratedListModel (ListDemo demo) { this.demo = demo; @@ -337,7 +337,7 @@ return prefix.size() * suffix.size(); } - public Object getElementAt(int index) { + public String getElementAt(int index) { if(permuter == null) { update(); } @@ -363,7 +363,7 @@ class CompanyLogoListCellRenderer extends DefaultListCellRenderer { public Component getListCellRendererComponent( - JList list, + JList list, Object value, int index, boolean isSelected, --- old/src/demo/share/jfc/SwingSet2/OptionPaneDemo.java 2020-01-22 16:03:56.000000000 -0800 +++ new/src/demo/share/jfc/SwingSet2/OptionPaneDemo.java 2020-01-22 16:03:56.000000000 -0800 @@ -163,7 +163,7 @@ message[0] = getString("OptionPaneDemo.componentmessage"); message[1] = new JTextField(getString("OptionPaneDemo.componenttextfield")); - JComboBox cb = new JComboBox(); + JComboBox cb = new JComboBox<>(); cb.addItem(getString("OptionPaneDemo.component_cb1")); cb.addItem(getString("OptionPaneDemo.component_cb2")); cb.addItem(getString("OptionPaneDemo.component_cb3")); --- old/src/demo/share/jfc/SwingSet2/SliderDemo.java 2020-01-22 16:03:57.000000000 -0800 +++ new/src/demo/share/jfc/SwingSet2/SliderDemo.java 2020-01-22 16:03:57.000000000 -0800 @@ -164,7 +164,9 @@ s.setPaintLabels( true ); s.setSnapToTicks( true ); - s.getLabelTable().put(new Integer(11), new JLabel(new Integer(11).toString(), JLabel.CENTER)); + @SuppressWarnings("unchecked") + Dictionary labelTable = s.getLabelTable(); + labelTable.put(Integer.valueOf(11), new JLabel(Integer.valueOf(11).toString(), JLabel.CENTER)); s.setLabelTable( s.getLabelTable() ); s.getAccessibleContext().setAccessibleName(getString("SliderDemo.minorticks")); --- old/src/demo/share/jfc/SwingSet2/SplitPaneDemo.java 2020-01-22 16:03:58.000000000 -0800 +++ new/src/demo/share/jfc/SwingSet2/SplitPaneDemo.java 2020-01-22 16:03:58.000000000 -0800 @@ -165,7 +165,7 @@ JLabel label; divSize = new JTextField(); - divSize.setText(new Integer(splitPane.getDividerSize()).toString()); + divSize.setText(Integer.valueOf(splitPane.getDividerSize()).toString()); divSize.setColumns(5); divSize.getAccessibleContext().setAccessibleName(getString("SplitPaneDemo.divider_size")); divSize.addActionListener(new ActionListener() { --- old/src/demo/share/jfc/SwingSet2/SwingSet2.java 2020-01-22 16:03:59.000000000 -0800 +++ new/src/demo/share/jfc/SwingSet2/SwingSet2.java 2020-01-22 16:03:59.000000000 -0800 @@ -71,12 +71,7 @@ void loadDemos() { for(int i = 0; i < demos.length;) { - if(isApplet() && demos[i].equals("FileChooserDemo")) { - // don't load the file chooser demo if we are - // an applet - } else { - loadDemo(demos[i]); - } + loadDemo(demos[i]); i++; } } @@ -126,9 +121,6 @@ // Used only if swingset is an application private JFrame frame = null; - // Used only if swingset is an applet - private SwingSet2Applet applet = null; - // To debug or not to debug, that is the question private boolean DEBUG = true; private int debugCounter = 0; @@ -151,27 +143,21 @@ private boolean dragEnabled = false; - public SwingSet2(SwingSet2Applet applet) { - this(applet, null); + public SwingSet2() { + this(null); } /** * SwingSet2 Constructor */ - public SwingSet2(SwingSet2Applet applet, GraphicsConfiguration gc) { - - // Note that applet may be null if this is started as an application - this.applet = applet; - + public SwingSet2(GraphicsConfiguration gc) { String lafClassName = UIManager.getLookAndFeel().getClass().getName(); lookAndFeelData = getInstalledLookAndFeelData(); currentLookAndFeel = Arrays.stream(lookAndFeelData) .filter(laf -> lafClassName.equals(laf.className)) .findFirst().get(); - if (!isApplet()) { - frame = createFrame(gc); - } + frame = createFrame(gc); // set the layout setLayout(new BorderLayout()); @@ -198,7 +184,7 @@ SwingUtilities.invokeLater(() -> { // Create SwingSet on the default monitor UIManager.put("swing.boldMetal", Boolean.FALSE); - SwingSet2 swingset = new SwingSet2(null, GraphicsEnvironment. + SwingSet2 swingset = new SwingSet2(GraphicsEnvironment. getLocalGraphicsEnvironment(). getDefaultScreenDevice(). getDefaultConfiguration()); @@ -218,11 +204,7 @@ menuBar = createMenus(); - if (isApplet()) { - applet.setJMenuBar(menuBar); - } else { frame.setJMenuBar(menuBar); - } // creates popup menu accessible via keyboard popupMenu = createPopupMenu(); @@ -309,13 +291,11 @@ "FileMenu.save_as_accessible_description", null); - if(!isApplet()) { - fileMenu.addSeparator(); + fileMenu.addSeparator(); - createMenuItem(fileMenu, "FileMenu.exit_label", "FileMenu.exit_mnemonic", - "FileMenu.exit_accessible_description", new ExitAction(this) - ); - } + createMenuItem(fileMenu, "FileMenu.exit_label", "FileMenu.exit_mnemonic", + "FileMenu.exit_accessible_description", new ExitAction(this) + ); // Create these menu items for the first SwingSet only. if (numSSs == 0) { @@ -431,7 +411,6 @@ // ***** create the multiscreen menu, if we have multiple screens - if (!isApplet()) { GraphicsDevice[] screens = GraphicsEnvironment. getLocalGraphicsEnvironment(). getScreenDevices(); @@ -449,7 +428,6 @@ createMultiscreenMenuItem(multiScreenMenu, i); } } - } return menuBar; } @@ -578,7 +556,7 @@ // register key binding to activate popup menu InputMap map = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); - map.put(KeyStroke.getKeyStroke(KeyEvent.VK_F10, InputEvent.SHIFT_MASK), + map.put(KeyStroke.getKeyStroke(KeyEvent.VK_F10, InputEvent.SHIFT_DOWN_MASK), "postMenuAction"); map.put(KeyStroke.getKeyStroke(KeyEvent.VK_CONTEXT_MENU, 0), "postMenuAction"); getActionMap().put("postMenuAction", new ActivatePopupMenuAction(this, popup)); @@ -659,37 +637,34 @@ /** - * Bring up the SwingSet2 demo by showing the frame (only - * applicable if coming up as an application, not an applet); + * Bring up the SwingSet2 demo by showing the frame */ public void showSwingSet2() { - if(!isApplet() && getFrame() != null) { - // put swingset in a frame and show it - JFrame f = getFrame(); - f.setTitle(getString("Frame.title")); - f.getContentPane().add(this, BorderLayout.CENTER); - f.pack(); - - Rectangle screenRect = f.getGraphicsConfiguration().getBounds(); - Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets( - f.getGraphicsConfiguration()); - - // Make sure we don't place the demo off the screen. - int centerWidth = screenRect.width < f.getSize().width ? - screenRect.x : - screenRect.x + screenRect.width/2 - f.getSize().width/2; - int centerHeight = screenRect.height < f.getSize().height ? - screenRect.y : - screenRect.y + screenRect.height/2 - f.getSize().height/2; - - centerHeight = centerHeight < screenInsets.top ? - screenInsets.top : centerHeight; - - f.setLocation(centerWidth, centerHeight); - f.show(); - numSSs++; - swingSets.add(this); - } + // put swingset in a frame and show it + JFrame f = getFrame(); + f.setTitle(getString("Frame.title")); + f.getContentPane().add(this, BorderLayout.CENTER); + f.pack(); + + Rectangle screenRect = f.getGraphicsConfiguration().getBounds(); + Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets( + f.getGraphicsConfiguration()); + + // Make sure we don't place the demo off the screen. + int centerWidth = screenRect.width < f.getSize().width ? + screenRect.x : + screenRect.x + screenRect.width/2 - f.getSize().width/2; + int centerHeight = screenRect.height < f.getSize().height ? + screenRect.y : + screenRect.y + screenRect.height/2 - f.getSize().height/2; + + centerHeight = centerHeight < screenInsets.top ? + screenInsets.top : centerHeight; + + f.setLocation(centerWidth, centerHeight); + f.setVisible(true); + numSSs++; + swingSets.add(this); } // ******************************************************* @@ -703,8 +678,8 @@ setStatus(getString("Status.loading") + getString(classname + ".name")); DemoModule demo = null; try { - Class demoClass = Class.forName(classname); - Constructor demoConstructor = demoClass.getConstructor(new Class[]{SwingSet2.class}); + Class demoClass = Class.forName(classname); + Constructor demoConstructor = demoClass.getConstructor(new Class[]{SwingSet2.class}); demo = (DemoModule) demoConstructor.newInstance(new Object[]{this}); addDemo(demo); } catch (Exception e) { @@ -713,21 +688,6 @@ } /** - * Determines if this is an applet or application - */ - public boolean isApplet() { - return (applet != null); - } - - /** - * Returns the applet instance - */ - public SwingSet2Applet getApplet() { - return applet; - } - - - /** * Returns the frame instance */ public JFrame getFrame() { @@ -763,8 +723,6 @@ if(contentPane == null) { if(getFrame() != null) { contentPane = getFrame().getContentPane(); - } else if (getApplet() != null) { - contentPane = getApplet().getContentPane(); } } return contentPane; @@ -886,15 +844,11 @@ } private void updateThisSwingSet() { - if (isApplet()) { - SwingUtilities.updateComponentTreeUI(getApplet()); + JFrame frame = getFrame(); + if (frame == null) { + SwingUtilities.updateComponentTreeUI(this); } else { - JFrame frame = getFrame(); - if (frame == null) { - SwingUtilities.updateComponentTreeUI(this); - } else { - SwingUtilities.updateComponentTreeUI(frame); - } + SwingUtilities.updateComponentTreeUI(frame); } SwingUtilities.updateComponentTreeUI(popupMenu); @@ -909,12 +863,8 @@ public void updateLookAndFeel() { try { UIManager.setLookAndFeel(currentLookAndFeel.className); - if (isApplet()) { - updateThisSwingSet(); - } else { - for (SwingSet2 ss : swingSets) { - ss.updateThisSwingSet(); - } + for (SwingSet2 ss : swingSets) { + ss.updateThisSwingSet(); } } catch (Exception ex) { System.out.println("Failed loading L&F: " + currentLookAndFeel); @@ -1142,12 +1092,8 @@ public void actionPerformed(ActionEvent e) { boolean dragEnabled = ((JCheckBoxMenuItem)e.getSource()).isSelected(); - if (isApplet()) { - setDragEnabled(dragEnabled); - } else { - for (SwingSet2 ss : swingSets) { - ss.setDragEnabled(dragEnabled); - } + for (SwingSet2 ss : swingSets) { + ss.setDragEnabled(dragEnabled); } } } @@ -1208,12 +1154,8 @@ button.addActionListener(new OkAction(aboutBox)); } aboutBox.pack(); - if (isApplet()) { - aboutBox.setLocationRelativeTo(getApplet()); - } else { - aboutBox.setLocationRelativeTo(getFrame()); - } - aboutBox.show(); + aboutBox.setLocationRelativeTo(getFrame()); + aboutBox.setVisible(true); } } @@ -1231,13 +1173,13 @@ getScreenDevices(); if (screen == ALL_SCREENS) { for (int i = 0; i < gds.length; i++) { - SwingSet2 swingset = new SwingSet2(null, + SwingSet2 swingset = new SwingSet2( gds[i].getDefaultConfiguration()); swingset.setDragEnabled(dragEnabled); } } else { - SwingSet2 swingset = new SwingSet2(null, + SwingSet2 swingset = new SwingSet2( gds[screen].getDefaultConfiguration()); swingset.setDragEnabled(dragEnabled); } --- old/src/demo/share/jfc/SwingSet2/TableDemo.java 2020-01-22 16:04:00.000000000 -0800 +++ new/src/demo/share/jfc/SwingSet2/TableDemo.java 2020-01-22 16:04:00.000000000 -0800 @@ -75,8 +75,8 @@ JSlider interCellSpacingSlider; JSlider rowHeightSlider; - JComboBox selectionModeComboBox = null; - JComboBox resizeModeComboBox = null; + JComboBox selectionModeComboBox = null; + JComboBox resizeModeComboBox = null; JLabel headerLabel; JLabel footerLabel; @@ -126,7 +126,7 @@ JPanel printPanel = new JPanel(new ColumnLayout()); getDemoPanel().add(controlPanel, BorderLayout.NORTH); - Vector relatedComponents = new Vector(); + Vector relatedComponents = new Vector<>(); // check box panel @@ -245,7 +245,7 @@ selectMode.setBorder(new TitledBorder(getString("TableDemo.selection_mode"))); - selectionModeComboBox = new JComboBox() { + selectionModeComboBox = new JComboBox<>() { public Dimension getMaximumSize() { return getPreferredSize(); } @@ -256,7 +256,7 @@ selectionModeComboBox.setSelectedIndex(tableView.getSelectionModel().getSelectionMode()); selectionModeComboBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { - JComboBox source = (JComboBox)e.getSource(); + JComboBox source = (JComboBox)e.getSource(); tableView.setSelectionMode(source.getSelectedIndex()); } }); @@ -272,7 +272,7 @@ resizeMode.setBorder(new TitledBorder(getString("TableDemo.autoresize_mode"))); - resizeModeComboBox = new JComboBox() { + resizeModeComboBox = new JComboBox<>() { public Dimension getMaximumSize() { return getPreferredSize(); } @@ -285,7 +285,7 @@ resizeModeComboBox.setSelectedIndex(tableView.getAutoResizeMode()); resizeModeComboBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { - JComboBox source = (JComboBox)e.getSource(); + JComboBox source = (JComboBox)e.getSource(); tableView.setAutoResizeMode(source.getSelectedIndex()); } }); @@ -367,7 +367,7 @@ * * @param components The list of objects that are related */ - void buildAccessibleGroup(Vector components) { + void buildAccessibleGroup(Vector components) { AccessibleContext context = null; int numComponents = components.size(); @@ -492,55 +492,55 @@ // Create the dummy data (a few rows of names) final Object[][] data = { - {"Mike", "Albers", green, getString("TableDemo.brazil"), new Double(44.0), strawberry}, - {"Mark", "Andrews", blue, getString("TableDemo.curse"), new Double(3), grapes}, - {"Brian", "Beck", black, getString("TableDemo.bluesbros"), new Double(2.7182818285), raspberry}, - {"Lara", "Bunni", red, getString("TableDemo.airplane"), new Double(15), strawberry}, - {"Roger", "Brinkley", blue, getString("TableDemo.man"), new Double(13), peach}, - {"Brent", "Christian", black, getString("TableDemo.bladerunner"), new Double(23), broccoli}, - {"Mark", "Davidson", darkgreen, getString("TableDemo.brazil"), new Double(27), asparagus}, - {"Jeff", "Dinkins", blue, getString("TableDemo.ladyvanishes"), new Double(8), kiwi}, - {"Ewan", "Dinkins", yellow, getString("TableDemo.bugs"), new Double(2), strawberry}, - {"Amy", "Fowler", violet, getString("TableDemo.reservoir"), new Double(3), raspberry}, - {"Hania", "Gajewska", purple, getString("TableDemo.jules"), new Double(5), raspberry}, - {"David", "Geary", blue, getString("TableDemo.pulpfiction"), new Double(3), watermelon}, -// {"James", "Gosling", pink, getString("TableDemo.tennis"), new Double(21), donut}, - {"Eric", "Hawkes", blue, getString("TableDemo.bladerunner"), new Double(.693), pickle}, - {"Shannon", "Hickey", green, getString("TableDemo.shawshank"), new Double(2), grapes}, - {"Earl", "Johnson", green, getString("TableDemo.pulpfiction"), new Double(8), carrot}, - {"Robi", "Khan", green, getString("TableDemo.goodfellas"), new Double(89), apple}, - {"Robert", "Kim", blue, getString("TableDemo.mohicans"), new Double(655321), strawberry}, - {"Janet", "Koenig", turquoise, getString("TableDemo.lonestar"), new Double(7), peach}, - {"Jeff", "Kesselman", blue, getString("TableDemo.stuntman"), new Double(17), pineapple}, - {"Onno", "Kluyt", orange, getString("TableDemo.oncewest"), new Double(8), broccoli}, - {"Peter", "Korn", sunpurple, getString("TableDemo.musicman"), new Double(12), sparegrass}, - - {"Rick", "Levenson", black, getString("TableDemo.harold"), new Double(1327), raspberry}, - {"Brian", "Lichtenwalter", jfcblue, getString("TableDemo.fifthelement"), new Double(22), pear}, - {"Malini", "Minasandram", beige, getString("TableDemo.joyluck"), new Double(9), corn}, - {"Michael", "Martak", green, getString("TableDemo.city"), new Double(3), strawberry}, - {"David", "Mendenhall", forestgreen, getString("TableDemo.schindlerslist"), new Double(7), peach}, - {"Phil", "Milne", suspectpink, getString("TableDemo.withnail"), new Double(3), banana}, - {"Lynn", "Monsanto", cybergreen, getString("TableDemo.dasboot"), new Double(52), peach}, - {"Hans", "Muller", rustred, getString("TableDemo.eraserhead"), new Double(0), pineapple}, - {"Joshua", "Outwater", blue, getString("TableDemo.labyrinth"), new Double(3), pineapple}, - {"Tim", "Prinzing", blue, getString("TableDemo.firstsight"), new Double(69), pepper}, - {"Raj", "Premkumar", jfcblue2, getString("TableDemo.none"), new Double(7), broccoli}, - {"Howard", "Rosen", green, getString("TableDemo.defending"), new Double(7), strawberry}, + {"Mike", "Albers", green, getString("TableDemo.brazil"), Double.valueOf(44.0), strawberry}, + {"Mark", "Andrews", blue, getString("TableDemo.curse"), Double.valueOf(3), grapes}, + {"Brian", "Beck", black, getString("TableDemo.bluesbros"), Double.valueOf(2.7182818285), raspberry}, + {"Lara", "Bunni", red, getString("TableDemo.airplane"), Double.valueOf(15), strawberry}, + {"Roger", "Brinkley", blue, getString("TableDemo.man"), Double.valueOf(13), peach}, + {"Brent", "Christian", black, getString("TableDemo.bladerunner"), Double.valueOf(23), broccoli}, + {"Mark", "Davidson", darkgreen, getString("TableDemo.brazil"), Double.valueOf(27), asparagus}, + {"Jeff", "Dinkins", blue, getString("TableDemo.ladyvanishes"), Double.valueOf(8), kiwi}, + {"Ewan", "Dinkins", yellow, getString("TableDemo.bugs"), Double.valueOf(2), strawberry}, + {"Amy", "Fowler", violet, getString("TableDemo.reservoir"), Double.valueOf(3), raspberry}, + {"Hania", "Gajewska", purple, getString("TableDemo.jules"), Double.valueOf(5), raspberry}, + {"David", "Geary", blue, getString("TableDemo.pulpfiction"), Double.valueOf(3), watermelon}, +// {"James", "Gosling", pink, getString("TableDemo.tennis"), Double.valueOf(21), donut}, + {"Eric", "Hawkes", blue, getString("TableDemo.bladerunner"), Double.valueOf(.693), pickle}, + {"Shannon", "Hickey", green, getString("TableDemo.shawshank"), Double.valueOf(2), grapes}, + {"Earl", "Johnson", green, getString("TableDemo.pulpfiction"), Double.valueOf(8), carrot}, + {"Robi", "Khan", green, getString("TableDemo.goodfellas"), Double.valueOf(89), apple}, + {"Robert", "Kim", blue, getString("TableDemo.mohicans"), Double.valueOf(655321), strawberry}, + {"Janet", "Koenig", turquoise, getString("TableDemo.lonestar"), Double.valueOf(7), peach}, + {"Jeff", "Kesselman", blue, getString("TableDemo.stuntman"), Double.valueOf(17), pineapple}, + {"Onno", "Kluyt", orange, getString("TableDemo.oncewest"), Double.valueOf(8), broccoli}, + {"Peter", "Korn", sunpurple, getString("TableDemo.musicman"), Double.valueOf(12), sparegrass}, + + {"Rick", "Levenson", black, getString("TableDemo.harold"), Double.valueOf(1327), raspberry}, + {"Brian", "Lichtenwalter", jfcblue, getString("TableDemo.fifthelement"), Double.valueOf(22), pear}, + {"Malini", "Minasandram", beige, getString("TableDemo.joyluck"), Double.valueOf(9), corn}, + {"Michael", "Martak", green, getString("TableDemo.city"), Double.valueOf(3), strawberry}, + {"David", "Mendenhall", forestgreen, getString("TableDemo.schindlerslist"), Double.valueOf(7), peach}, + {"Phil", "Milne", suspectpink, getString("TableDemo.withnail"), Double.valueOf(3), banana}, + {"Lynn", "Monsanto", cybergreen, getString("TableDemo.dasboot"), Double.valueOf(52), peach}, + {"Hans", "Muller", rustred, getString("TableDemo.eraserhead"), Double.valueOf(0), pineapple}, + {"Joshua", "Outwater", blue, getString("TableDemo.labyrinth"), Double.valueOf(3), pineapple}, + {"Tim", "Prinzing", blue, getString("TableDemo.firstsight"), Double.valueOf(69), pepper}, + {"Raj", "Premkumar", jfcblue2, getString("TableDemo.none"), Double.valueOf(7), broccoli}, + {"Howard", "Rosen", green, getString("TableDemo.defending"), Double.valueOf(7), strawberry}, {"Ray", "Ryan", black, getString("TableDemo.buckaroo"), - new Double(3.141592653589793238462643383279502884197169399375105820974944), banana}, - {"Georges", "Saab", aqua, getString("TableDemo.bicycle"), new Double(290), cantaloupe}, - {"Tom", "Santos", blue, getString("TableDemo.spinaltap"), new Double(241), pepper}, - {"Rich", "Schiavi", blue, getString("TableDemo.repoman"), new Double(0xFF), pepper}, - {"Nancy", "Schorr", green, getString("TableDemo.fifthelement"), new Double(47), watermelon}, - {"Keith", "Sprochi", darkgreen, getString("TableDemo.2001"), new Double(13), watermelon}, - {"Matt", "Tucker", eblue, getString("TableDemo.starwars"), new Double(2), broccoli}, - {"Dmitri", "Trembovetski", red, getString("TableDemo.aliens"), new Double(222), tomato}, - {"Scott", "Violet", violet, getString("TableDemo.raiders"), new Double(-97), banana}, - {"Kathy", "Walrath", darkgreen, getString("TableDemo.thinman"), new Double(8), pear}, - {"Nathan", "Walrath", black, getString("TableDemo.chusingura"), new Double(3), grapefruit}, - {"Steve", "Wilson", green, getString("TableDemo.raiders"), new Double(7), onion}, - {"Kathleen", "Zelony", gray, getString("TableDemo.dog"), new Double(13), grapes} + Double.valueOf(3.141592653589793238462643383279502884197169399375105820974944), banana}, + {"Georges", "Saab", aqua, getString("TableDemo.bicycle"), Double.valueOf(290), cantaloupe}, + {"Tom", "Santos", blue, getString("TableDemo.spinaltap"), Double.valueOf(241), pepper}, + {"Rich", "Schiavi", blue, getString("TableDemo.repoman"), Double.valueOf(0xFF), pepper}, + {"Nancy", "Schorr", green, getString("TableDemo.fifthelement"), Double.valueOf(47), watermelon}, + {"Keith", "Sprochi", darkgreen, getString("TableDemo.2001"), Double.valueOf(13), watermelon}, + {"Matt", "Tucker", eblue, getString("TableDemo.starwars"), Double.valueOf(2), broccoli}, + {"Dmitri", "Trembovetski", red, getString("TableDemo.aliens"), Double.valueOf(222), tomato}, + {"Scott", "Violet", violet, getString("TableDemo.raiders"), Double.valueOf(-97), banana}, + {"Kathy", "Walrath", darkgreen, getString("TableDemo.thinman"), Double.valueOf(8), pear}, + {"Nathan", "Walrath", black, getString("TableDemo.chusingura"), Double.valueOf(3), grapefruit}, + {"Steve", "Wilson", green, getString("TableDemo.raiders"), Double.valueOf(7), onion}, + {"Kathleen", "Zelony", gray, getString("TableDemo.dog"), Double.valueOf(13), grapes} }; // Create a model of the data. @@ -549,7 +549,7 @@ public int getRowCount() { return data.length;} public Object getValueAt(int row, int col) {return data[row][col];} public String getColumnName(int column) {return names[column];} - public Class getColumnClass(int c) {return getValueAt(0, c).getClass();} + public Class getColumnClass(int c) {return getValueAt(0, c).getClass();} public boolean isCellEditable(int row, int col) {return col != 5;} public void setValueAt(Object aValue, int row, int column) { data[row][column] = aValue; } }; @@ -557,7 +557,7 @@ // Create the table tableView = new JTable(dataModel); - TableRowSorter sorter = new TableRowSorter(dataModel); + TableRowSorter sorter = new TableRowSorter<>(dataModel); tableView.setRowSorter(sorter); // Show colors by rendering them in their own color. @@ -575,7 +575,7 @@ }; // Create a combo box to show that you can use one in a table. - JComboBox comboBox = new JComboBox(); + JComboBox comboBox = new JComboBox<>(); comboBox.addItem(aqua); comboBox.addItem(beige); comboBox.addItem(black); --- old/src/demo/share/jfc/TableExample/JDBCAdapter.java 2020-01-22 16:04:01.000000000 -0800 +++ new/src/demo/share/jfc/TableExample/JDBCAdapter.java 2020-01-22 16:04:01.000000000 -0800 @@ -125,12 +125,6 @@ connection.close(); } - @Override - protected void finalize() throws Throwable { - close(); - super.finalize(); - } - ////////////////////////////////////////////////////////////////////////// // // Implementation of the TableModel Interface --- old/src/demo/share/jfc/TableExample/OldJTable.java 2020-01-22 16:04:03.000000000 -0800 +++ new/src/demo/share/jfc/TableExample/OldJTable.java 2020-01-22 16:04:02.000000000 -0800 @@ -72,7 +72,7 @@ return addColumn(columnIdentifier, width, null, null, null); } - public TableColumn addColumn(Object columnIdentifier, List columnData) { + public TableColumn addColumn(Object columnIdentifier, List columnData) { return addColumn(columnIdentifier, -1, null, null, columnData); } @@ -86,7 +86,7 @@ public TableColumn addColumn(Object columnIdentifier, int width, TableCellRenderer renderer, - TableCellEditor editor, List columnData) { + TableCellEditor editor, List columnData) { checkDefaultTableModel(); // Set up the model side first @@ -112,7 +112,7 @@ ((DefaultTableModel)getModel()).addRow(rowData); } - public void addRow(List rowData) { + public void addRow(List rowData) { checkDefaultTableModel(); ((DefaultTableModel)getModel()).addRow(rowData.toArray()); } @@ -132,7 +132,7 @@ ((DefaultTableModel)getModel()).insertRow(rowIndex, rowData); } - public void insertRow(int rowIndex, List rowData) { + public void insertRow(int rowIndex, List rowData) { checkDefaultTableModel(); ((DefaultTableModel)getModel()).insertRow(rowIndex, rowData.toArray()); } @@ -142,7 +142,7 @@ ((DefaultTableModel)getModel()).setNumRows(newSize); } - public void setDataVector(Object[][] newData, List columnIds) { + public void setDataVector(Object[][] newData, List columnIds) { checkDefaultTableModel(); ((DefaultTableModel)getModel()).setDataVector( newData, columnIds.toArray()); --- old/src/demo/share/jfc/TableExample/TableExample3.java 2020-01-22 16:04:04.000000000 -0800 +++ new/src/demo/share/jfc/TableExample/TableExample3.java 2020-01-22 16:04:03.000000000 -0800 @@ -73,27 +73,27 @@ final String[] names = { "First Name", "Last Name", "Favorite Color", "Favorite Number", "Vegetarian" }; final Object[][] data = { - { "Mark", "Andrews", "Red", new Integer(2), Boolean.TRUE }, - { "Tom", "Ball", "Blue", new Integer(99), Boolean.FALSE }, - { "Alan", "Chung", "Green", new Integer(838), Boolean.FALSE }, - { "Jeff", "Dinkins", "Turquois", new Integer(8), Boolean.TRUE }, - { "Amy", "Fowler", "Yellow", new Integer(3), Boolean.FALSE }, - { "Brian", "Gerhold", "Green", new Integer(0), Boolean.FALSE }, - { "James", "Gosling", "Pink", new Integer(21), Boolean.FALSE }, - { "David", "Karlton", "Red", new Integer(1), Boolean.FALSE }, - { "Dave", "Kloba", "Yellow", new Integer(14), Boolean.FALSE }, - { "Peter", "Korn", "Purple", new Integer(12), Boolean.FALSE }, - { "Phil", "Milne", "Purple", new Integer(3), Boolean.FALSE }, - { "Dave", "Moore", "Green", new Integer(88), Boolean.FALSE }, - { "Hans", "Muller", "Maroon", new Integer(5), Boolean.FALSE }, - { "Rick", "Levenson", "Blue", new Integer(2), Boolean.FALSE }, - { "Tim", "Prinzing", "Blue", new Integer(22), Boolean.FALSE }, - { "Chester", "Rose", "Black", new Integer(0), Boolean.FALSE }, - { "Ray", "Ryan", "Gray", new Integer(77), Boolean.FALSE }, - { "Georges", "Saab", "Red", new Integer(4), Boolean.FALSE }, - { "Willie", "Walker", "Phthalo Blue", new Integer(4), Boolean.FALSE }, - { "Kathy", "Walrath", "Blue", new Integer(8), Boolean.FALSE }, - { "Arnaud", "Weber", "Green", new Integer(44), Boolean.FALSE } + { "Mark", "Andrews", "Red", Integer.valueOf(2), Boolean.TRUE }, + { "Tom", "Ball", "Blue", Integer.valueOf(99), Boolean.FALSE }, + { "Alan", "Chung", "Green", Integer.valueOf(838), Boolean.FALSE }, + { "Jeff", "Dinkins", "Turquois", Integer.valueOf(8), Boolean.TRUE }, + { "Amy", "Fowler", "Yellow", Integer.valueOf(3), Boolean.FALSE }, + { "Brian", "Gerhold", "Green", Integer.valueOf(0), Boolean.FALSE }, + { "James", "Gosling", "Pink", Integer.valueOf(21), Boolean.FALSE }, + { "David", "Karlton", "Red", Integer.valueOf(1), Boolean.FALSE }, + { "Dave", "Kloba", "Yellow", Integer.valueOf(14), Boolean.FALSE }, + { "Peter", "Korn", "Purple", Integer.valueOf(12), Boolean.FALSE }, + { "Phil", "Milne", "Purple", Integer.valueOf(3), Boolean.FALSE }, + { "Dave", "Moore", "Green", Integer.valueOf(88), Boolean.FALSE }, + { "Hans", "Muller", "Maroon", Integer.valueOf(5), Boolean.FALSE }, + { "Rick", "Levenson", "Blue", Integer.valueOf(2), Boolean.FALSE }, + { "Tim", "Prinzing", "Blue", Integer.valueOf(22), Boolean.FALSE }, + { "Chester", "Rose", "Black", Integer.valueOf(0), Boolean.FALSE }, + { "Ray", "Ryan", "Gray", Integer.valueOf(77), Boolean.FALSE }, + { "Georges", "Saab", "Red", Integer.valueOf(4), Boolean.FALSE }, + { "Willie", "Walker", "Phthalo Blue", Integer.valueOf(4), Boolean.FALSE }, + { "Kathy", "Walrath", "Blue", Integer.valueOf(8), Boolean.FALSE }, + { "Arnaud", "Weber", "Green", Integer.valueOf(44), Boolean.FALSE } }; // Create a model of the data. @@ -121,7 +121,7 @@ } @Override - public Class getColumnClass(int col) { + public Class getColumnClass(int col) { return getValueAt(0, col).getClass(); } --- old/src/demo/share/jfc/TableExample/TableExample4.java 2020-01-22 16:04:05.000000000 -0800 +++ new/src/demo/share/jfc/TableExample/TableExample4.java 2020-01-22 16:04:05.000000000 -0800 @@ -75,27 +75,27 @@ final String[] names = { "First Name", "Last Name", "Favorite Color", "Favorite Number", "Vegetarian" }; final Object[][] data = { - { "Mark", "Andrews", "Red", new Integer(2), Boolean.TRUE }, - { "Tom", "Ball", "Blue", new Integer(99), Boolean.FALSE }, - { "Alan", "Chung", "Green", new Integer(838), Boolean.FALSE }, - { "Jeff", "Dinkins", "Turquois", new Integer(8), Boolean.TRUE }, - { "Amy", "Fowler", "Yellow", new Integer(3), Boolean.FALSE }, - { "Brian", "Gerhold", "Green", new Integer(0), Boolean.FALSE }, - { "James", "Gosling", "Pink", new Integer(21), Boolean.FALSE }, - { "David", "Karlton", "Red", new Integer(1), Boolean.FALSE }, - { "Dave", "Kloba", "Yellow", new Integer(14), Boolean.FALSE }, - { "Peter", "Korn", "Purple", new Integer(12), Boolean.FALSE }, - { "Phil", "Milne", "Purple", new Integer(3), Boolean.FALSE }, - { "Dave", "Moore", "Green", new Integer(88), Boolean.FALSE }, - { "Hans", "Muller", "Maroon", new Integer(5), Boolean.FALSE }, - { "Rick", "Levenson", "Blue", new Integer(2), Boolean.FALSE }, - { "Tim", "Prinzing", "Blue", new Integer(22), Boolean.FALSE }, - { "Chester", "Rose", "Black", new Integer(0), Boolean.FALSE }, - { "Ray", "Ryan", "Gray", new Integer(77), Boolean.FALSE }, - { "Georges", "Saab", "Red", new Integer(4), Boolean.FALSE }, - { "Willie", "Walker", "Phthalo Blue", new Integer(4), Boolean.FALSE }, - { "Kathy", "Walrath", "Blue", new Integer(8), Boolean.FALSE }, - { "Arnaud", "Weber", "Green", new Integer(44), Boolean.FALSE } + { "Mark", "Andrews", "Red", Integer.valueOf(2), Boolean.TRUE }, + { "Tom", "Ball", "Blue", Integer.valueOf(99), Boolean.FALSE }, + { "Alan", "Chung", "Green", Integer.valueOf(838), Boolean.FALSE }, + { "Jeff", "Dinkins", "Turquois", Integer.valueOf(8), Boolean.TRUE }, + { "Amy", "Fowler", "Yellow", Integer.valueOf(3), Boolean.FALSE }, + { "Brian", "Gerhold", "Green", Integer.valueOf(0), Boolean.FALSE }, + { "James", "Gosling", "Pink", Integer.valueOf(21), Boolean.FALSE }, + { "David", "Karlton", "Red", Integer.valueOf(1), Boolean.FALSE }, + { "Dave", "Kloba", "Yellow", Integer.valueOf(14), Boolean.FALSE }, + { "Peter", "Korn", "Purple", Integer.valueOf(12), Boolean.FALSE }, + { "Phil", "Milne", "Purple", Integer.valueOf(3), Boolean.FALSE }, + { "Dave", "Moore", "Green", Integer.valueOf(88), Boolean.FALSE }, + { "Hans", "Muller", "Maroon", Integer.valueOf(5), Boolean.FALSE }, + { "Rick", "Levenson", "Blue", Integer.valueOf(2), Boolean.FALSE }, + { "Tim", "Prinzing", "Blue", Integer.valueOf(22), Boolean.FALSE }, + { "Chester", "Rose", "Black", Integer.valueOf(0), Boolean.FALSE }, + { "Ray", "Ryan", "Gray", Integer.valueOf(77), Boolean.FALSE }, + { "Georges", "Saab", "Red", Integer.valueOf(4), Boolean.FALSE }, + { "Willie", "Walker", "Phthalo Blue", Integer.valueOf(4), Boolean.FALSE }, + { "Kathy", "Walrath", "Blue", Integer.valueOf(8), Boolean.FALSE }, + { "Arnaud", "Weber", "Green", Integer.valueOf(44), Boolean.FALSE } }; // Create a model of the data. @@ -123,7 +123,7 @@ } @Override - public Class getColumnClass(int c) { + public Class getColumnClass(int c) { return getValueAt(0, c).getClass(); } @@ -147,7 +147,7 @@ tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // Create a combo box to show that you can use one in a table. - JComboBox comboBox = new JComboBox(); + JComboBox comboBox = new JComboBox<>(); comboBox.addItem("Red"); comboBox.addItem("Orange"); comboBox.addItem("Yellow"); --- old/src/demo/share/jfc/TableExample/TableMap.java 2020-01-22 16:04:06.000000000 -0800 +++ new/src/demo/share/jfc/TableExample/TableMap.java 2020-01-22 16:04:06.000000000 -0800 @@ -94,7 +94,7 @@ } @Override - public Class getColumnClass(int aColumn) { + public Class getColumnClass(int aColumn) { return model.getColumnClass(aColumn); } --- old/src/demo/share/jfc/TableExample/TableSorter.java 2020-01-22 16:04:07.000000000 -0800 +++ new/src/demo/share/jfc/TableExample/TableSorter.java 2020-01-22 16:04:07.000000000 -0800 @@ -91,7 +91,7 @@ } public int compareRowsByColumn(int row1, int row2, int column) { - Class type = model.getColumnClass(column); + Class type = model.getColumnClass(column); TableModel data = model; // Check for nulls @@ -339,7 +339,7 @@ int column = tableView.convertColumnIndexToModel(viewColumn); if (e.getClickCount() == 1 && column != -1) { System.out.println("Sorting ..."); - int shiftPressed = e.getModifiers() & InputEvent.SHIFT_MASK; + int shiftPressed = e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK; boolean ascending = (shiftPressed == 0); sorter.sortByColumn(column, ascending); } --- old/src/demo/share/jfc/Font2DTest/Font2DTestApplet.java 2020-01-22 16:04:09.000000000 -0800 +++ /dev/null 2020-01-22 16:04:09.000000000 -0800 @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Oracle nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -/* - */ - -import java.awt.AWTPermission; -import java.awt.Frame; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; - -import javax.swing.*; - -/** - * Font2DTestApplet.java - * - * @author Shinsuke Fukuda - * @author Ankit Patel [Conversion to Swing - 01/07/30] - */ - -/// Applet version of Font2DTest that wraps the actual demo - -public final class Font2DTestApplet extends JApplet { - public void init() { - /// Check if necessary permission is given... - SecurityManager security = System.getSecurityManager(); - if ( security != null ) { - try { - security.checkPermission( new AWTPermission( "showWindowWithoutWarningBanner" )); - } - catch ( SecurityException e ) { - System.out.println( "NOTE: showWindowWithoutWarningBanner AWTPermission not given.\n" + - "Zoom window will contain warning banner at bottom when shown\n" ); - } - try { - security.checkPrintJobAccess(); - } - catch ( SecurityException e ) { - System.out.println( "NOTE: queuePrintJob RuntimePermission not given.\n" + - "Printing feature will not be available\n" ); - } - } - - final JFrame f = new JFrame( "Font2DTest" ); - final Font2DTest f2dt = new Font2DTest( f, true ); - f.addWindowListener( new WindowAdapter() { - public void windowClosing( WindowEvent e ) { f.dispose(); } - }); - - f.getContentPane().add( f2dt ); - f.pack(); - f.show(); - } -} --- old/src/demo/share/jfc/SwingSet2/SwingSet2Applet.java 2020-01-22 16:04:09.000000000 -0800 +++ /dev/null 2020-01-22 16:04:09.000000000 -0800 @@ -1,78 +0,0 @@ -/* - * - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Oracle nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -import javax.swing.*; -import javax.swing.event.*; -import javax.swing.text.*; -import javax.swing.border.*; -import javax.swing.colorchooser.*; -import javax.swing.filechooser.*; -import javax.accessibility.*; - -import java.awt.*; -import java.awt.event.*; -import java.beans.*; -import java.util.*; -import java.io.*; -import java.applet.*; -import java.net.*; - -/** - * - * - * @author Jeff Dinkins - */ - -public class SwingSet2Applet extends JApplet { - public void init() { - getContentPane().setLayout(new BorderLayout()); - getContentPane().add(new SwingSet2(this), BorderLayout.CENTER); - } - - public URL getURL(String filename) { - URL codeBase = this.getCodeBase(); - URL url = null; - - try { - url = new URL(codeBase, filename); - System.out.println(url); - } catch (java.net.MalformedURLException e) { - System.out.println("Error: badly specified URL"); - return null; - } - - return url; - } - - -}