8237746: Fixing compiler warnings in src/demo/share/jfc
Reviewed-by: kizune, aivanov
This commit is contained in:
parent
f3ef97263f
commit
afe70e6985
@ -136,7 +136,7 @@ public class FileChooserDemo extends JPanel implements ActionListener {
|
||||
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;
|
||||
@ -158,7 +158,7 @@ public class FileChooserDemo extends JPanel implements ActionListener {
|
||||
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 @@ public class FileChooserDemo extends JPanel implements ActionListener {
|
||||
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 @@ public class FileChooserDemo extends JPanel implements ActionListener {
|
||||
frame.pack();
|
||||
} catch (UnsupportedLookAndFeelException exc) {
|
||||
// This should not happen because we already checked
|
||||
((DefaultComboBoxModel) lafComboBox.getModel()).
|
||||
((DefaultComboBoxModel<?>) lafComboBox.getModel()).
|
||||
removeElement(supportedLaF);
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,6 @@ import java.io.BufferedOutputStream;
|
||||
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 @@ 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;
|
||||
|
||||
@ -151,10 +150,10 @@ public final class Font2DTest extends JPanel
|
||||
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 @@ public final class Font2DTest extends JPanel
|
||||
userTextDialog.pack();
|
||||
userTextDialog.addWindowListener( new WindowAdapter() {
|
||||
public void windowClosing( WindowEvent e ) {
|
||||
userTextDialog.hide();
|
||||
userTextDialog.setVisible(false);
|
||||
}
|
||||
});
|
||||
|
||||
@ -385,7 +384,7 @@ public final class Font2DTest extends JPanel
|
||||
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 @@ public final class Font2DTest extends JPanel
|
||||
fontInfoDialog.setResizable( false );
|
||||
fontInfoDialog.addWindowListener( new WindowAdapter() {
|
||||
public void windowClosing( WindowEvent e ) {
|
||||
fontInfoDialog.hide();
|
||||
fontInfoDialog.setVisible(false);
|
||||
showFontInfoCBMI.setState( false );
|
||||
}
|
||||
});
|
||||
@ -467,7 +466,7 @@ public final class Font2DTest extends JPanel
|
||||
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 @@ public final class Font2DTest extends JPanel
|
||||
|
||||
/// 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 @@ public final class Font2DTest extends JPanel
|
||||
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 @@ public final class Font2DTest extends JPanel
|
||||
}
|
||||
});
|
||||
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 @@ public final class Font2DTest extends JPanel
|
||||
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 @@ public final class Font2DTest extends JPanel
|
||||
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 @@ public final class Font2DTest extends JPanel
|
||||
else if ( cbmi == showFontInfoCBMI ) {
|
||||
if ( showFontInfoCBMI.getState() ) {
|
||||
fireUpdateFontInfo();
|
||||
fontInfoDialog.show();
|
||||
fontInfoDialog.setVisible(true);
|
||||
}
|
||||
else
|
||||
fontInfoDialog.hide();
|
||||
fontInfoDialog.setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1039,7 +1038,7 @@ public final class Font2DTest extends JPanel
|
||||
|
||||
f.getContentPane().add( f2dt );
|
||||
f.pack();
|
||||
f.show();
|
||||
f.setVisible(true);
|
||||
}
|
||||
|
||||
/// Inner class definitions...
|
||||
@ -1070,7 +1069,7 @@ public final class Font2DTest extends JPanel
|
||||
}
|
||||
}
|
||||
|
||||
private final class ChoiceV2 extends JComboBox {
|
||||
private final class ChoiceV2 extends JComboBox<String> {
|
||||
|
||||
private BitSet bitSet = null;
|
||||
|
||||
@ -1141,7 +1140,7 @@ public final class Font2DTest extends JPanel
|
||||
this.choice = choice;
|
||||
}
|
||||
|
||||
public Component getListCellRendererComponent(JList list,
|
||||
public Component getListCellRendererComponent(JList<?> list,
|
||||
Object value,
|
||||
int index,
|
||||
boolean isSelected,
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
@ -74,7 +74,6 @@ import java.awt.print.PrinterJob;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.text.AttributedString;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.imageio.*;
|
||||
@ -392,7 +391,7 @@ public final class FontPanel extends JPanel implements AdjustmentListener {
|
||||
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 +433,7 @@ public final class FontPanel extends JPanel implements AdjustmentListener {
|
||||
private int canvasInset_X = 5, canvasInset_Y = 5;
|
||||
|
||||
/// LineBreak'ed TextLayout vector
|
||||
private Vector lineBreakTLs = null;
|
||||
private Vector<TextLayout> lineBreakTLs = null;
|
||||
|
||||
/// Whether the current draw command requested is for printing
|
||||
private boolean isPrinting = false;
|
||||
@ -800,7 +799,7 @@ public final class FontPanel extends JPanel implements AdjustmentListener {
|
||||
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 +928,7 @@ public final class FontPanel extends JPanel implements AdjustmentListener {
|
||||
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 +991,9 @@ public final class FontPanel extends JPanel implements AdjustmentListener {
|
||||
/// 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<TextLayout> backupLineBreakTLs = null;
|
||||
if ( textToUse == FILE_TEXT )
|
||||
backupLineBreakTLs = (Vector) lineBreakTLs.clone();
|
||||
backupLineBreakTLs = new Vector<>(lineBreakTLs);
|
||||
|
||||
printPageNumber = pageIndex;
|
||||
isPrinting = true;
|
||||
@ -1137,7 +1136,7 @@ public final class FontPanel extends JPanel implements AdjustmentListener {
|
||||
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 +1175,7 @@ public final class FontPanel extends JPanel implements AdjustmentListener {
|
||||
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 +1245,7 @@ public final class FontPanel extends JPanel implements AdjustmentListener {
|
||||
}
|
||||
public static Object getValue(int ordinal) {
|
||||
if (valArray == null) {
|
||||
valArray = (FMValues[])EnumSet.allOf(FMValues.class).toArray(new FMValues[0]);
|
||||
valArray = FMValues.values();
|
||||
}
|
||||
for (int i=0;i<valArray.length;i++) {
|
||||
if (valArray[i].ordinal() == ordinal) {
|
||||
@ -1257,7 +1256,7 @@ public final class FontPanel extends JPanel implements AdjustmentListener {
|
||||
}
|
||||
private static FMValues[] getArray() {
|
||||
if (valArray == null) {
|
||||
valArray = (FMValues[])EnumSet.allOf(FMValues.class).toArray(new FMValues[0]);
|
||||
valArray = FMValues.values();
|
||||
}
|
||||
return valArray;
|
||||
}
|
||||
@ -1308,7 +1307,7 @@ public final class FontPanel extends JPanel implements AdjustmentListener {
|
||||
|
||||
public static Object getValue(int ordinal) {
|
||||
if (valArray == null) {
|
||||
valArray = (AAValues[])EnumSet.allOf(AAValues.class).toArray(new AAValues[0]);
|
||||
valArray = AAValues.values();
|
||||
}
|
||||
for (int i=0;i<valArray.length;i++) {
|
||||
if (valArray[i].ordinal() == ordinal) {
|
||||
@ -1320,8 +1319,7 @@ public final class FontPanel extends JPanel implements AdjustmentListener {
|
||||
|
||||
private static AAValues[] getArray() {
|
||||
if (valArray == null) {
|
||||
Object [] oa = EnumSet.allOf(AAValues.class).toArray(new AAValues[0]);
|
||||
valArray = (AAValues[])(EnumSet.allOf(AAValues.class).toArray(new AAValues[0]));
|
||||
valArray = AAValues.values();
|
||||
}
|
||||
return valArray;
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ import java.util.regex.*;
|
||||
|
||||
/// Custom made choice menu that holds data for unicode range
|
||||
|
||||
public final class RangeMenu extends JComboBox implements ActionListener {
|
||||
public final class RangeMenu extends JComboBox<String> implements ActionListener {
|
||||
|
||||
private static final int[][] UNICODE_RANGES = getUnicodeRanges();
|
||||
private static final String[] UNICODE_RANGE_NAMES = getUnicodeRangeNames();
|
||||
@ -181,12 +181,12 @@ public final class RangeMenu extends JComboBox implements ActionListener {
|
||||
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 @@ public final class RangeMenu extends JComboBox implements ActionListener {
|
||||
}
|
||||
else if ( source instanceof JButton ) {
|
||||
/// Since it is only "OK" button that sends any action here...
|
||||
customRangeDialog.hide();
|
||||
customRangeDialog.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class DemoPanel extends JPanel {
|
||||
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);
|
||||
|
@ -63,7 +63,7 @@ public class GlobalControls extends JPanel implements ItemListener,
|
||||
"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<String> screenCombo;
|
||||
public TextureChooser texturechooser;
|
||||
public JCheckBox aliasCB, renderCB, toolBarCB;
|
||||
public JCheckBox compositeCB, textureCB;
|
||||
@ -83,7 +83,7 @@ public class GlobalControls extends JPanel implements ItemListener,
|
||||
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);
|
||||
|
@ -94,7 +94,7 @@ public final class Tools extends JPanel implements ActionListener,
|
||||
protected boolean focus;
|
||||
public JToggleButton toggleB;
|
||||
public JButton printB;
|
||||
public JComboBox screenCombo;
|
||||
public JComboBox<String> screenCombo;
|
||||
public JToggleButton renderB, aliasB;
|
||||
public JToggleButton textureB, compositeB;
|
||||
public JButton startStopB;
|
||||
@ -167,7 +167,7 @@ public final class Tools extends JPanel implements ActionListener,
|
||||
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) {
|
||||
|
@ -151,7 +151,6 @@ public class Areas extends ControlsSurface {
|
||||
|
||||
Areas demo;
|
||||
JToolBar toolbar;
|
||||
JComboBox combo;
|
||||
|
||||
public DemoControls(Areas demo) {
|
||||
super(demo.name);
|
||||
|
@ -51,8 +51,8 @@ import java2d.AnimatingSurface;
|
||||
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 @@ public class Tree extends AnimatingSurface {
|
||||
@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';
|
||||
}
|
||||
}
|
||||
|
@ -188,20 +188,20 @@ public class ImageOps extends ControlsSurface implements ChangeListener {
|
||||
static class DemoControls extends CustomControls implements ActionListener {
|
||||
|
||||
ImageOps demo;
|
||||
JComboBox imgCombo, opsCombo;
|
||||
JComboBox<String> 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);
|
||||
|
@ -71,7 +71,7 @@ public class Balls extends AnimatingControlsSurface {
|
||||
private boolean active;
|
||||
protected Ball[] balls = new Ball[colors.length];
|
||||
protected boolean clearToggle;
|
||||
protected JComboBox combo;
|
||||
protected JComboBox<String> combo;
|
||||
|
||||
public Balls() {
|
||||
setBackground(WHITE);
|
||||
@ -279,7 +279,7 @@ public class Balls extends AnimatingControlsSurface {
|
||||
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");
|
||||
|
@ -60,7 +60,6 @@ import java.util.logging.Logger;
|
||||
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 @@ public class BezierScroller extends AnimatingControlsSurface {
|
||||
|
||||
BezierScroller demo;
|
||||
JToolBar toolbar;
|
||||
JComboBox combo;
|
||||
|
||||
public DemoControls(BezierScroller demo) {
|
||||
super(demo.name);
|
||||
|
@ -266,13 +266,13 @@ public class GradAnim extends AnimatingControlsSurface {
|
||||
class DemoControls extends CustomControls implements ActionListener {
|
||||
|
||||
GradAnim demo;
|
||||
JComboBox combo;
|
||||
JComboBox<String> 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");
|
||||
|
@ -299,7 +299,7 @@ public final class TextureAnim extends AnimatingControlsSurface {
|
||||
|
||||
TextureAnim demo;
|
||||
JToolBar toolbar;
|
||||
JComboBox combo;
|
||||
JComboBox<String> combo;
|
||||
JMenu menu;
|
||||
JMenuItem[] menuitems;
|
||||
int iconSize = 20;
|
||||
@ -318,7 +318,7 @@ public final class TextureAnim extends AnimatingControlsSurface {
|
||||
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");
|
||||
|
@ -162,7 +162,7 @@ public final class MetalworksPrefs extends JDialog {
|
||||
|
||||
JPanel protoPanel = new JPanel();
|
||||
JLabel protoLabel = new JLabel("Protocol");
|
||||
JComboBox protocol = new JComboBox();
|
||||
JComboBox<String> protocol = new JComboBox<>();
|
||||
protocol.addItem("SMTP");
|
||||
protocol.addItem("IMAP");
|
||||
protocol.addItem("Other...");
|
||||
@ -171,7 +171,7 @@ public final class MetalworksPrefs extends JDialog {
|
||||
|
||||
JPanel attachmentPanel = new JPanel();
|
||||
JLabel attachmentLabel = new JLabel("Attachments");
|
||||
JComboBox attach = new JComboBox();
|
||||
JComboBox<String> attach = new JComboBox<>();
|
||||
attach.addItem("Download Always");
|
||||
attach.addItem("Ask size > 1 Meg");
|
||||
attach.addItem("Ask size > 5 Meg");
|
||||
|
@ -115,7 +115,7 @@ public class ElementTreePanel extends JPanel implements CaretListener,
|
||||
|
||||
if (as != null) {
|
||||
StringBuilder retBuffer = new StringBuilder("[");
|
||||
Enumeration names = as.getAttributeNames();
|
||||
Enumeration<?> names = as.getAttributeNames();
|
||||
|
||||
while (names.hasMoreElements()) {
|
||||
Object nextName = names.nextElement();
|
||||
|
@ -255,8 +255,8 @@ public class Stylepad extends Notepad {
|
||||
w.loadDocument();
|
||||
}
|
||||
|
||||
JComboBox createFamilyChoices() {
|
||||
JComboBox b = new JComboBox();
|
||||
JComboBox<String> createFamilyChoices() {
|
||||
JComboBox<String> b = new JComboBox<>();
|
||||
String[] fontNames = GraphicsEnvironment.getLocalGraphicsEnvironment().
|
||||
getAvailableFontFamilyNames();
|
||||
for (String fontName : fontNames) {
|
||||
|
@ -61,12 +61,12 @@ public class ButtonDemo extends DemoModule implements ChangeListener {
|
||||
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<Component> buttons = new Vector<>();
|
||||
Vector<Component> checkboxes = new Vector<>();
|
||||
Vector<Component> radiobuttons = new Vector<>();
|
||||
Vector<Component> togglebuttons = new Vector<>();
|
||||
|
||||
Vector currentControls = buttons;
|
||||
Vector<Component> currentControls = buttons;
|
||||
|
||||
JButton button;
|
||||
JCheckBox check;
|
||||
@ -466,12 +466,12 @@ public class ButtonDemo extends DemoModule implements ChangeListener {
|
||||
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 @@ public class ButtonDemo extends DemoModule implements ChangeListener {
|
||||
}
|
||||
}
|
||||
} 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 @@ public class ButtonDemo extends DemoModule implements ChangeListener {
|
||||
}
|
||||
}
|
||||
} 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 class ButtonDemo extends DemoModule implements ChangeListener {
|
||||
}
|
||||
}
|
||||
|
||||
public Vector getCurrentControls() {
|
||||
public Vector<Component> getCurrentControls() {
|
||||
return currentControls;
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ public class ColorChooserDemo extends DemoModule {
|
||||
okListener,
|
||||
null);
|
||||
|
||||
dialog.show();
|
||||
dialog.setVisible(true);
|
||||
|
||||
if(e.getSource() == outerColorButton) {
|
||||
bezAnim.setOuterColor(chosen);
|
||||
|
@ -57,13 +57,13 @@ public class ComboBoxDemo extends DemoModule implements ActionListener {
|
||||
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<String, Object> parts = new Hashtable<>();
|
||||
|
||||
/**
|
||||
* main method allows us to run as a standalone demo.
|
||||
@ -111,28 +111,31 @@ public class ComboBoxDemo extends DemoModule implements ActionListener {
|
||||
|
||||
JLabel l = (JLabel) comboBoxPanel.add(new JLabel(getString("ComboBoxDemo.presets")));
|
||||
l.setAlignmentX(JLabel.LEFT_ALIGNMENT);
|
||||
presetCB = (JComboBox) comboBoxPanel.add(createPresetComboBox());
|
||||
presetCB = createPresetComboBox();
|
||||
presetCB.setAlignmentX(JComboBox.LEFT_ALIGNMENT);
|
||||
l.setLabelFor(presetCB);
|
||||
comboBoxPanel.add(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 = createHairComboBox();
|
||||
hairCB.setAlignmentX(JComboBox.LEFT_ALIGNMENT);
|
||||
l.setLabelFor(hairCB);
|
||||
comboBoxPanel.add(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 = createEyesComboBox();
|
||||
eyesCB.setAlignmentX(JComboBox.LEFT_ALIGNMENT);
|
||||
l.setLabelFor(eyesCB);
|
||||
comboBoxPanel.add(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 +220,36 @@ public class ComboBoxDemo extends DemoModule implements ActionListener {
|
||||
return face;
|
||||
}
|
||||
|
||||
JComboBox createHairComboBox() {
|
||||
JComboBox cb = new JComboBox();
|
||||
JComboBox<String> createHairComboBox() {
|
||||
JComboBox<String> cb = new JComboBox<>();
|
||||
fillComboBox(cb);
|
||||
cb.addActionListener(this);
|
||||
return cb;
|
||||
}
|
||||
|
||||
JComboBox createEyesComboBox() {
|
||||
JComboBox cb = new JComboBox();
|
||||
JComboBox<String> createEyesComboBox() {
|
||||
JComboBox<String> cb = new JComboBox<>();
|
||||
fillComboBox(cb);
|
||||
cb.addActionListener(this);
|
||||
return cb;
|
||||
}
|
||||
|
||||
JComboBox createNoseComboBox() {
|
||||
JComboBox cb = new JComboBox();
|
||||
JComboBox<String> createNoseComboBox() {
|
||||
JComboBox<String> cb = new JComboBox<>();
|
||||
fillComboBox(cb);
|
||||
cb.addActionListener(this);
|
||||
return cb;
|
||||
}
|
||||
|
||||
JComboBox createMouthComboBox() {
|
||||
JComboBox cb = new JComboBox();
|
||||
JComboBox<String> createMouthComboBox() {
|
||||
JComboBox<String> cb = new JComboBox<>();
|
||||
fillComboBox(cb);
|
||||
cb.addActionListener(this);
|
||||
return cb;
|
||||
}
|
||||
|
||||
JComboBox createPresetComboBox() {
|
||||
JComboBox cb = new JComboBox();
|
||||
JComboBox<String> createPresetComboBox() {
|
||||
JComboBox<String> cb = new JComboBox<>();
|
||||
cb.addItem(getString("ComboBoxDemo.preset1"));
|
||||
cb.addItem(getString("ComboBoxDemo.preset2"));
|
||||
cb.addItem(getString("ComboBoxDemo.preset3"));
|
||||
@ -261,7 +264,7 @@ public class ComboBoxDemo extends DemoModule implements ActionListener {
|
||||
return cb;
|
||||
}
|
||||
|
||||
void fillComboBox(JComboBox cb) {
|
||||
void fillComboBox(JComboBox<String> cb) {
|
||||
cb.addItem(getString("ComboBoxDemo.brent"));
|
||||
cb.addItem(getString("ComboBoxDemo.georges"));
|
||||
cb.addItem(getString("ComboBoxDemo.hans"));
|
||||
@ -279,15 +282,15 @@ public class ComboBoxDemo extends DemoModule implements ActionListener {
|
||||
|
||||
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) {
|
||||
|
@ -51,7 +51,7 @@ import java.net.*;
|
||||
*
|
||||
* @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 @@ public class DemoModule extends JApplet {
|
||||
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) {
|
||||
|
@ -92,9 +92,9 @@ public class DirectionPanel extends JPanel {
|
||||
}
|
||||
|
||||
public void setSelection( String selection ) {
|
||||
Enumeration e = group.getElements();
|
||||
Enumeration<AbstractButton> 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 @@ public class DirectionPanel extends JPanel {
|
||||
getAccessibleContext().setAccessibleName(direction);
|
||||
getAccessibleContext().setAccessibleDescription(description);
|
||||
setSelected(selected);
|
||||
}
|
||||
|
||||
public boolean isFocusTraversable() {
|
||||
return false;
|
||||
setFocusable(false);
|
||||
}
|
||||
|
||||
public void setBorder(Border b) {
|
||||
|
@ -59,9 +59,9 @@ import java.util.Hashtable;
|
||||
* @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<String, Icon> icons = new Hashtable<>(5);
|
||||
private Hashtable<File, String> fileDescriptions = new Hashtable<>(5);
|
||||
private Hashtable<String, String> typeDescriptions = new Hashtable<>(5);
|
||||
|
||||
/**
|
||||
* The name of the file. Do nothing special here. Let
|
||||
@ -85,7 +85,7 @@ public class ExampleFileView extends FileView {
|
||||
* @see FileView#getDescription
|
||||
*/
|
||||
public String getDescription(File f) {
|
||||
return (String) fileDescriptions.get(f);
|
||||
return fileDescriptions.get(f);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -111,7 +111,7 @@ public class ExampleFileView extends FileView {
|
||||
* @see FileView#getTypeDescription
|
||||
*/
|
||||
public String getTypeDescription(File f) {
|
||||
return (String) typeDescriptions.get(getExtension(f));
|
||||
return typeDescriptions.get(getExtension(f));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -149,7 +149,7 @@ public class ExampleFileView extends FileView {
|
||||
Icon icon = null;
|
||||
String extension = getExtension(f);
|
||||
if(extension != null) {
|
||||
icon = (Icon) icons.get(extension);
|
||||
icon = icons.get(extension);
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ public class FileChooserDemo extends DemoModule {
|
||||
dialog.getContentPane().add(custom, BorderLayout.CENTER);
|
||||
dialog.pack();
|
||||
dialog.setLocationRelativeTo(getDemoPanel());
|
||||
dialog.show();
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
};
|
||||
return createButton(a);
|
||||
|
@ -59,9 +59,9 @@ public class InternalFrameDemo extends DemoModule {
|
||||
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;
|
||||
|
@ -104,7 +104,7 @@ public class LayoutControlPanel extends JPanel implements SwingConstants {
|
||||
// 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 @@ public class LayoutControlPanel extends JPanel implements SwingConstants {
|
||||
}
|
||||
|
||||
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 @@ public class LayoutControlPanel extends JPanel implements SwingConstants {
|
||||
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 @@ public class LayoutControlPanel extends JPanel implements SwingConstants {
|
||||
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();
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ import java.net.*;
|
||||
* @author Jeff Dinkins
|
||||
*/
|
||||
public class ListDemo extends DemoModule {
|
||||
JList list;
|
||||
JList<String> list;
|
||||
|
||||
JPanel prefixList;
|
||||
JPanel suffixList;
|
||||
@ -69,7 +69,7 @@ public class ListDemo extends DemoModule {
|
||||
|
||||
GeneratedListModel listModel;
|
||||
|
||||
Vector checkboxes = new Vector();
|
||||
Vector<JCheckBox> checkboxes = new Vector<>();
|
||||
|
||||
/**
|
||||
* main method allows us to run as a standalone demo.
|
||||
@ -103,7 +103,7 @@ public class ListDemo extends DemoModule {
|
||||
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 @@ public class ListDemo extends DemoModule {
|
||||
}
|
||||
|
||||
|
||||
class GeneratedListModel extends AbstractListModel {
|
||||
class GeneratedListModel extends AbstractListModel<String> {
|
||||
ListDemo demo;
|
||||
Permuter permuter;
|
||||
|
||||
public Vector prefix = new Vector();
|
||||
public Vector suffix = new Vector();
|
||||
public Vector<String> prefix = new Vector<>();
|
||||
public Vector<String> suffix = new Vector<>();
|
||||
|
||||
public GeneratedListModel (ListDemo demo) {
|
||||
this.demo = demo;
|
||||
@ -337,7 +337,7 @@ public class ListDemo extends DemoModule {
|
||||
return prefix.size() * suffix.size();
|
||||
}
|
||||
|
||||
public Object getElementAt(int index) {
|
||||
public String getElementAt(int index) {
|
||||
if(permuter == null) {
|
||||
update();
|
||||
}
|
||||
@ -363,7 +363,7 @@ public class ListDemo extends DemoModule {
|
||||
|
||||
class CompanyLogoListCellRenderer extends DefaultListCellRenderer {
|
||||
public Component getListCellRendererComponent(
|
||||
JList list,
|
||||
JList<?> list,
|
||||
Object value,
|
||||
int index,
|
||||
boolean isSelected,
|
||||
|
@ -163,7 +163,7 @@ public class OptionPaneDemo extends DemoModule {
|
||||
message[0] = getString("OptionPaneDemo.componentmessage");
|
||||
message[1] = new JTextField(getString("OptionPaneDemo.componenttextfield"));
|
||||
|
||||
JComboBox cb = new JComboBox();
|
||||
JComboBox<String> cb = new JComboBox<>();
|
||||
cb.addItem(getString("OptionPaneDemo.component_cb1"));
|
||||
cb.addItem(getString("OptionPaneDemo.component_cb2"));
|
||||
cb.addItem(getString("OptionPaneDemo.component_cb3"));
|
||||
|
@ -164,7 +164,9 @@ public class SliderDemo extends DemoModule {
|
||||
s.setPaintLabels( true );
|
||||
s.setSnapToTicks( true );
|
||||
|
||||
s.getLabelTable().put(new Integer(11), new JLabel(new Integer(11).toString(), JLabel.CENTER));
|
||||
@SuppressWarnings("unchecked")
|
||||
Dictionary<Object, Object> 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"));
|
||||
|
@ -165,7 +165,7 @@ public class SplitPaneDemo extends DemoModule {
|
||||
JLabel label;
|
||||
|
||||
divSize = new JTextField();
|
||||
divSize.setText(new Integer(splitPane.getDividerSize()).toString());
|
||||
divSize.setText(Integer.toString(splitPane.getDividerSize()));
|
||||
divSize.setColumns(5);
|
||||
divSize.getAccessibleContext().setAccessibleName(getString("SplitPaneDemo.divider_size"));
|
||||
divSize.addActionListener(new ActionListener() {
|
||||
|
@ -71,12 +71,7 @@ public class SwingSet2 extends JPanel {
|
||||
|
||||
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]);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@ -126,9 +121,6 @@ public class SwingSet2 extends JPanel {
|
||||
// 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 @@ public class SwingSet2 extends JPanel {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// set the layout
|
||||
setLayout(new BorderLayout());
|
||||
@ -198,7 +184,7 @@ public class SwingSet2 extends JPanel {
|
||||
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 @@ public class SwingSet2 extends JPanel {
|
||||
|
||||
menuBar = createMenus();
|
||||
|
||||
if (isApplet()) {
|
||||
applet.setJMenuBar(menuBar);
|
||||
} else {
|
||||
frame.setJMenuBar(menuBar);
|
||||
}
|
||||
|
||||
// creates popup menu accessible via keyboard
|
||||
popupMenu = createPopupMenu();
|
||||
@ -309,13 +291,11 @@ public class SwingSet2 extends JPanel {
|
||||
"FileMenu.save_as_accessible_description", null);
|
||||
|
||||
|
||||
if(!isApplet()) {
|
||||
fileMenu.addSeparator();
|
||||
|
||||
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 @@ public class SwingSet2 extends JPanel {
|
||||
|
||||
|
||||
// ***** create the multiscreen menu, if we have multiple screens
|
||||
if (!isApplet()) {
|
||||
GraphicsDevice[] screens = GraphicsEnvironment.
|
||||
getLocalGraphicsEnvironment().
|
||||
getScreenDevices();
|
||||
@ -449,7 +428,6 @@ public class SwingSet2 extends JPanel {
|
||||
createMultiscreenMenuItem(multiScreenMenu, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return menuBar;
|
||||
}
|
||||
@ -578,7 +556,7 @@ public class SwingSet2 extends JPanel {
|
||||
|
||||
// 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,11 +637,9 @@ public class SwingSet2 extends JPanel {
|
||||
|
||||
|
||||
/**
|
||||
* 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"));
|
||||
@ -686,11 +662,10 @@ public class SwingSet2 extends JPanel {
|
||||
screenInsets.top : centerHeight;
|
||||
|
||||
f.setLocation(centerWidth, centerHeight);
|
||||
f.show();
|
||||
f.setVisible(true);
|
||||
numSSs++;
|
||||
swingSets.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
// *******************************************************
|
||||
// ****************** Utility Methods ********************
|
||||
@ -703,8 +678,8 @@ public class SwingSet2 extends JPanel {
|
||||
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) {
|
||||
@ -712,21 +687,6 @@ public class SwingSet2 extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@ -763,8 +723,6 @@ public class SwingSet2 extends JPanel {
|
||||
if(contentPane == null) {
|
||||
if(getFrame() != null) {
|
||||
contentPane = getFrame().getContentPane();
|
||||
} else if (getApplet() != null) {
|
||||
contentPane = getApplet().getContentPane();
|
||||
}
|
||||
}
|
||||
return contentPane;
|
||||
@ -886,16 +844,12 @@ public class SwingSet2 extends JPanel {
|
||||
}
|
||||
|
||||
private void updateThisSwingSet() {
|
||||
if (isApplet()) {
|
||||
SwingUtilities.updateComponentTreeUI(getApplet());
|
||||
} else {
|
||||
JFrame frame = getFrame();
|
||||
if (frame == null) {
|
||||
SwingUtilities.updateComponentTreeUI(this);
|
||||
} else {
|
||||
SwingUtilities.updateComponentTreeUI(frame);
|
||||
}
|
||||
}
|
||||
|
||||
SwingUtilities.updateComponentTreeUI(popupMenu);
|
||||
if (aboutBox != null) {
|
||||
@ -909,13 +863,9 @@ public class SwingSet2 extends JPanel {
|
||||
public void updateLookAndFeel() {
|
||||
try {
|
||||
UIManager.setLookAndFeel(currentLookAndFeel.className);
|
||||
if (isApplet()) {
|
||||
updateThisSwingSet();
|
||||
} else {
|
||||
for (SwingSet2 ss : swingSets) {
|
||||
ss.updateThisSwingSet();
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
System.out.println("Failed loading L&F: " + currentLookAndFeel);
|
||||
System.out.println(ex);
|
||||
@ -1142,15 +1092,11 @@ public class SwingSet2 extends JPanel {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
boolean dragEnabled = ((JCheckBoxMenuItem)e.getSource()).isSelected();
|
||||
if (isApplet()) {
|
||||
setDragEnabled(dragEnabled);
|
||||
} else {
|
||||
for (SwingSet2 ss : swingSets) {
|
||||
ss.setDragEnabled(dragEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ChangeThemeAction extends AbstractAction {
|
||||
SwingSet2 swingset;
|
||||
@ -1208,12 +1154,8 @@ public class SwingSet2 extends JPanel {
|
||||
button.addActionListener(new OkAction(aboutBox));
|
||||
}
|
||||
aboutBox.pack();
|
||||
if (isApplet()) {
|
||||
aboutBox.setLocationRelativeTo(getApplet());
|
||||
} else {
|
||||
aboutBox.setLocationRelativeTo(getFrame());
|
||||
}
|
||||
aboutBox.show();
|
||||
aboutBox.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1231,13 +1173,13 @@ public class SwingSet2 extends JPanel {
|
||||
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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -75,8 +75,8 @@ public class TableDemo extends DemoModule {
|
||||
JSlider interCellSpacingSlider;
|
||||
JSlider rowHeightSlider;
|
||||
|
||||
JComboBox selectionModeComboBox = null;
|
||||
JComboBox resizeModeComboBox = null;
|
||||
JComboBox<String> selectionModeComboBox = null;
|
||||
JComboBox<String> resizeModeComboBox = null;
|
||||
|
||||
JLabel headerLabel;
|
||||
JLabel footerLabel;
|
||||
@ -126,7 +126,7 @@ public class TableDemo extends DemoModule {
|
||||
JPanel printPanel = new JPanel(new ColumnLayout());
|
||||
|
||||
getDemoPanel().add(controlPanel, BorderLayout.NORTH);
|
||||
Vector relatedComponents = new Vector();
|
||||
Vector<JComponent> relatedComponents = new Vector<>();
|
||||
|
||||
|
||||
// check box panel
|
||||
@ -245,7 +245,7 @@ public class TableDemo extends DemoModule {
|
||||
selectMode.setBorder(new TitledBorder(getString("TableDemo.selection_mode")));
|
||||
|
||||
|
||||
selectionModeComboBox = new JComboBox() {
|
||||
selectionModeComboBox = new JComboBox<>() {
|
||||
public Dimension getMaximumSize() {
|
||||
return getPreferredSize();
|
||||
}
|
||||
@ -256,7 +256,7 @@ public class TableDemo extends DemoModule {
|
||||
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 @@ public class TableDemo extends DemoModule {
|
||||
resizeMode.setBorder(new TitledBorder(getString("TableDemo.autoresize_mode")));
|
||||
|
||||
|
||||
resizeModeComboBox = new JComboBox() {
|
||||
resizeModeComboBox = new JComboBox<>() {
|
||||
public Dimension getMaximumSize() {
|
||||
return getPreferredSize();
|
||||
}
|
||||
@ -285,7 +285,7 @@ public class TableDemo extends DemoModule {
|
||||
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 @@ public class TableDemo extends DemoModule {
|
||||
*
|
||||
* @param components The list of objects that are related
|
||||
*/
|
||||
void buildAccessibleGroup(Vector components) {
|
||||
void buildAccessibleGroup(Vector<JComponent> components) {
|
||||
|
||||
AccessibleContext context = null;
|
||||
int numComponents = components.size();
|
||||
@ -492,55 +492,55 @@ public class TableDemo extends DemoModule {
|
||||
|
||||
// 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},
|
||||
{"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"), 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},
|
||||
{"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 class TableDemo extends DemoModule {
|
||||
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 @@ public class TableDemo extends DemoModule {
|
||||
|
||||
// Create the table
|
||||
tableView = new JTable(dataModel);
|
||||
TableRowSorter sorter = new TableRowSorter(dataModel);
|
||||
TableRowSorter<TableModel> sorter = new TableRowSorter<>(dataModel);
|
||||
tableView.setRowSorter(sorter);
|
||||
|
||||
// Show colors by rendering them in their own color.
|
||||
@ -575,7 +575,7 @@ public class TableDemo extends DemoModule {
|
||||
};
|
||||
|
||||
// Create a combo box to show that you can use one in a table.
|
||||
JComboBox comboBox = new JComboBox();
|
||||
JComboBox<NamedColor> comboBox = new JComboBox<>();
|
||||
comboBox.addItem(aqua);
|
||||
comboBox.addItem(beige);
|
||||
comboBox.addItem(black);
|
||||
|
@ -125,12 +125,6 @@ public class JDBCAdapter extends AbstractTableModel {
|
||||
connection.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
close();
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Implementation of the TableModel Interface
|
||||
|
@ -72,7 +72,7 @@ public class OldJTable extends JTable
|
||||
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 class OldJTable extends JTable
|
||||
|
||||
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 @@ public class OldJTable extends JTable
|
||||
((DefaultTableModel)getModel()).addRow(rowData);
|
||||
}
|
||||
|
||||
public void addRow(List rowData) {
|
||||
public void addRow(List<?> rowData) {
|
||||
checkDefaultTableModel();
|
||||
((DefaultTableModel)getModel()).addRow(rowData.toArray());
|
||||
}
|
||||
@ -132,7 +132,7 @@ public class OldJTable extends JTable
|
||||
((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 @@ public class OldJTable extends JTable
|
||||
((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());
|
||||
|
@ -73,27 +73,27 @@ public class TableExample3 {
|
||||
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 @@ public class TableExample3 {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getColumnClass(int col) {
|
||||
public Class<?> getColumnClass(int col) {
|
||||
return getValueAt(0, col).getClass();
|
||||
}
|
||||
|
||||
|
@ -75,27 +75,27 @@ public class TableExample4 {
|
||||
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 @@ public class TableExample4 {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getColumnClass(int c) {
|
||||
public Class<?> getColumnClass(int c) {
|
||||
return getValueAt(0, c).getClass();
|
||||
}
|
||||
|
||||
@ -147,7 +147,7 @@ public class TableExample4 {
|
||||
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<String> comboBox = new JComboBox<>();
|
||||
comboBox.addItem("Red");
|
||||
comboBox.addItem("Orange");
|
||||
comboBox.addItem("Yellow");
|
||||
|
@ -94,7 +94,7 @@ public class TableMap extends AbstractTableModel implements TableModelListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getColumnClass(int aColumn) {
|
||||
public Class<?> getColumnClass(int aColumn) {
|
||||
return model.getColumnClass(aColumn);
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ public final class TableSorter extends TableMap {
|
||||
}
|
||||
|
||||
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 @@ public final class TableSorter extends TableMap {
|
||||
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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user