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 openRadioButton;
|
||||||
private JRadioButton saveRadioButton;
|
private JRadioButton saveRadioButton;
|
||||||
private JRadioButton customButton;
|
private JRadioButton customButton;
|
||||||
private JComboBox lafComboBox;
|
private JComboBox<SupportedLaF> lafComboBox;
|
||||||
private JRadioButton justFilesRadioButton;
|
private JRadioButton justFilesRadioButton;
|
||||||
private JRadioButton justDirectoriesRadioButton;
|
private JRadioButton justDirectoriesRadioButton;
|
||||||
private JRadioButton bothFilesAndDirectoriesRadioButton;
|
private JRadioButton bothFilesAndDirectoriesRadioButton;
|
||||||
@ -158,7 +158,7 @@ public class FileChooserDemo extends JPanel implements ActionListener {
|
|||||||
for (UIManager.LookAndFeelInfo lafInfo : installedLafs) {
|
for (UIManager.LookAndFeelInfo lafInfo : installedLafs) {
|
||||||
try {
|
try {
|
||||||
Class<?> lnfClass = Class.forName(lafInfo.getClassName());
|
Class<?> lnfClass = Class.forName(lafInfo.getClassName());
|
||||||
LookAndFeel laf = (LookAndFeel) (lnfClass.newInstance());
|
LookAndFeel laf = (LookAndFeel) (lnfClass.getDeclaredConstructor().newInstance());
|
||||||
if (laf.isSupportedLookAndFeel()) {
|
if (laf.isSupportedLookAndFeel()) {
|
||||||
String name = lafInfo.getName();
|
String name = lafInfo.getName();
|
||||||
SupportedLaF supportedLaF = new SupportedLaF(name, laf);
|
SupportedLaF supportedLaF = new SupportedLaF(name, laf);
|
||||||
@ -292,7 +292,7 @@ public class FileChooserDemo extends JPanel implements ActionListener {
|
|||||||
showButton.setMnemonic('s');
|
showButton.setMnemonic('s');
|
||||||
|
|
||||||
// Create laf combo box
|
// Create laf combo box
|
||||||
lafComboBox = new JComboBox(supportedLaFs.toArray());
|
lafComboBox = new JComboBox<>(supportedLaFs.toArray(new SupportedLaF[0]));
|
||||||
lafComboBox.setSelectedItem(nimbusLaF);
|
lafComboBox.setSelectedItem(nimbusLaF);
|
||||||
lafComboBox.setEditable(false);
|
lafComboBox.setEditable(false);
|
||||||
lafComboBox.addActionListener(optionListener);
|
lafComboBox.addActionListener(optionListener);
|
||||||
@ -729,7 +729,7 @@ public class FileChooserDemo extends JPanel implements ActionListener {
|
|||||||
frame.pack();
|
frame.pack();
|
||||||
} catch (UnsupportedLookAndFeelException exc) {
|
} catch (UnsupportedLookAndFeelException exc) {
|
||||||
// This should not happen because we already checked
|
// This should not happen because we already checked
|
||||||
((DefaultComboBoxModel) lafComboBox.getModel()).
|
((DefaultComboBoxModel<?>) lafComboBox.getModel()).
|
||||||
removeElement(supportedLaF);
|
removeElement(supportedLaF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,6 @@ import java.io.BufferedOutputStream;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@ -101,8 +100,8 @@ public final class Font2DTest extends JPanel
|
|||||||
private final ChoiceV2 transformMenu;
|
private final ChoiceV2 transformMenu;
|
||||||
private final ChoiceV2 transformMenuG2;
|
private final ChoiceV2 transformMenuG2;
|
||||||
private final ChoiceV2 methodsMenu;
|
private final ChoiceV2 methodsMenu;
|
||||||
private final JComboBox antiAliasMenu;
|
private final JComboBox<FontPanel.AAValues> antiAliasMenu;
|
||||||
private final JComboBox fracMetricsMenu;
|
private final JComboBox<FontPanel.FMValues> fracMetricsMenu;
|
||||||
|
|
||||||
private final JSlider contrastSlider;
|
private final JSlider contrastSlider;
|
||||||
|
|
||||||
@ -151,10 +150,10 @@ public final class Font2DTest extends JPanel
|
|||||||
methodsMenu = new ChoiceV2( this );
|
methodsMenu = new ChoiceV2( this );
|
||||||
|
|
||||||
antiAliasMenu =
|
antiAliasMenu =
|
||||||
new JComboBox(EnumSet.allOf(FontPanel.AAValues.class).toArray());
|
new JComboBox<>(FontPanel.AAValues.values());
|
||||||
antiAliasMenu.addActionListener(this);
|
antiAliasMenu.addActionListener(this);
|
||||||
fracMetricsMenu =
|
fracMetricsMenu =
|
||||||
new JComboBox(EnumSet.allOf(FontPanel.FMValues.class).toArray());
|
new JComboBox<>(FontPanel.FMValues.values());
|
||||||
fracMetricsMenu.addActionListener(this);
|
fracMetricsMenu.addActionListener(this);
|
||||||
|
|
||||||
contrastSlider = new JSlider(JSlider.HORIZONTAL, 100, 250,
|
contrastSlider = new JSlider(JSlider.HORIZONTAL, 100, 250,
|
||||||
@ -359,7 +358,7 @@ public final class Font2DTest extends JPanel
|
|||||||
userTextDialog.pack();
|
userTextDialog.pack();
|
||||||
userTextDialog.addWindowListener( new WindowAdapter() {
|
userTextDialog.addWindowListener( new WindowAdapter() {
|
||||||
public void windowClosing( WindowEvent e ) {
|
public void windowClosing( WindowEvent e ) {
|
||||||
userTextDialog.hide();
|
userTextDialog.setVisible(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -385,7 +384,7 @@ public final class Font2DTest extends JPanel
|
|||||||
printDialog.setResizable( false );
|
printDialog.setResizable( false );
|
||||||
printDialog.addWindowListener( new WindowAdapter() {
|
printDialog.addWindowListener( new WindowAdapter() {
|
||||||
public void windowClosing( WindowEvent e ) {
|
public void windowClosing( WindowEvent e ) {
|
||||||
printDialog.hide();
|
printDialog.setVisible(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
printDialog.getContentPane().setLayout( new GridLayout( printModeCBs.length + 2, 1 ));
|
printDialog.getContentPane().setLayout( new GridLayout( printModeCBs.length + 2, 1 ));
|
||||||
@ -402,7 +401,7 @@ public final class Font2DTest extends JPanel
|
|||||||
fontInfoDialog.setResizable( false );
|
fontInfoDialog.setResizable( false );
|
||||||
fontInfoDialog.addWindowListener( new WindowAdapter() {
|
fontInfoDialog.addWindowListener( new WindowAdapter() {
|
||||||
public void windowClosing( WindowEvent e ) {
|
public void windowClosing( WindowEvent e ) {
|
||||||
fontInfoDialog.hide();
|
fontInfoDialog.setVisible(false);
|
||||||
showFontInfoCBMI.setState( false );
|
showFontInfoCBMI.setState( false );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -467,7 +466,7 @@ public final class Font2DTest extends JPanel
|
|||||||
int style = fontStyles[styleMenu.getSelectedIndex()];
|
int style = fontStyles[styleMenu.getSelectedIndex()];
|
||||||
Font f;
|
Font f;
|
||||||
for (int i = 0; i < listCount; i++) {
|
for (int i = 0; i < listCount; i++) {
|
||||||
String fontName = (String)fontMenu.getItemAt(i);
|
String fontName = fontMenu.getItemAt(i);
|
||||||
f = new Font(fontName, style, size);
|
f = new Font(fontName, style, size);
|
||||||
if ((rm.getSelectedIndex() != RangeMenu.SURROGATES_AREA_INDEX) &&
|
if ((rm.getSelectedIndex() != RangeMenu.SURROGATES_AREA_INDEX) &&
|
||||||
canDisplayRange(f, rangeStart, rangeEnd)) {
|
canDisplayRange(f, rangeStart, rangeEnd)) {
|
||||||
@ -673,9 +672,9 @@ public final class Font2DTest extends JPanel
|
|||||||
|
|
||||||
/// Set the visibility of User Text dialog
|
/// Set the visibility of User Text dialog
|
||||||
if ( selectedText == fp.USER_TEXT )
|
if ( selectedText == fp.USER_TEXT )
|
||||||
userTextDialog.show();
|
userTextDialog.setVisible(true);
|
||||||
else
|
else
|
||||||
userTextDialog.hide();
|
userTextDialog.setVisible(false);
|
||||||
/// Change the visibility/status/availability of Print JDialog buttons
|
/// Change the visibility/status/availability of Print JDialog buttons
|
||||||
printModeCBs[ fp.ONE_PAGE ].setSelected( true );
|
printModeCBs[ fp.ONE_PAGE ].setSelected( true );
|
||||||
if ( selectedText == fp.FILE_TEXT || selectedText == fp.USER_TEXT ) {
|
if ( selectedText == fp.FILE_TEXT || selectedText == fp.USER_TEXT ) {
|
||||||
@ -793,10 +792,10 @@ public final class Font2DTest extends JPanel
|
|||||||
lcdContrast, userTextOpt );
|
lcdContrast, userTextOpt );
|
||||||
if ( showFontInfoOpt ) {
|
if ( showFontInfoOpt ) {
|
||||||
fireUpdateFontInfo();
|
fireUpdateFontInfo();
|
||||||
fontInfoDialog.show();
|
fontInfoDialog.setVisible(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fontInfoDialog.hide();
|
fontInfoDialog.setVisible(false);
|
||||||
}
|
}
|
||||||
catch ( Exception ex ) {
|
catch ( Exception ex ) {
|
||||||
fireChangeStatus( "ERROR: Failed to Load Options File; See Stack Trace", true );
|
fireChangeStatus( "ERROR: Failed to Load Options File; See Stack Trace", true );
|
||||||
@ -819,7 +818,7 @@ public final class Font2DTest extends JPanel
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
f.pack();
|
f.pack();
|
||||||
f.show();
|
f.setVisible(true);
|
||||||
}
|
}
|
||||||
catch ( Exception ex ) {
|
catch ( Exception ex ) {
|
||||||
fireChangeStatus( "ERROR: Failed to Load PNG File; See Stack Trace", true );
|
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..." ))
|
else if ( itemName.equals( "Page Setup..." ))
|
||||||
fp.doPageSetup();
|
fp.doPageSetup();
|
||||||
else if ( itemName.equals( "Print..." ))
|
else if ( itemName.equals( "Print..." ))
|
||||||
printDialog.show();
|
printDialog.setVisible(true);
|
||||||
else if ( itemName.equals( "Close" ))
|
else if ( itemName.equals( "Close" ))
|
||||||
parent.dispose();
|
parent.dispose();
|
||||||
else if ( itemName.equals( "Exit" ))
|
else if ( itemName.equals( "Exit" ))
|
||||||
@ -893,19 +892,19 @@ public final class Font2DTest extends JPanel
|
|||||||
if ( itemName.equals( "Print" )) {
|
if ( itemName.equals( "Print" )) {
|
||||||
for ( int i = 0; i < printModeCBs.length; i++ )
|
for ( int i = 0; i < printModeCBs.length; i++ )
|
||||||
if ( printModeCBs[i].isSelected() ) {
|
if ( printModeCBs[i].isSelected() ) {
|
||||||
printDialog.hide();
|
printDialog.setVisible(false);
|
||||||
fp.doPrint( i );
|
fp.doPrint( i );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( itemName.equals( "Cancel" ))
|
else if ( itemName.equals( "Cancel" ))
|
||||||
printDialog.hide();
|
printDialog.setVisible(false);
|
||||||
/// Update button from Usert Text JDialog...
|
/// Update button from Usert Text JDialog...
|
||||||
else if ( itemName.equals( "Update" ))
|
else if ( itemName.equals( "Update" ))
|
||||||
fp.setTextToDraw( fp.USER_TEXT, null,
|
fp.setTextToDraw( fp.USER_TEXT, null,
|
||||||
parseUserText( userTextArea.getText() ), null );
|
parseUserText( userTextArea.getText() ), null );
|
||||||
}
|
}
|
||||||
else if ( source instanceof JComboBox ) {
|
else if ( source instanceof JComboBox ) {
|
||||||
JComboBox c = (JComboBox) source;
|
JComboBox<?> c = (JComboBox<?>) source;
|
||||||
|
|
||||||
/// RangeMenu handles actions by itself and then calls fireRangeChanged,
|
/// RangeMenu handles actions by itself and then calls fireRangeChanged,
|
||||||
/// so it is not listed or handled here
|
/// so it is not listed or handled here
|
||||||
@ -996,10 +995,10 @@ public final class Font2DTest extends JPanel
|
|||||||
else if ( cbmi == showFontInfoCBMI ) {
|
else if ( cbmi == showFontInfoCBMI ) {
|
||||||
if ( showFontInfoCBMI.getState() ) {
|
if ( showFontInfoCBMI.getState() ) {
|
||||||
fireUpdateFontInfo();
|
fireUpdateFontInfo();
|
||||||
fontInfoDialog.show();
|
fontInfoDialog.setVisible(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fontInfoDialog.hide();
|
fontInfoDialog.setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1039,7 +1038,7 @@ public final class Font2DTest extends JPanel
|
|||||||
|
|
||||||
f.getContentPane().add( f2dt );
|
f.getContentPane().add( f2dt );
|
||||||
f.pack();
|
f.pack();
|
||||||
f.show();
|
f.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Inner class definitions...
|
/// 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;
|
private BitSet bitSet = null;
|
||||||
|
|
||||||
@ -1141,7 +1140,7 @@ public final class Font2DTest extends JPanel
|
|||||||
this.choice = choice;
|
this.choice = choice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Component getListCellRendererComponent(JList list,
|
public Component getListCellRendererComponent(JList<?> list,
|
||||||
Object value,
|
Object value,
|
||||||
int index,
|
int index,
|
||||||
boolean isSelected,
|
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.BufferedOutputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.text.AttributedString;
|
import java.text.AttributedString;
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import javax.imageio.*;
|
import javax.imageio.*;
|
||||||
@ -392,7 +391,7 @@ public final class FontPanel extends JPanel implements AdjustmentListener {
|
|||||||
setTransformG2( g2transform ); // ABP
|
setTransformG2( g2transform ); // ABP
|
||||||
setDrawMethod( method );
|
setDrawMethod( method );
|
||||||
setRenderingHints(AAValues.getValue(aa), FMValues.getValue(fm),
|
setRenderingHints(AAValues.getValue(aa), FMValues.getValue(fm),
|
||||||
new Integer(contrast));
|
Integer.valueOf(contrast));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Writes the current screen to PNG file
|
/// 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;
|
private int canvasInset_X = 5, canvasInset_Y = 5;
|
||||||
|
|
||||||
/// LineBreak'ed TextLayout vector
|
/// LineBreak'ed TextLayout vector
|
||||||
private Vector lineBreakTLs = null;
|
private Vector<TextLayout> lineBreakTLs = null;
|
||||||
|
|
||||||
/// Whether the current draw command requested is for printing
|
/// Whether the current draw command requested is for printing
|
||||||
private boolean isPrinting = false;
|
private boolean isPrinting = false;
|
||||||
@ -800,7 +799,7 @@ public final class FontPanel extends JPanel implements AdjustmentListener {
|
|||||||
if ( textToUse == FILE_TEXT ) {
|
if ( textToUse == FILE_TEXT ) {
|
||||||
if ( !isPrinting )
|
if ( !isPrinting )
|
||||||
f2dt.fireChangeStatus( "LineBreaking Text... Please Wait", false );
|
f2dt.fireChangeStatus( "LineBreaking Text... Please Wait", false );
|
||||||
lineBreakTLs = new Vector();
|
lineBreakTLs = new Vector<>();
|
||||||
for ( int i = 0; i < fileText.length; i++ ) {
|
for ( int i = 0; i < fileText.length; i++ ) {
|
||||||
AttributedString as =
|
AttributedString as =
|
||||||
new AttributedString( fileText[i], g2.getFont().getAttributes() );
|
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;
|
float xPos, yPos = (float) canvasInset_Y;
|
||||||
g2.drawRect( 0, 0, w - 1, h - 1 );
|
g2.drawRect( 0, 0, w - 1, h - 1 );
|
||||||
for ( int i = drawStart; i <= drawEnd; i++ ) {
|
for ( int i = drawStart; i <= drawEnd; i++ ) {
|
||||||
TextLayout oneLine = (TextLayout) lineBreakTLs.elementAt( i );
|
TextLayout oneLine = lineBreakTLs.elementAt( i );
|
||||||
xPos =
|
xPos =
|
||||||
oneLine.isLeftToRight() ?
|
oneLine.isLeftToRight() ?
|
||||||
canvasInset_X : ( (float) w - oneLine.getAdvance() - canvasInset_X );
|
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
|
/// Back up metrics and other drawing info before printing modifies it
|
||||||
int backupDrawStart = drawStart, backupDrawEnd = drawEnd;
|
int backupDrawStart = drawStart, backupDrawEnd = drawEnd;
|
||||||
int backupNumCharAcross = numCharAcross, backupNumCharDown = numCharDown;
|
int backupNumCharAcross = numCharAcross, backupNumCharDown = numCharDown;
|
||||||
Vector backupLineBreakTLs = null;
|
Vector<TextLayout> backupLineBreakTLs = null;
|
||||||
if ( textToUse == FILE_TEXT )
|
if ( textToUse == FILE_TEXT )
|
||||||
backupLineBreakTLs = (Vector) lineBreakTLs.clone();
|
backupLineBreakTLs = new Vector<>(lineBreakTLs);
|
||||||
|
|
||||||
printPageNumber = pageIndex;
|
printPageNumber = pageIndex;
|
||||||
isPrinting = true;
|
isPrinting = true;
|
||||||
@ -1137,7 +1136,7 @@ public final class FontPanel extends JPanel implements AdjustmentListener {
|
|||||||
zoomAreaWidth / 2, (int) ( maxAscent * ZOOM ));
|
zoomAreaWidth / 2, (int) ( maxAscent * ZOOM ));
|
||||||
g2.dispose();
|
g2.dispose();
|
||||||
if ( !nowZooming )
|
if ( !nowZooming )
|
||||||
zoomWindow.show();
|
zoomWindow.setVisible(true);
|
||||||
/// This is sort of redundant... since there is a paint function
|
/// This is sort of redundant... since there is a paint function
|
||||||
/// inside zoomWindow definition that does the drawImage.
|
/// inside zoomWindow definition that does the drawImage.
|
||||||
/// (I should be able to call just repaint() here)
|
/// (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 ) {
|
public void mouseReleased( MouseEvent e ) {
|
||||||
if ( textToUse == RANGE_TEXT || textToUse == ALL_GLYPHS ) {
|
if ( textToUse == RANGE_TEXT || textToUse == ALL_GLYPHS ) {
|
||||||
if ( nowZooming )
|
if ( nowZooming )
|
||||||
zoomWindow.hide();
|
zoomWindow.setVisible(false);
|
||||||
nowZooming = false;
|
nowZooming = false;
|
||||||
}
|
}
|
||||||
this.setCursor( Cursor.getDefaultCursor() );
|
this.setCursor( Cursor.getDefaultCursor() );
|
||||||
@ -1246,7 +1245,7 @@ public final class FontPanel extends JPanel implements AdjustmentListener {
|
|||||||
}
|
}
|
||||||
public static Object getValue(int ordinal) {
|
public static Object getValue(int ordinal) {
|
||||||
if (valArray == null) {
|
if (valArray == null) {
|
||||||
valArray = (FMValues[])EnumSet.allOf(FMValues.class).toArray(new FMValues[0]);
|
valArray = FMValues.values();
|
||||||
}
|
}
|
||||||
for (int i=0;i<valArray.length;i++) {
|
for (int i=0;i<valArray.length;i++) {
|
||||||
if (valArray[i].ordinal() == ordinal) {
|
if (valArray[i].ordinal() == ordinal) {
|
||||||
@ -1257,7 +1256,7 @@ public final class FontPanel extends JPanel implements AdjustmentListener {
|
|||||||
}
|
}
|
||||||
private static FMValues[] getArray() {
|
private static FMValues[] getArray() {
|
||||||
if (valArray == null) {
|
if (valArray == null) {
|
||||||
valArray = (FMValues[])EnumSet.allOf(FMValues.class).toArray(new FMValues[0]);
|
valArray = FMValues.values();
|
||||||
}
|
}
|
||||||
return valArray;
|
return valArray;
|
||||||
}
|
}
|
||||||
@ -1308,7 +1307,7 @@ public final class FontPanel extends JPanel implements AdjustmentListener {
|
|||||||
|
|
||||||
public static Object getValue(int ordinal) {
|
public static Object getValue(int ordinal) {
|
||||||
if (valArray == null) {
|
if (valArray == null) {
|
||||||
valArray = (AAValues[])EnumSet.allOf(AAValues.class).toArray(new AAValues[0]);
|
valArray = AAValues.values();
|
||||||
}
|
}
|
||||||
for (int i=0;i<valArray.length;i++) {
|
for (int i=0;i<valArray.length;i++) {
|
||||||
if (valArray[i].ordinal() == ordinal) {
|
if (valArray[i].ordinal() == ordinal) {
|
||||||
@ -1320,8 +1319,7 @@ public final class FontPanel extends JPanel implements AdjustmentListener {
|
|||||||
|
|
||||||
private static AAValues[] getArray() {
|
private static AAValues[] getArray() {
|
||||||
if (valArray == null) {
|
if (valArray == null) {
|
||||||
Object [] oa = EnumSet.allOf(AAValues.class).toArray(new AAValues[0]);
|
valArray = AAValues.values();
|
||||||
valArray = (AAValues[])(EnumSet.allOf(AAValues.class).toArray(new AAValues[0]));
|
|
||||||
}
|
}
|
||||||
return valArray;
|
return valArray;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ import java.util.regex.*;
|
|||||||
|
|
||||||
/// Custom made choice menu that holds data for unicode range
|
/// 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 int[][] UNICODE_RANGES = getUnicodeRanges();
|
||||||
private static final String[] UNICODE_RANGE_NAMES = getUnicodeRangeNames();
|
private static final String[] UNICODE_RANGE_NAMES = getUnicodeRangeNames();
|
||||||
@ -181,12 +181,12 @@ public final class RangeMenu extends JComboBox implements ActionListener {
|
|||||||
Object source = e.getSource();
|
Object source = e.getSource();
|
||||||
|
|
||||||
if ( source instanceof JComboBox ) {
|
if ( source instanceof JComboBox ) {
|
||||||
String rangeName = (String)((JComboBox)source).getSelectedItem();
|
String rangeName = (String)((JComboBox<?>)source).getSelectedItem();
|
||||||
|
|
||||||
if ( rangeName.equals("Custom...") ) {
|
if ( rangeName.equals("Custom...") ) {
|
||||||
useCustomRange = true;
|
useCustomRange = true;
|
||||||
customRangeDialog.setLocationRelativeTo(parent);
|
customRangeDialog.setLocationRelativeTo(parent);
|
||||||
customRangeDialog.show();
|
customRangeDialog.setVisible(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
useCustomRange = false;
|
useCustomRange = false;
|
||||||
@ -195,7 +195,7 @@ public final class RangeMenu extends JComboBox implements ActionListener {
|
|||||||
}
|
}
|
||||||
else if ( source instanceof JButton ) {
|
else if ( source instanceof JButton ) {
|
||||||
/// Since it is only "OK" button that sends any action here...
|
/// 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 {
|
try {
|
||||||
if (obj instanceof String) {
|
if (obj instanceof String) {
|
||||||
className = (String) obj;
|
className = (String) obj;
|
||||||
obj = Class.forName(className).newInstance();
|
obj = Class.forName(className).getDeclaredConstructor().newInstance();
|
||||||
}
|
}
|
||||||
if (obj instanceof Component) {
|
if (obj instanceof Component) {
|
||||||
add((Component) obj);
|
add((Component) obj);
|
||||||
|
@ -63,7 +63,7 @@ public class GlobalControls extends JPanel implements ItemListener,
|
|||||||
"USHORT_x555_RGB", "BYTE_GRAY", "USHORT_GRAY",
|
"USHORT_x555_RGB", "BYTE_GRAY", "USHORT_GRAY",
|
||||||
"BYTE_BINARY", "BYTE_INDEXED", "BYTE_BINARY 2 bit", "BYTE_BINARY 4 bit",
|
"BYTE_BINARY", "BYTE_INDEXED", "BYTE_BINARY 2 bit", "BYTE_BINARY 4 bit",
|
||||||
"INT_RGBx", "USHORT_555x_RGB" };
|
"INT_RGBx", "USHORT_555x_RGB" };
|
||||||
public final JComboBox screenCombo;
|
public final JComboBox<String> screenCombo;
|
||||||
public TextureChooser texturechooser;
|
public TextureChooser texturechooser;
|
||||||
public JCheckBox aliasCB, renderCB, toolBarCB;
|
public JCheckBox aliasCB, renderCB, toolBarCB;
|
||||||
public JCheckBox compositeCB, textureCB;
|
public JCheckBox compositeCB, textureCB;
|
||||||
@ -83,7 +83,7 @@ public class GlobalControls extends JPanel implements ItemListener,
|
|||||||
textureCB = createCheckBox("Texture", false, 2);
|
textureCB = createCheckBox("Texture", false, 2);
|
||||||
compositeCB = createCheckBox("AlphaComposite", false, 3);
|
compositeCB = createCheckBox("AlphaComposite", false, 3);
|
||||||
|
|
||||||
screenCombo = new JComboBox();
|
screenCombo = new JComboBox<>();
|
||||||
screenCombo.setPreferredSize(new Dimension(120, 18));
|
screenCombo.setPreferredSize(new Dimension(120, 18));
|
||||||
screenCombo.setLightWeightPopupEnabled(true);
|
screenCombo.setLightWeightPopupEnabled(true);
|
||||||
screenCombo.setFont(font);
|
screenCombo.setFont(font);
|
||||||
|
@ -94,7 +94,7 @@ public final class Tools extends JPanel implements ActionListener,
|
|||||||
protected boolean focus;
|
protected boolean focus;
|
||||||
public JToggleButton toggleB;
|
public JToggleButton toggleB;
|
||||||
public JButton printB;
|
public JButton printB;
|
||||||
public JComboBox screenCombo;
|
public JComboBox<String> screenCombo;
|
||||||
public JToggleButton renderB, aliasB;
|
public JToggleButton renderB, aliasB;
|
||||||
public JToggleButton textureB, compositeB;
|
public JToggleButton textureB, compositeB;
|
||||||
public JButton startStopB;
|
public JButton startStopB;
|
||||||
@ -167,7 +167,7 @@ public final class Tools extends JPanel implements ActionListener,
|
|||||||
toolbar.setPreferredSize(new Dimension(6*25, 26));
|
toolbar.setPreferredSize(new Dimension(6*25, 26));
|
||||||
}
|
}
|
||||||
|
|
||||||
screenCombo = new JComboBox();
|
screenCombo = new JComboBox<>();
|
||||||
screenCombo.setPreferredSize(new Dimension(100, 18));
|
screenCombo.setPreferredSize(new Dimension(100, 18));
|
||||||
screenCombo.setFont(font);
|
screenCombo.setFont(font);
|
||||||
for (String name : GlobalControls.screenNames) {
|
for (String name : GlobalControls.screenNames) {
|
||||||
|
@ -151,7 +151,6 @@ public class Areas extends ControlsSurface {
|
|||||||
|
|
||||||
Areas demo;
|
Areas demo;
|
||||||
JToolBar toolbar;
|
JToolBar toolbar;
|
||||||
JComboBox combo;
|
|
||||||
|
|
||||||
public DemoControls(Areas demo) {
|
public DemoControls(Areas demo) {
|
||||||
super(demo.name);
|
super(demo.name);
|
||||||
|
@ -51,8 +51,8 @@ import java2d.AnimatingSurface;
|
|||||||
public class Tree extends AnimatingSurface {
|
public class Tree extends AnimatingSurface {
|
||||||
|
|
||||||
private char theC = 'A';
|
private char theC = 'A';
|
||||||
private Character theT = new Character(theC);
|
private Character theT = Character.valueOf(theC);
|
||||||
private Character theR = new Character((char) (theC + 1));
|
private Character theR = Character.valueOf((char) (theC + 1));
|
||||||
|
|
||||||
public Tree() {
|
public Tree() {
|
||||||
setBackground(WHITE);
|
setBackground(WHITE);
|
||||||
@ -65,9 +65,9 @@ public class Tree extends AnimatingSurface {
|
|||||||
@Override
|
@Override
|
||||||
public void step(int w, int h) {
|
public void step(int w, int h) {
|
||||||
setSleepAmount(4000);
|
setSleepAmount(4000);
|
||||||
theT = new Character(theC = ((char) (theC + 1)));
|
theT = Character.valueOf(theC = ((char) (theC + 1)));
|
||||||
theR = new Character((char) (theC + 1));
|
theR = Character.valueOf((char) (theC + 1));
|
||||||
if (theR.compareTo(new Character('z')) == 0) {
|
if (theR.compareTo(Character.valueOf('z')) == 0) {
|
||||||
theC = 'A';
|
theC = 'A';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,20 +188,20 @@ public class ImageOps extends ControlsSurface implements ChangeListener {
|
|||||||
static class DemoControls extends CustomControls implements ActionListener {
|
static class DemoControls extends CustomControls implements ActionListener {
|
||||||
|
|
||||||
ImageOps demo;
|
ImageOps demo;
|
||||||
JComboBox imgCombo, opsCombo;
|
JComboBox<String> imgCombo, opsCombo;
|
||||||
Font font = new Font(Font.SERIF, Font.PLAIN, 10);
|
Font font = new Font(Font.SERIF, Font.PLAIN, 10);
|
||||||
|
|
||||||
@SuppressWarnings("LeakingThisInConstructor")
|
@SuppressWarnings("LeakingThisInConstructor")
|
||||||
public DemoControls(ImageOps demo) {
|
public DemoControls(ImageOps demo) {
|
||||||
super(demo.name);
|
super(demo.name);
|
||||||
this.demo = demo;
|
this.demo = demo;
|
||||||
add(imgCombo = new JComboBox());
|
add(imgCombo = new JComboBox<>());
|
||||||
imgCombo.setFont(font);
|
imgCombo.setFont(font);
|
||||||
for (String name : ImageOps.imgName) {
|
for (String name : ImageOps.imgName) {
|
||||||
imgCombo.addItem(name);
|
imgCombo.addItem(name);
|
||||||
}
|
}
|
||||||
imgCombo.addActionListener(this);
|
imgCombo.addActionListener(this);
|
||||||
add(opsCombo = new JComboBox());
|
add(opsCombo = new JComboBox<>());
|
||||||
opsCombo.setFont(font);
|
opsCombo.setFont(font);
|
||||||
for (String name : ImageOps.opsName) {
|
for (String name : ImageOps.opsName) {
|
||||||
opsCombo.addItem(name);
|
opsCombo.addItem(name);
|
||||||
|
@ -71,7 +71,7 @@ public class Balls extends AnimatingControlsSurface {
|
|||||||
private boolean active;
|
private boolean active;
|
||||||
protected Ball[] balls = new Ball[colors.length];
|
protected Ball[] balls = new Ball[colors.length];
|
||||||
protected boolean clearToggle;
|
protected boolean clearToggle;
|
||||||
protected JComboBox combo;
|
protected JComboBox<String> combo;
|
||||||
|
|
||||||
public Balls() {
|
public Balls() {
|
||||||
setBackground(WHITE);
|
setBackground(WHITE);
|
||||||
@ -279,7 +279,7 @@ public class Balls extends AnimatingControlsSurface {
|
|||||||
addTool("B", demo.balls[4].isSelected);
|
addTool("B", demo.balls[4].isSelected);
|
||||||
addTool("I", demo.balls[5].isSelected);
|
addTool("I", demo.balls[5].isSelected);
|
||||||
addTool("V", demo.balls[6].isSelected);
|
addTool("V", demo.balls[6].isSelected);
|
||||||
add(combo = new JComboBox());
|
add(combo = new JComboBox<>());
|
||||||
combo.addItem("10");
|
combo.addItem("10");
|
||||||
combo.addItem("20");
|
combo.addItem("20");
|
||||||
combo.addItem("30");
|
combo.addItem("30");
|
||||||
|
@ -60,7 +60,6 @@ import java.util.logging.Logger;
|
|||||||
import java2d.AnimatingControlsSurface;
|
import java2d.AnimatingControlsSurface;
|
||||||
import java2d.CustomControls;
|
import java2d.CustomControls;
|
||||||
import javax.swing.AbstractButton;
|
import javax.swing.AbstractButton;
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JToggleButton;
|
import javax.swing.JToggleButton;
|
||||||
import javax.swing.JToolBar;
|
import javax.swing.JToolBar;
|
||||||
|
|
||||||
@ -320,7 +319,6 @@ public class BezierScroller extends AnimatingControlsSurface {
|
|||||||
|
|
||||||
BezierScroller demo;
|
BezierScroller demo;
|
||||||
JToolBar toolbar;
|
JToolBar toolbar;
|
||||||
JComboBox combo;
|
|
||||||
|
|
||||||
public DemoControls(BezierScroller demo) {
|
public DemoControls(BezierScroller demo) {
|
||||||
super(demo.name);
|
super(demo.name);
|
||||||
|
@ -266,13 +266,13 @@ public class GradAnim extends AnimatingControlsSurface {
|
|||||||
class DemoControls extends CustomControls implements ActionListener {
|
class DemoControls extends CustomControls implements ActionListener {
|
||||||
|
|
||||||
GradAnim demo;
|
GradAnim demo;
|
||||||
JComboBox combo;
|
JComboBox<String> combo;
|
||||||
|
|
||||||
@SuppressWarnings("LeakingThisInConstructor")
|
@SuppressWarnings("LeakingThisInConstructor")
|
||||||
public DemoControls(GradAnim demo) {
|
public DemoControls(GradAnim demo) {
|
||||||
super(demo.name);
|
super(demo.name);
|
||||||
this.demo = demo;
|
this.demo = demo;
|
||||||
combo = new JComboBox();
|
combo = new JComboBox<>();
|
||||||
combo.addActionListener(this);
|
combo.addActionListener(this);
|
||||||
combo.addItem("2-color GradientPaint");
|
combo.addItem("2-color GradientPaint");
|
||||||
combo.addItem("3-color LinearGradientPaint");
|
combo.addItem("3-color LinearGradientPaint");
|
||||||
|
@ -299,7 +299,7 @@ public final class TextureAnim extends AnimatingControlsSurface {
|
|||||||
|
|
||||||
TextureAnim demo;
|
TextureAnim demo;
|
||||||
JToolBar toolbar;
|
JToolBar toolbar;
|
||||||
JComboBox combo;
|
JComboBox<String> combo;
|
||||||
JMenu menu;
|
JMenu menu;
|
||||||
JMenuItem[] menuitems;
|
JMenuItem[] menuitems;
|
||||||
int iconSize = 20;
|
int iconSize = 20;
|
||||||
@ -318,7 +318,7 @@ public final class TextureAnim extends AnimatingControlsSurface {
|
|||||||
addTool("RO", "rotate", false);
|
addTool("RO", "rotate", false);
|
||||||
addTool("SX", "shear x", false);
|
addTool("SX", "shear x", false);
|
||||||
addTool("SY", "shear y", false);
|
addTool("SY", "shear y", false);
|
||||||
add(combo = new JComboBox());
|
add(combo = new JComboBox<>());
|
||||||
combo.addActionListener(this);
|
combo.addActionListener(this);
|
||||||
combo.addItem("8");
|
combo.addItem("8");
|
||||||
combo.addItem("16");
|
combo.addItem("16");
|
||||||
|
@ -162,7 +162,7 @@ public final class MetalworksPrefs extends JDialog {
|
|||||||
|
|
||||||
JPanel protoPanel = new JPanel();
|
JPanel protoPanel = new JPanel();
|
||||||
JLabel protoLabel = new JLabel("Protocol");
|
JLabel protoLabel = new JLabel("Protocol");
|
||||||
JComboBox protocol = new JComboBox();
|
JComboBox<String> protocol = new JComboBox<>();
|
||||||
protocol.addItem("SMTP");
|
protocol.addItem("SMTP");
|
||||||
protocol.addItem("IMAP");
|
protocol.addItem("IMAP");
|
||||||
protocol.addItem("Other...");
|
protocol.addItem("Other...");
|
||||||
@ -171,7 +171,7 @@ public final class MetalworksPrefs extends JDialog {
|
|||||||
|
|
||||||
JPanel attachmentPanel = new JPanel();
|
JPanel attachmentPanel = new JPanel();
|
||||||
JLabel attachmentLabel = new JLabel("Attachments");
|
JLabel attachmentLabel = new JLabel("Attachments");
|
||||||
JComboBox attach = new JComboBox();
|
JComboBox<String> attach = new JComboBox<>();
|
||||||
attach.addItem("Download Always");
|
attach.addItem("Download Always");
|
||||||
attach.addItem("Ask size > 1 Meg");
|
attach.addItem("Ask size > 1 Meg");
|
||||||
attach.addItem("Ask size > 5 Meg");
|
attach.addItem("Ask size > 5 Meg");
|
||||||
|
@ -115,7 +115,7 @@ public class ElementTreePanel extends JPanel implements CaretListener,
|
|||||||
|
|
||||||
if (as != null) {
|
if (as != null) {
|
||||||
StringBuilder retBuffer = new StringBuilder("[");
|
StringBuilder retBuffer = new StringBuilder("[");
|
||||||
Enumeration names = as.getAttributeNames();
|
Enumeration<?> names = as.getAttributeNames();
|
||||||
|
|
||||||
while (names.hasMoreElements()) {
|
while (names.hasMoreElements()) {
|
||||||
Object nextName = names.nextElement();
|
Object nextName = names.nextElement();
|
||||||
|
@ -255,8 +255,8 @@ public class Stylepad extends Notepad {
|
|||||||
w.loadDocument();
|
w.loadDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
JComboBox createFamilyChoices() {
|
JComboBox<String> createFamilyChoices() {
|
||||||
JComboBox b = new JComboBox();
|
JComboBox<String> b = new JComboBox<>();
|
||||||
String[] fontNames = GraphicsEnvironment.getLocalGraphicsEnvironment().
|
String[] fontNames = GraphicsEnvironment.getLocalGraphicsEnvironment().
|
||||||
getAvailableFontFamilyNames();
|
getAvailableFontFamilyNames();
|
||||||
for (String fontName : fontNames) {
|
for (String fontName : fontNames) {
|
||||||
|
@ -61,12 +61,12 @@ public class ButtonDemo extends DemoModule implements ChangeListener {
|
|||||||
JPanel radioButtonPanel = new JPanel();
|
JPanel radioButtonPanel = new JPanel();
|
||||||
JPanel toggleButtonPanel = new JPanel();
|
JPanel toggleButtonPanel = new JPanel();
|
||||||
|
|
||||||
Vector buttons = new Vector();
|
Vector<Component> buttons = new Vector<>();
|
||||||
Vector checkboxes = new Vector();
|
Vector<Component> checkboxes = new Vector<>();
|
||||||
Vector radiobuttons = new Vector();
|
Vector<Component> radiobuttons = new Vector<>();
|
||||||
Vector togglebuttons = new Vector();
|
Vector<Component> togglebuttons = new Vector<>();
|
||||||
|
|
||||||
Vector currentControls = buttons;
|
Vector<Component> currentControls = buttons;
|
||||||
|
|
||||||
JButton button;
|
JButton button;
|
||||||
JCheckBox check;
|
JCheckBox check;
|
||||||
@ -466,12 +466,12 @@ public class ButtonDemo extends DemoModule implements ChangeListener {
|
|||||||
String command = cb.getActionCommand();
|
String command = cb.getActionCommand();
|
||||||
if(command == "Enabled") {
|
if(command == "Enabled") {
|
||||||
for(int i = 0; i < currentControls.size(); i++) {
|
for(int i = 0; i < currentControls.size(); i++) {
|
||||||
c = (Component) currentControls.elementAt(i);
|
c = currentControls.elementAt(i);
|
||||||
c.setEnabled(cb.isSelected());
|
c.setEnabled(cb.isSelected());
|
||||||
c.invalidate();
|
c.invalidate();
|
||||||
}
|
}
|
||||||
} else if(command == "PaintBorder") {
|
} else if(command == "PaintBorder") {
|
||||||
c = (Component) currentControls.elementAt(0);
|
c = currentControls.elementAt(0);
|
||||||
if(c instanceof AbstractButton) {
|
if(c instanceof AbstractButton) {
|
||||||
for(int i = 0; i < currentControls.size(); i++) {
|
for(int i = 0; i < currentControls.size(); i++) {
|
||||||
b = (AbstractButton) currentControls.elementAt(i);
|
b = (AbstractButton) currentControls.elementAt(i);
|
||||||
@ -480,7 +480,7 @@ public class ButtonDemo extends DemoModule implements ChangeListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(command == "PaintFocus") {
|
} else if(command == "PaintFocus") {
|
||||||
c = (Component) currentControls.elementAt(0);
|
c = currentControls.elementAt(0);
|
||||||
if(c instanceof AbstractButton) {
|
if(c instanceof AbstractButton) {
|
||||||
for(int i = 0; i < currentControls.size(); i++) {
|
for(int i = 0; i < currentControls.size(); i++) {
|
||||||
b = (AbstractButton) currentControls.elementAt(i);
|
b = (AbstractButton) currentControls.elementAt(i);
|
||||||
@ -489,7 +489,7 @@ public class ButtonDemo extends DemoModule implements ChangeListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(command == "ContentFilled") {
|
} else if(command == "ContentFilled") {
|
||||||
c = (Component) currentControls.elementAt(0);
|
c = currentControls.elementAt(0);
|
||||||
if(c instanceof AbstractButton) {
|
if(c instanceof AbstractButton) {
|
||||||
for(int i = 0; i < currentControls.size(); i++) {
|
for(int i = 0; i < currentControls.size(); i++) {
|
||||||
b = (AbstractButton) currentControls.elementAt(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;
|
return currentControls;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ public class ColorChooserDemo extends DemoModule {
|
|||||||
okListener,
|
okListener,
|
||||||
null);
|
null);
|
||||||
|
|
||||||
dialog.show();
|
dialog.setVisible(true);
|
||||||
|
|
||||||
if(e.getSource() == outerColorButton) {
|
if(e.getSource() == outerColorButton) {
|
||||||
bezAnim.setOuterColor(chosen);
|
bezAnim.setOuterColor(chosen);
|
||||||
|
@ -57,13 +57,13 @@ public class ComboBoxDemo extends DemoModule implements ActionListener {
|
|||||||
Face face;
|
Face face;
|
||||||
JLabel faceLabel;
|
JLabel faceLabel;
|
||||||
|
|
||||||
JComboBox hairCB;
|
JComboBox<?> hairCB;
|
||||||
JComboBox eyesCB;
|
JComboBox<?> eyesCB;
|
||||||
JComboBox mouthCB;
|
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.
|
* 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")));
|
JLabel l = (JLabel) comboBoxPanel.add(new JLabel(getString("ComboBoxDemo.presets")));
|
||||||
l.setAlignmentX(JLabel.LEFT_ALIGNMENT);
|
l.setAlignmentX(JLabel.LEFT_ALIGNMENT);
|
||||||
presetCB = (JComboBox) comboBoxPanel.add(createPresetComboBox());
|
presetCB = createPresetComboBox();
|
||||||
presetCB.setAlignmentX(JComboBox.LEFT_ALIGNMENT);
|
presetCB.setAlignmentX(JComboBox.LEFT_ALIGNMENT);
|
||||||
l.setLabelFor(presetCB);
|
l.setLabelFor(presetCB);
|
||||||
|
comboBoxPanel.add(presetCB);
|
||||||
comboBoxPanel.add(Box.createRigidArea(VGAP30));
|
comboBoxPanel.add(Box.createRigidArea(VGAP30));
|
||||||
|
|
||||||
l = (JLabel) comboBoxPanel.add(new JLabel(getString("ComboBoxDemo.hair_description")));
|
l = (JLabel) comboBoxPanel.add(new JLabel(getString("ComboBoxDemo.hair_description")));
|
||||||
l.setAlignmentX(JLabel.LEFT_ALIGNMENT);
|
l.setAlignmentX(JLabel.LEFT_ALIGNMENT);
|
||||||
hairCB = (JComboBox) comboBoxPanel.add(createHairComboBox());
|
hairCB = createHairComboBox();
|
||||||
hairCB.setAlignmentX(JComboBox.LEFT_ALIGNMENT);
|
hairCB.setAlignmentX(JComboBox.LEFT_ALIGNMENT);
|
||||||
l.setLabelFor(hairCB);
|
l.setLabelFor(hairCB);
|
||||||
|
comboBoxPanel.add(hairCB);
|
||||||
comboBoxPanel.add(Box.createRigidArea(VGAP15));
|
comboBoxPanel.add(Box.createRigidArea(VGAP15));
|
||||||
|
|
||||||
l = (JLabel) comboBoxPanel.add(new JLabel(getString("ComboBoxDemo.eyes_description")));
|
l = (JLabel) comboBoxPanel.add(new JLabel(getString("ComboBoxDemo.eyes_description")));
|
||||||
l.setAlignmentX(JLabel.LEFT_ALIGNMENT);
|
l.setAlignmentX(JLabel.LEFT_ALIGNMENT);
|
||||||
eyesCB = (JComboBox) comboBoxPanel.add(createEyesComboBox());
|
eyesCB = createEyesComboBox();
|
||||||
eyesCB.setAlignmentX(JComboBox.LEFT_ALIGNMENT);
|
eyesCB.setAlignmentX(JComboBox.LEFT_ALIGNMENT);
|
||||||
l.setLabelFor(eyesCB);
|
l.setLabelFor(eyesCB);
|
||||||
|
comboBoxPanel.add(eyesCB);
|
||||||
comboBoxPanel.add(Box.createRigidArea(VGAP15));
|
comboBoxPanel.add(Box.createRigidArea(VGAP15));
|
||||||
|
|
||||||
l = (JLabel) comboBoxPanel.add(new JLabel(getString("ComboBoxDemo.mouth_description")));
|
l = (JLabel) comboBoxPanel.add(new JLabel(getString("ComboBoxDemo.mouth_description")));
|
||||||
l.setAlignmentX(JLabel.LEFT_ALIGNMENT);
|
l.setAlignmentX(JLabel.LEFT_ALIGNMENT);
|
||||||
mouthCB = (JComboBox) comboBoxPanel.add(createMouthComboBox());
|
mouthCB = (JComboBox<?>) comboBoxPanel.add(createMouthComboBox());
|
||||||
mouthCB.setAlignmentX(JComboBox.LEFT_ALIGNMENT);
|
mouthCB.setAlignmentX(JComboBox.LEFT_ALIGNMENT);
|
||||||
l.setLabelFor(mouthCB);
|
l.setLabelFor(mouthCB);
|
||||||
comboBoxPanel.add(Box.createRigidArea(VGAP15));
|
comboBoxPanel.add(Box.createRigidArea(VGAP15));
|
||||||
@ -217,36 +220,36 @@ public class ComboBoxDemo extends DemoModule implements ActionListener {
|
|||||||
return face;
|
return face;
|
||||||
}
|
}
|
||||||
|
|
||||||
JComboBox createHairComboBox() {
|
JComboBox<String> createHairComboBox() {
|
||||||
JComboBox cb = new JComboBox();
|
JComboBox<String> cb = new JComboBox<>();
|
||||||
fillComboBox(cb);
|
fillComboBox(cb);
|
||||||
cb.addActionListener(this);
|
cb.addActionListener(this);
|
||||||
return cb;
|
return cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
JComboBox createEyesComboBox() {
|
JComboBox<String> createEyesComboBox() {
|
||||||
JComboBox cb = new JComboBox();
|
JComboBox<String> cb = new JComboBox<>();
|
||||||
fillComboBox(cb);
|
fillComboBox(cb);
|
||||||
cb.addActionListener(this);
|
cb.addActionListener(this);
|
||||||
return cb;
|
return cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
JComboBox createNoseComboBox() {
|
JComboBox<String> createNoseComboBox() {
|
||||||
JComboBox cb = new JComboBox();
|
JComboBox<String> cb = new JComboBox<>();
|
||||||
fillComboBox(cb);
|
fillComboBox(cb);
|
||||||
cb.addActionListener(this);
|
cb.addActionListener(this);
|
||||||
return cb;
|
return cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
JComboBox createMouthComboBox() {
|
JComboBox<String> createMouthComboBox() {
|
||||||
JComboBox cb = new JComboBox();
|
JComboBox<String> cb = new JComboBox<>();
|
||||||
fillComboBox(cb);
|
fillComboBox(cb);
|
||||||
cb.addActionListener(this);
|
cb.addActionListener(this);
|
||||||
return cb;
|
return cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
JComboBox createPresetComboBox() {
|
JComboBox<String> createPresetComboBox() {
|
||||||
JComboBox cb = new JComboBox();
|
JComboBox<String> cb = new JComboBox<>();
|
||||||
cb.addItem(getString("ComboBoxDemo.preset1"));
|
cb.addItem(getString("ComboBoxDemo.preset1"));
|
||||||
cb.addItem(getString("ComboBoxDemo.preset2"));
|
cb.addItem(getString("ComboBoxDemo.preset2"));
|
||||||
cb.addItem(getString("ComboBoxDemo.preset3"));
|
cb.addItem(getString("ComboBoxDemo.preset3"));
|
||||||
@ -261,7 +264,7 @@ public class ComboBoxDemo extends DemoModule implements ActionListener {
|
|||||||
return cb;
|
return cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fillComboBox(JComboBox cb) {
|
void fillComboBox(JComboBox<String> cb) {
|
||||||
cb.addItem(getString("ComboBoxDemo.brent"));
|
cb.addItem(getString("ComboBoxDemo.brent"));
|
||||||
cb.addItem(getString("ComboBoxDemo.georges"));
|
cb.addItem(getString("ComboBoxDemo.georges"));
|
||||||
cb.addItem(getString("ComboBoxDemo.hans"));
|
cb.addItem(getString("ComboBoxDemo.hans"));
|
||||||
@ -279,15 +282,15 @@ public class ComboBoxDemo extends DemoModule implements ActionListener {
|
|||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if(e.getSource() == hairCB) {
|
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"));
|
face.setHair((ImageIcon) parts.get(name + "hair"));
|
||||||
faceLabel.repaint();
|
faceLabel.repaint();
|
||||||
} else if(e.getSource() == eyesCB) {
|
} 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"));
|
face.setEyes((ImageIcon) parts.get(name + "eyes"));
|
||||||
faceLabel.repaint();
|
faceLabel.repaint();
|
||||||
} else if(e.getSource() == mouthCB) {
|
} 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"));
|
face.setMouth((ImageIcon) parts.get(name + "mouth"));
|
||||||
faceLabel.repaint();
|
faceLabel.repaint();
|
||||||
} else if(e.getSource() == presetCB) {
|
} else if(e.getSource() == presetCB) {
|
||||||
|
@ -51,7 +51,7 @@ import java.net.*;
|
|||||||
*
|
*
|
||||||
* @author Jeff Dinkins
|
* @author Jeff Dinkins
|
||||||
*/
|
*/
|
||||||
public class DemoModule extends JApplet {
|
public class DemoModule extends JFrame {
|
||||||
|
|
||||||
// The preferred size of the demo
|
// The preferred size of the demo
|
||||||
private int PREFERRED_WIDTH = 680;
|
private int PREFERRED_WIDTH = 680;
|
||||||
@ -190,7 +190,7 @@ public class DemoModule extends JApplet {
|
|||||||
frame.getContentPane().add(getDemoPanel(), BorderLayout.CENTER);
|
frame.getContentPane().add(getDemoPanel(), BorderLayout.CENTER);
|
||||||
getDemoPanel().setPreferredSize(new Dimension(PREFERRED_WIDTH, PREFERRED_HEIGHT));
|
getDemoPanel().setPreferredSize(new Dimension(PREFERRED_WIDTH, PREFERRED_HEIGHT));
|
||||||
frame.pack();
|
frame.pack();
|
||||||
frame.show();
|
frame.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JPanel createHorizontalPanel(boolean threeD) {
|
public JPanel createHorizontalPanel(boolean threeD) {
|
||||||
|
@ -92,9 +92,9 @@ public class DirectionPanel extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSelection( String selection ) {
|
public void setSelection( String selection ) {
|
||||||
Enumeration e = group.getElements();
|
Enumeration<AbstractButton> e = group.getElements();
|
||||||
while( e.hasMoreElements() ) {
|
while( e.hasMoreElements() ) {
|
||||||
JRadioButton b = (JRadioButton)e.nextElement();
|
AbstractButton b = e.nextElement();
|
||||||
if( b.getActionCommand().equals(selection) ) {
|
if( b.getActionCommand().equals(selection) ) {
|
||||||
b.setSelected(true);
|
b.setSelected(true);
|
||||||
}
|
}
|
||||||
@ -147,10 +147,7 @@ public class DirectionPanel extends JPanel {
|
|||||||
getAccessibleContext().setAccessibleName(direction);
|
getAccessibleContext().setAccessibleName(direction);
|
||||||
getAccessibleContext().setAccessibleDescription(description);
|
getAccessibleContext().setAccessibleDescription(description);
|
||||||
setSelected(selected);
|
setSelected(selected);
|
||||||
}
|
setFocusable(false);
|
||||||
|
|
||||||
public boolean isFocusTraversable() {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBorder(Border b) {
|
public void setBorder(Border b) {
|
||||||
|
@ -59,9 +59,9 @@ import java.util.Hashtable;
|
|||||||
* @author Jeff Dinkins
|
* @author Jeff Dinkins
|
||||||
*/
|
*/
|
||||||
public class ExampleFileView extends FileView {
|
public class ExampleFileView extends FileView {
|
||||||
private Hashtable icons = new Hashtable(5);
|
private Hashtable<String, Icon> icons = new Hashtable<>(5);
|
||||||
private Hashtable fileDescriptions = new Hashtable(5);
|
private Hashtable<File, String> fileDescriptions = new Hashtable<>(5);
|
||||||
private Hashtable typeDescriptions = new Hashtable(5);
|
private Hashtable<String, String> typeDescriptions = new Hashtable<>(5);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the file. Do nothing special here. Let
|
* The name of the file. Do nothing special here. Let
|
||||||
@ -85,7 +85,7 @@ public class ExampleFileView extends FileView {
|
|||||||
* @see FileView#getDescription
|
* @see FileView#getDescription
|
||||||
*/
|
*/
|
||||||
public String getDescription(File f) {
|
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
|
* @see FileView#getTypeDescription
|
||||||
*/
|
*/
|
||||||
public String getTypeDescription(File f) {
|
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;
|
Icon icon = null;
|
||||||
String extension = getExtension(f);
|
String extension = getExtension(f);
|
||||||
if(extension != null) {
|
if(extension != null) {
|
||||||
icon = (Icon) icons.get(extension);
|
icon = icons.get(extension);
|
||||||
}
|
}
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ public class FileChooserDemo extends DemoModule {
|
|||||||
dialog.getContentPane().add(custom, BorderLayout.CENTER);
|
dialog.getContentPane().add(custom, BorderLayout.CENTER);
|
||||||
dialog.pack();
|
dialog.pack();
|
||||||
dialog.setLocationRelativeTo(getDemoPanel());
|
dialog.setLocationRelativeTo(getDemoPanel());
|
||||||
dialog.show();
|
dialog.setVisible(true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return createButton(a);
|
return createButton(a);
|
||||||
|
@ -59,9 +59,9 @@ public class InternalFrameDemo extends DemoModule {
|
|||||||
ImageIcon icon1, icon2, icon3, icon4;
|
ImageIcon icon1, icon2, icon3, icon4;
|
||||||
ImageIcon smIcon1, smIcon2, smIcon3, smIcon4;
|
ImageIcon smIcon1, smIcon2, smIcon3, smIcon4;
|
||||||
|
|
||||||
public Integer FIRST_FRAME_LAYER = new Integer(1);
|
public Integer FIRST_FRAME_LAYER = Integer.valueOf(1);
|
||||||
public Integer DEMO_FRAME_LAYER = new Integer(2);
|
public Integer DEMO_FRAME_LAYER = Integer.valueOf(2);
|
||||||
public Integer PALETTE_LAYER = new Integer(3);
|
public Integer PALETTE_LAYER = Integer.valueOf(3);
|
||||||
|
|
||||||
public int FRAME0_X = 15;
|
public int FRAME0_X = 15;
|
||||||
public int FRAME0_Y = 280;
|
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
|
// Make sure the controls' text position and label alignment match
|
||||||
// the initial value of the associated direction panel.
|
// the initial value of the associated direction panel.
|
||||||
for(int i = 0; i < demo.getCurrentControls().size(); i++) {
|
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);
|
setPosition(c, RIGHT, CENTER);
|
||||||
setAlignment(c,CENTER,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++) {
|
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;
|
int hPos, vPos, hAlign, vAlign;
|
||||||
if( c instanceof AbstractButton ) {
|
if( c instanceof AbstractButton ) {
|
||||||
hPos = ((AbstractButton)c).getHorizontalTextPosition();
|
hPos = ((AbstractButton)c).getHorizontalTextPosition();
|
||||||
@ -228,7 +228,7 @@ public class LayoutControlPanel extends JPanel implements SwingConstants {
|
|||||||
hPos = RIGHT; vPos = BOTTOM;
|
hPos = RIGHT; vPos = BOTTOM;
|
||||||
}
|
}
|
||||||
for(int i = 0; i < demo.getCurrentControls().size(); i++) {
|
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);
|
setPosition(c, hPos, vPos);
|
||||||
}
|
}
|
||||||
demo.invalidate();
|
demo.invalidate();
|
||||||
@ -267,7 +267,7 @@ public class LayoutControlPanel extends JPanel implements SwingConstants {
|
|||||||
hPos = RIGHT; vPos = BOTTOM;
|
hPos = RIGHT; vPos = BOTTOM;
|
||||||
}
|
}
|
||||||
for(int i = 0; i < demo.getCurrentControls().size(); i++) {
|
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);
|
setAlignment(c,hPos,vPos);
|
||||||
c.invalidate();
|
c.invalidate();
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ import java.net.*;
|
|||||||
* @author Jeff Dinkins
|
* @author Jeff Dinkins
|
||||||
*/
|
*/
|
||||||
public class ListDemo extends DemoModule {
|
public class ListDemo extends DemoModule {
|
||||||
JList list;
|
JList<String> list;
|
||||||
|
|
||||||
JPanel prefixList;
|
JPanel prefixList;
|
||||||
JPanel suffixList;
|
JPanel suffixList;
|
||||||
@ -69,7 +69,7 @@ public class ListDemo extends DemoModule {
|
|||||||
|
|
||||||
GeneratedListModel listModel;
|
GeneratedListModel listModel;
|
||||||
|
|
||||||
Vector checkboxes = new Vector();
|
Vector<JCheckBox> checkboxes = new Vector<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* main method allows us to run as a standalone demo.
|
* main method allows us to run as a standalone demo.
|
||||||
@ -103,7 +103,7 @@ public class ListDemo extends DemoModule {
|
|||||||
centerPanel.add(Box.createRigidArea(HGAP30));
|
centerPanel.add(Box.createRigidArea(HGAP30));
|
||||||
|
|
||||||
// Create the list
|
// Create the list
|
||||||
list = new JList();
|
list = new JList<>();
|
||||||
list.setCellRenderer(new CompanyLogoListCellRenderer());
|
list.setCellRenderer(new CompanyLogoListCellRenderer());
|
||||||
listModel = new GeneratedListModel(this);
|
listModel = new GeneratedListModel(this);
|
||||||
list.setModel(listModel);
|
list.setModel(listModel);
|
||||||
@ -293,12 +293,12 @@ public class ListDemo extends DemoModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class GeneratedListModel extends AbstractListModel {
|
class GeneratedListModel extends AbstractListModel<String> {
|
||||||
ListDemo demo;
|
ListDemo demo;
|
||||||
Permuter permuter;
|
Permuter permuter;
|
||||||
|
|
||||||
public Vector prefix = new Vector();
|
public Vector<String> prefix = new Vector<>();
|
||||||
public Vector suffix = new Vector();
|
public Vector<String> suffix = new Vector<>();
|
||||||
|
|
||||||
public GeneratedListModel (ListDemo demo) {
|
public GeneratedListModel (ListDemo demo) {
|
||||||
this.demo = demo;
|
this.demo = demo;
|
||||||
@ -337,7 +337,7 @@ public class ListDemo extends DemoModule {
|
|||||||
return prefix.size() * suffix.size();
|
return prefix.size() * suffix.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getElementAt(int index) {
|
public String getElementAt(int index) {
|
||||||
if(permuter == null) {
|
if(permuter == null) {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@ -363,7 +363,7 @@ public class ListDemo extends DemoModule {
|
|||||||
|
|
||||||
class CompanyLogoListCellRenderer extends DefaultListCellRenderer {
|
class CompanyLogoListCellRenderer extends DefaultListCellRenderer {
|
||||||
public Component getListCellRendererComponent(
|
public Component getListCellRendererComponent(
|
||||||
JList list,
|
JList<?> list,
|
||||||
Object value,
|
Object value,
|
||||||
int index,
|
int index,
|
||||||
boolean isSelected,
|
boolean isSelected,
|
||||||
|
@ -163,7 +163,7 @@ public class OptionPaneDemo extends DemoModule {
|
|||||||
message[0] = getString("OptionPaneDemo.componentmessage");
|
message[0] = getString("OptionPaneDemo.componentmessage");
|
||||||
message[1] = new JTextField(getString("OptionPaneDemo.componenttextfield"));
|
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_cb1"));
|
||||||
cb.addItem(getString("OptionPaneDemo.component_cb2"));
|
cb.addItem(getString("OptionPaneDemo.component_cb2"));
|
||||||
cb.addItem(getString("OptionPaneDemo.component_cb3"));
|
cb.addItem(getString("OptionPaneDemo.component_cb3"));
|
||||||
|
@ -164,7 +164,9 @@ public class SliderDemo extends DemoModule {
|
|||||||
s.setPaintLabels( true );
|
s.setPaintLabels( true );
|
||||||
s.setSnapToTicks( 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.setLabelTable( s.getLabelTable() );
|
||||||
|
|
||||||
s.getAccessibleContext().setAccessibleName(getString("SliderDemo.minorticks"));
|
s.getAccessibleContext().setAccessibleName(getString("SliderDemo.minorticks"));
|
||||||
|
@ -165,7 +165,7 @@ public class SplitPaneDemo extends DemoModule {
|
|||||||
JLabel label;
|
JLabel label;
|
||||||
|
|
||||||
divSize = new JTextField();
|
divSize = new JTextField();
|
||||||
divSize.setText(new Integer(splitPane.getDividerSize()).toString());
|
divSize.setText(Integer.toString(splitPane.getDividerSize()));
|
||||||
divSize.setColumns(5);
|
divSize.setColumns(5);
|
||||||
divSize.getAccessibleContext().setAccessibleName(getString("SplitPaneDemo.divider_size"));
|
divSize.getAccessibleContext().setAccessibleName(getString("SplitPaneDemo.divider_size"));
|
||||||
divSize.addActionListener(new ActionListener() {
|
divSize.addActionListener(new ActionListener() {
|
||||||
|
@ -71,12 +71,7 @@ public class SwingSet2 extends JPanel {
|
|||||||
|
|
||||||
void loadDemos() {
|
void loadDemos() {
|
||||||
for(int i = 0; i < demos.length;) {
|
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++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,9 +121,6 @@ public class SwingSet2 extends JPanel {
|
|||||||
// Used only if swingset is an application
|
// Used only if swingset is an application
|
||||||
private JFrame frame = null;
|
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
|
// To debug or not to debug, that is the question
|
||||||
private boolean DEBUG = true;
|
private boolean DEBUG = true;
|
||||||
private int debugCounter = 0;
|
private int debugCounter = 0;
|
||||||
@ -151,27 +143,21 @@ public class SwingSet2 extends JPanel {
|
|||||||
|
|
||||||
private boolean dragEnabled = false;
|
private boolean dragEnabled = false;
|
||||||
|
|
||||||
public SwingSet2(SwingSet2Applet applet) {
|
public SwingSet2() {
|
||||||
this(applet, null);
|
this(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SwingSet2 Constructor
|
* SwingSet2 Constructor
|
||||||
*/
|
*/
|
||||||
public SwingSet2(SwingSet2Applet applet, GraphicsConfiguration gc) {
|
public SwingSet2(GraphicsConfiguration gc) {
|
||||||
|
|
||||||
// Note that applet may be null if this is started as an application
|
|
||||||
this.applet = applet;
|
|
||||||
|
|
||||||
String lafClassName = UIManager.getLookAndFeel().getClass().getName();
|
String lafClassName = UIManager.getLookAndFeel().getClass().getName();
|
||||||
lookAndFeelData = getInstalledLookAndFeelData();
|
lookAndFeelData = getInstalledLookAndFeelData();
|
||||||
currentLookAndFeel = Arrays.stream(lookAndFeelData)
|
currentLookAndFeel = Arrays.stream(lookAndFeelData)
|
||||||
.filter(laf -> lafClassName.equals(laf.className))
|
.filter(laf -> lafClassName.equals(laf.className))
|
||||||
.findFirst().get();
|
.findFirst().get();
|
||||||
|
|
||||||
if (!isApplet()) {
|
|
||||||
frame = createFrame(gc);
|
frame = createFrame(gc);
|
||||||
}
|
|
||||||
|
|
||||||
// set the layout
|
// set the layout
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
@ -198,7 +184,7 @@ public class SwingSet2 extends JPanel {
|
|||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
// Create SwingSet on the default monitor
|
// Create SwingSet on the default monitor
|
||||||
UIManager.put("swing.boldMetal", Boolean.FALSE);
|
UIManager.put("swing.boldMetal", Boolean.FALSE);
|
||||||
SwingSet2 swingset = new SwingSet2(null, GraphicsEnvironment.
|
SwingSet2 swingset = new SwingSet2(GraphicsEnvironment.
|
||||||
getLocalGraphicsEnvironment().
|
getLocalGraphicsEnvironment().
|
||||||
getDefaultScreenDevice().
|
getDefaultScreenDevice().
|
||||||
getDefaultConfiguration());
|
getDefaultConfiguration());
|
||||||
@ -218,11 +204,7 @@ public class SwingSet2 extends JPanel {
|
|||||||
|
|
||||||
menuBar = createMenus();
|
menuBar = createMenus();
|
||||||
|
|
||||||
if (isApplet()) {
|
|
||||||
applet.setJMenuBar(menuBar);
|
|
||||||
} else {
|
|
||||||
frame.setJMenuBar(menuBar);
|
frame.setJMenuBar(menuBar);
|
||||||
}
|
|
||||||
|
|
||||||
// creates popup menu accessible via keyboard
|
// creates popup menu accessible via keyboard
|
||||||
popupMenu = createPopupMenu();
|
popupMenu = createPopupMenu();
|
||||||
@ -309,13 +291,11 @@ public class SwingSet2 extends JPanel {
|
|||||||
"FileMenu.save_as_accessible_description", null);
|
"FileMenu.save_as_accessible_description", null);
|
||||||
|
|
||||||
|
|
||||||
if(!isApplet()) {
|
|
||||||
fileMenu.addSeparator();
|
fileMenu.addSeparator();
|
||||||
|
|
||||||
createMenuItem(fileMenu, "FileMenu.exit_label", "FileMenu.exit_mnemonic",
|
createMenuItem(fileMenu, "FileMenu.exit_label", "FileMenu.exit_mnemonic",
|
||||||
"FileMenu.exit_accessible_description", new ExitAction(this)
|
"FileMenu.exit_accessible_description", new ExitAction(this)
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
// Create these menu items for the first SwingSet only.
|
// Create these menu items for the first SwingSet only.
|
||||||
if (numSSs == 0) {
|
if (numSSs == 0) {
|
||||||
@ -431,7 +411,6 @@ public class SwingSet2 extends JPanel {
|
|||||||
|
|
||||||
|
|
||||||
// ***** create the multiscreen menu, if we have multiple screens
|
// ***** create the multiscreen menu, if we have multiple screens
|
||||||
if (!isApplet()) {
|
|
||||||
GraphicsDevice[] screens = GraphicsEnvironment.
|
GraphicsDevice[] screens = GraphicsEnvironment.
|
||||||
getLocalGraphicsEnvironment().
|
getLocalGraphicsEnvironment().
|
||||||
getScreenDevices();
|
getScreenDevices();
|
||||||
@ -449,7 +428,6 @@ public class SwingSet2 extends JPanel {
|
|||||||
createMultiscreenMenuItem(multiScreenMenu, i);
|
createMultiscreenMenuItem(multiScreenMenu, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return menuBar;
|
return menuBar;
|
||||||
}
|
}
|
||||||
@ -578,7 +556,7 @@ public class SwingSet2 extends JPanel {
|
|||||||
|
|
||||||
// register key binding to activate popup menu
|
// register key binding to activate popup menu
|
||||||
InputMap map = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
|
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");
|
"postMenuAction");
|
||||||
map.put(KeyStroke.getKeyStroke(KeyEvent.VK_CONTEXT_MENU, 0), "postMenuAction");
|
map.put(KeyStroke.getKeyStroke(KeyEvent.VK_CONTEXT_MENU, 0), "postMenuAction");
|
||||||
getActionMap().put("postMenuAction", new ActivatePopupMenuAction(this, popup));
|
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
|
* Bring up the SwingSet2 demo by showing the frame
|
||||||
* applicable if coming up as an application, not an applet);
|
|
||||||
*/
|
*/
|
||||||
public void showSwingSet2() {
|
public void showSwingSet2() {
|
||||||
if(!isApplet() && getFrame() != null) {
|
|
||||||
// put swingset in a frame and show it
|
// put swingset in a frame and show it
|
||||||
JFrame f = getFrame();
|
JFrame f = getFrame();
|
||||||
f.setTitle(getString("Frame.title"));
|
f.setTitle(getString("Frame.title"));
|
||||||
@ -686,11 +662,10 @@ public class SwingSet2 extends JPanel {
|
|||||||
screenInsets.top : centerHeight;
|
screenInsets.top : centerHeight;
|
||||||
|
|
||||||
f.setLocation(centerWidth, centerHeight);
|
f.setLocation(centerWidth, centerHeight);
|
||||||
f.show();
|
f.setVisible(true);
|
||||||
numSSs++;
|
numSSs++;
|
||||||
swingSets.add(this);
|
swingSets.add(this);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// *******************************************************
|
// *******************************************************
|
||||||
// ****************** Utility Methods ********************
|
// ****************** Utility Methods ********************
|
||||||
@ -703,8 +678,8 @@ public class SwingSet2 extends JPanel {
|
|||||||
setStatus(getString("Status.loading") + getString(classname + ".name"));
|
setStatus(getString("Status.loading") + getString(classname + ".name"));
|
||||||
DemoModule demo = null;
|
DemoModule demo = null;
|
||||||
try {
|
try {
|
||||||
Class demoClass = Class.forName(classname);
|
Class<?> demoClass = Class.forName(classname);
|
||||||
Constructor demoConstructor = demoClass.getConstructor(new Class[]{SwingSet2.class});
|
Constructor<?> demoConstructor = demoClass.getConstructor(new Class[]{SwingSet2.class});
|
||||||
demo = (DemoModule) demoConstructor.newInstance(new Object[]{this});
|
demo = (DemoModule) demoConstructor.newInstance(new Object[]{this});
|
||||||
addDemo(demo);
|
addDemo(demo);
|
||||||
} catch (Exception e) {
|
} 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
|
* Returns the frame instance
|
||||||
*/
|
*/
|
||||||
@ -763,8 +723,6 @@ public class SwingSet2 extends JPanel {
|
|||||||
if(contentPane == null) {
|
if(contentPane == null) {
|
||||||
if(getFrame() != null) {
|
if(getFrame() != null) {
|
||||||
contentPane = getFrame().getContentPane();
|
contentPane = getFrame().getContentPane();
|
||||||
} else if (getApplet() != null) {
|
|
||||||
contentPane = getApplet().getContentPane();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return contentPane;
|
return contentPane;
|
||||||
@ -886,16 +844,12 @@ public class SwingSet2 extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateThisSwingSet() {
|
private void updateThisSwingSet() {
|
||||||
if (isApplet()) {
|
|
||||||
SwingUtilities.updateComponentTreeUI(getApplet());
|
|
||||||
} else {
|
|
||||||
JFrame frame = getFrame();
|
JFrame frame = getFrame();
|
||||||
if (frame == null) {
|
if (frame == null) {
|
||||||
SwingUtilities.updateComponentTreeUI(this);
|
SwingUtilities.updateComponentTreeUI(this);
|
||||||
} else {
|
} else {
|
||||||
SwingUtilities.updateComponentTreeUI(frame);
|
SwingUtilities.updateComponentTreeUI(frame);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SwingUtilities.updateComponentTreeUI(popupMenu);
|
SwingUtilities.updateComponentTreeUI(popupMenu);
|
||||||
if (aboutBox != null) {
|
if (aboutBox != null) {
|
||||||
@ -909,13 +863,9 @@ public class SwingSet2 extends JPanel {
|
|||||||
public void updateLookAndFeel() {
|
public void updateLookAndFeel() {
|
||||||
try {
|
try {
|
||||||
UIManager.setLookAndFeel(currentLookAndFeel.className);
|
UIManager.setLookAndFeel(currentLookAndFeel.className);
|
||||||
if (isApplet()) {
|
|
||||||
updateThisSwingSet();
|
|
||||||
} else {
|
|
||||||
for (SwingSet2 ss : swingSets) {
|
for (SwingSet2 ss : swingSets) {
|
||||||
ss.updateThisSwingSet();
|
ss.updateThisSwingSet();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("Failed loading L&F: " + currentLookAndFeel);
|
System.out.println("Failed loading L&F: " + currentLookAndFeel);
|
||||||
System.out.println(ex);
|
System.out.println(ex);
|
||||||
@ -1142,15 +1092,11 @@ public class SwingSet2 extends JPanel {
|
|||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
boolean dragEnabled = ((JCheckBoxMenuItem)e.getSource()).isSelected();
|
boolean dragEnabled = ((JCheckBoxMenuItem)e.getSource()).isSelected();
|
||||||
if (isApplet()) {
|
|
||||||
setDragEnabled(dragEnabled);
|
|
||||||
} else {
|
|
||||||
for (SwingSet2 ss : swingSets) {
|
for (SwingSet2 ss : swingSets) {
|
||||||
ss.setDragEnabled(dragEnabled);
|
ss.setDragEnabled(dragEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
class ChangeThemeAction extends AbstractAction {
|
class ChangeThemeAction extends AbstractAction {
|
||||||
SwingSet2 swingset;
|
SwingSet2 swingset;
|
||||||
@ -1208,12 +1154,8 @@ public class SwingSet2 extends JPanel {
|
|||||||
button.addActionListener(new OkAction(aboutBox));
|
button.addActionListener(new OkAction(aboutBox));
|
||||||
}
|
}
|
||||||
aboutBox.pack();
|
aboutBox.pack();
|
||||||
if (isApplet()) {
|
|
||||||
aboutBox.setLocationRelativeTo(getApplet());
|
|
||||||
} else {
|
|
||||||
aboutBox.setLocationRelativeTo(getFrame());
|
aboutBox.setLocationRelativeTo(getFrame());
|
||||||
}
|
aboutBox.setVisible(true);
|
||||||
aboutBox.show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1231,13 +1173,13 @@ public class SwingSet2 extends JPanel {
|
|||||||
getScreenDevices();
|
getScreenDevices();
|
||||||
if (screen == ALL_SCREENS) {
|
if (screen == ALL_SCREENS) {
|
||||||
for (int i = 0; i < gds.length; i++) {
|
for (int i = 0; i < gds.length; i++) {
|
||||||
SwingSet2 swingset = new SwingSet2(null,
|
SwingSet2 swingset = new SwingSet2(
|
||||||
gds[i].getDefaultConfiguration());
|
gds[i].getDefaultConfiguration());
|
||||||
swingset.setDragEnabled(dragEnabled);
|
swingset.setDragEnabled(dragEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SwingSet2 swingset = new SwingSet2(null,
|
SwingSet2 swingset = new SwingSet2(
|
||||||
gds[screen].getDefaultConfiguration());
|
gds[screen].getDefaultConfiguration());
|
||||||
swingset.setDragEnabled(dragEnabled);
|
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 interCellSpacingSlider;
|
||||||
JSlider rowHeightSlider;
|
JSlider rowHeightSlider;
|
||||||
|
|
||||||
JComboBox selectionModeComboBox = null;
|
JComboBox<String> selectionModeComboBox = null;
|
||||||
JComboBox resizeModeComboBox = null;
|
JComboBox<String> resizeModeComboBox = null;
|
||||||
|
|
||||||
JLabel headerLabel;
|
JLabel headerLabel;
|
||||||
JLabel footerLabel;
|
JLabel footerLabel;
|
||||||
@ -126,7 +126,7 @@ public class TableDemo extends DemoModule {
|
|||||||
JPanel printPanel = new JPanel(new ColumnLayout());
|
JPanel printPanel = new JPanel(new ColumnLayout());
|
||||||
|
|
||||||
getDemoPanel().add(controlPanel, BorderLayout.NORTH);
|
getDemoPanel().add(controlPanel, BorderLayout.NORTH);
|
||||||
Vector relatedComponents = new Vector();
|
Vector<JComponent> relatedComponents = new Vector<>();
|
||||||
|
|
||||||
|
|
||||||
// check box panel
|
// check box panel
|
||||||
@ -245,7 +245,7 @@ public class TableDemo extends DemoModule {
|
|||||||
selectMode.setBorder(new TitledBorder(getString("TableDemo.selection_mode")));
|
selectMode.setBorder(new TitledBorder(getString("TableDemo.selection_mode")));
|
||||||
|
|
||||||
|
|
||||||
selectionModeComboBox = new JComboBox() {
|
selectionModeComboBox = new JComboBox<>() {
|
||||||
public Dimension getMaximumSize() {
|
public Dimension getMaximumSize() {
|
||||||
return getPreferredSize();
|
return getPreferredSize();
|
||||||
}
|
}
|
||||||
@ -256,7 +256,7 @@ public class TableDemo extends DemoModule {
|
|||||||
selectionModeComboBox.setSelectedIndex(tableView.getSelectionModel().getSelectionMode());
|
selectionModeComboBox.setSelectedIndex(tableView.getSelectionModel().getSelectionMode());
|
||||||
selectionModeComboBox.addItemListener(new ItemListener() {
|
selectionModeComboBox.addItemListener(new ItemListener() {
|
||||||
public void itemStateChanged(ItemEvent e) {
|
public void itemStateChanged(ItemEvent e) {
|
||||||
JComboBox source = (JComboBox)e.getSource();
|
JComboBox<?> source = (JComboBox<?>)e.getSource();
|
||||||
tableView.setSelectionMode(source.getSelectedIndex());
|
tableView.setSelectionMode(source.getSelectedIndex());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -272,7 +272,7 @@ public class TableDemo extends DemoModule {
|
|||||||
resizeMode.setBorder(new TitledBorder(getString("TableDemo.autoresize_mode")));
|
resizeMode.setBorder(new TitledBorder(getString("TableDemo.autoresize_mode")));
|
||||||
|
|
||||||
|
|
||||||
resizeModeComboBox = new JComboBox() {
|
resizeModeComboBox = new JComboBox<>() {
|
||||||
public Dimension getMaximumSize() {
|
public Dimension getMaximumSize() {
|
||||||
return getPreferredSize();
|
return getPreferredSize();
|
||||||
}
|
}
|
||||||
@ -285,7 +285,7 @@ public class TableDemo extends DemoModule {
|
|||||||
resizeModeComboBox.setSelectedIndex(tableView.getAutoResizeMode());
|
resizeModeComboBox.setSelectedIndex(tableView.getAutoResizeMode());
|
||||||
resizeModeComboBox.addItemListener(new ItemListener() {
|
resizeModeComboBox.addItemListener(new ItemListener() {
|
||||||
public void itemStateChanged(ItemEvent e) {
|
public void itemStateChanged(ItemEvent e) {
|
||||||
JComboBox source = (JComboBox)e.getSource();
|
JComboBox<?> source = (JComboBox<?>)e.getSource();
|
||||||
tableView.setAutoResizeMode(source.getSelectedIndex());
|
tableView.setAutoResizeMode(source.getSelectedIndex());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -367,7 +367,7 @@ public class TableDemo extends DemoModule {
|
|||||||
*
|
*
|
||||||
* @param components The list of objects that are related
|
* @param components The list of objects that are related
|
||||||
*/
|
*/
|
||||||
void buildAccessibleGroup(Vector components) {
|
void buildAccessibleGroup(Vector<JComponent> components) {
|
||||||
|
|
||||||
AccessibleContext context = null;
|
AccessibleContext context = null;
|
||||||
int numComponents = components.size();
|
int numComponents = components.size();
|
||||||
@ -492,55 +492,55 @@ public class TableDemo extends DemoModule {
|
|||||||
|
|
||||||
// Create the dummy data (a few rows of names)
|
// Create the dummy data (a few rows of names)
|
||||||
final Object[][] data = {
|
final Object[][] data = {
|
||||||
{"Mike", "Albers", green, getString("TableDemo.brazil"), new Double(44.0), strawberry},
|
{"Mike", "Albers", green, getString("TableDemo.brazil"), Double.valueOf(44.0), strawberry},
|
||||||
{"Mark", "Andrews", blue, getString("TableDemo.curse"), new Double(3), grapes},
|
{"Mark", "Andrews", blue, getString("TableDemo.curse"), Double.valueOf(3), grapes},
|
||||||
{"Brian", "Beck", black, getString("TableDemo.bluesbros"), new Double(2.7182818285), raspberry},
|
{"Brian", "Beck", black, getString("TableDemo.bluesbros"), Double.valueOf(2.7182818285), raspberry},
|
||||||
{"Lara", "Bunni", red, getString("TableDemo.airplane"), new Double(15), strawberry},
|
{"Lara", "Bunni", red, getString("TableDemo.airplane"), Double.valueOf(15), strawberry},
|
||||||
{"Roger", "Brinkley", blue, getString("TableDemo.man"), new Double(13), peach},
|
{"Roger", "Brinkley", blue, getString("TableDemo.man"), Double.valueOf(13), peach},
|
||||||
{"Brent", "Christian", black, getString("TableDemo.bladerunner"), new Double(23), broccoli},
|
{"Brent", "Christian", black, getString("TableDemo.bladerunner"), Double.valueOf(23), broccoli},
|
||||||
{"Mark", "Davidson", darkgreen, getString("TableDemo.brazil"), new Double(27), asparagus},
|
{"Mark", "Davidson", darkgreen, getString("TableDemo.brazil"), Double.valueOf(27), asparagus},
|
||||||
{"Jeff", "Dinkins", blue, getString("TableDemo.ladyvanishes"), new Double(8), kiwi},
|
{"Jeff", "Dinkins", blue, getString("TableDemo.ladyvanishes"), Double.valueOf(8), kiwi},
|
||||||
{"Ewan", "Dinkins", yellow, getString("TableDemo.bugs"), new Double(2), strawberry},
|
{"Ewan", "Dinkins", yellow, getString("TableDemo.bugs"), Double.valueOf(2), strawberry},
|
||||||
{"Amy", "Fowler", violet, getString("TableDemo.reservoir"), new Double(3), raspberry},
|
{"Amy", "Fowler", violet, getString("TableDemo.reservoir"), Double.valueOf(3), raspberry},
|
||||||
{"Hania", "Gajewska", purple, getString("TableDemo.jules"), new Double(5), raspberry},
|
{"Hania", "Gajewska", purple, getString("TableDemo.jules"), Double.valueOf(5), raspberry},
|
||||||
{"David", "Geary", blue, getString("TableDemo.pulpfiction"), new Double(3), watermelon},
|
{"David", "Geary", blue, getString("TableDemo.pulpfiction"), Double.valueOf(3), watermelon},
|
||||||
// {"James", "Gosling", pink, getString("TableDemo.tennis"), new Double(21), donut},
|
// {"James", "Gosling", pink, getString("TableDemo.tennis"), Double.valueOf(21), donut},
|
||||||
{"Eric", "Hawkes", blue, getString("TableDemo.bladerunner"), new Double(.693), pickle},
|
{"Eric", "Hawkes", blue, getString("TableDemo.bladerunner"), Double.valueOf(.693), pickle},
|
||||||
{"Shannon", "Hickey", green, getString("TableDemo.shawshank"), new Double(2), grapes},
|
{"Shannon", "Hickey", green, getString("TableDemo.shawshank"), Double.valueOf(2), grapes},
|
||||||
{"Earl", "Johnson", green, getString("TableDemo.pulpfiction"), new Double(8), carrot},
|
{"Earl", "Johnson", green, getString("TableDemo.pulpfiction"), Double.valueOf(8), carrot},
|
||||||
{"Robi", "Khan", green, getString("TableDemo.goodfellas"), new Double(89), apple},
|
{"Robi", "Khan", green, getString("TableDemo.goodfellas"), Double.valueOf(89), apple},
|
||||||
{"Robert", "Kim", blue, getString("TableDemo.mohicans"), new Double(655321), strawberry},
|
{"Robert", "Kim", blue, getString("TableDemo.mohicans"), Double.valueOf(655321), strawberry},
|
||||||
{"Janet", "Koenig", turquoise, getString("TableDemo.lonestar"), new Double(7), peach},
|
{"Janet", "Koenig", turquoise, getString("TableDemo.lonestar"), Double.valueOf(7), peach},
|
||||||
{"Jeff", "Kesselman", blue, getString("TableDemo.stuntman"), new Double(17), pineapple},
|
{"Jeff", "Kesselman", blue, getString("TableDemo.stuntman"), Double.valueOf(17), pineapple},
|
||||||
{"Onno", "Kluyt", orange, getString("TableDemo.oncewest"), new Double(8), broccoli},
|
{"Onno", "Kluyt", orange, getString("TableDemo.oncewest"), Double.valueOf(8), broccoli},
|
||||||
{"Peter", "Korn", sunpurple, getString("TableDemo.musicman"), new Double(12), sparegrass},
|
{"Peter", "Korn", sunpurple, getString("TableDemo.musicman"), Double.valueOf(12), sparegrass},
|
||||||
|
|
||||||
{"Rick", "Levenson", black, getString("TableDemo.harold"), new Double(1327), raspberry},
|
{"Rick", "Levenson", black, getString("TableDemo.harold"), Double.valueOf(1327), raspberry},
|
||||||
{"Brian", "Lichtenwalter", jfcblue, getString("TableDemo.fifthelement"), new Double(22), pear},
|
{"Brian", "Lichtenwalter", jfcblue, getString("TableDemo.fifthelement"), Double.valueOf(22), pear},
|
||||||
{"Malini", "Minasandram", beige, getString("TableDemo.joyluck"), new Double(9), corn},
|
{"Malini", "Minasandram", beige, getString("TableDemo.joyluck"), Double.valueOf(9), corn},
|
||||||
{"Michael", "Martak", green, getString("TableDemo.city"), new Double(3), strawberry},
|
{"Michael", "Martak", green, getString("TableDemo.city"), Double.valueOf(3), strawberry},
|
||||||
{"David", "Mendenhall", forestgreen, getString("TableDemo.schindlerslist"), new Double(7), peach},
|
{"David", "Mendenhall", forestgreen, getString("TableDemo.schindlerslist"), Double.valueOf(7), peach},
|
||||||
{"Phil", "Milne", suspectpink, getString("TableDemo.withnail"), new Double(3), banana},
|
{"Phil", "Milne", suspectpink, getString("TableDemo.withnail"), Double.valueOf(3), banana},
|
||||||
{"Lynn", "Monsanto", cybergreen, getString("TableDemo.dasboot"), new Double(52), peach},
|
{"Lynn", "Monsanto", cybergreen, getString("TableDemo.dasboot"), Double.valueOf(52), peach},
|
||||||
{"Hans", "Muller", rustred, getString("TableDemo.eraserhead"), new Double(0), pineapple},
|
{"Hans", "Muller", rustred, getString("TableDemo.eraserhead"), Double.valueOf(0), pineapple},
|
||||||
{"Joshua", "Outwater", blue, getString("TableDemo.labyrinth"), new Double(3), pineapple},
|
{"Joshua", "Outwater", blue, getString("TableDemo.labyrinth"), Double.valueOf(3), pineapple},
|
||||||
{"Tim", "Prinzing", blue, getString("TableDemo.firstsight"), new Double(69), pepper},
|
{"Tim", "Prinzing", blue, getString("TableDemo.firstsight"), Double.valueOf(69), pepper},
|
||||||
{"Raj", "Premkumar", jfcblue2, getString("TableDemo.none"), new Double(7), broccoli},
|
{"Raj", "Premkumar", jfcblue2, getString("TableDemo.none"), Double.valueOf(7), broccoli},
|
||||||
{"Howard", "Rosen", green, getString("TableDemo.defending"), new Double(7), strawberry},
|
{"Howard", "Rosen", green, getString("TableDemo.defending"), Double.valueOf(7), strawberry},
|
||||||
{"Ray", "Ryan", black, getString("TableDemo.buckaroo"),
|
{"Ray", "Ryan", black, getString("TableDemo.buckaroo"),
|
||||||
new Double(3.141592653589793238462643383279502884197169399375105820974944), banana},
|
Double.valueOf(3.141592653589793238462643383279502884197169399375105820974944), banana},
|
||||||
{"Georges", "Saab", aqua, getString("TableDemo.bicycle"), new Double(290), cantaloupe},
|
{"Georges", "Saab", aqua, getString("TableDemo.bicycle"), Double.valueOf(290), cantaloupe},
|
||||||
{"Tom", "Santos", blue, getString("TableDemo.spinaltap"), new Double(241), pepper},
|
{"Tom", "Santos", blue, getString("TableDemo.spinaltap"), Double.valueOf(241), pepper},
|
||||||
{"Rich", "Schiavi", blue, getString("TableDemo.repoman"), new Double(0xFF), pepper},
|
{"Rich", "Schiavi", blue, getString("TableDemo.repoman"), Double.valueOf(0xFF), pepper},
|
||||||
{"Nancy", "Schorr", green, getString("TableDemo.fifthelement"), new Double(47), watermelon},
|
{"Nancy", "Schorr", green, getString("TableDemo.fifthelement"), Double.valueOf(47), watermelon},
|
||||||
{"Keith", "Sprochi", darkgreen, getString("TableDemo.2001"), new Double(13), watermelon},
|
{"Keith", "Sprochi", darkgreen, getString("TableDemo.2001"), Double.valueOf(13), watermelon},
|
||||||
{"Matt", "Tucker", eblue, getString("TableDemo.starwars"), new Double(2), broccoli},
|
{"Matt", "Tucker", eblue, getString("TableDemo.starwars"), Double.valueOf(2), broccoli},
|
||||||
{"Dmitri", "Trembovetski", red, getString("TableDemo.aliens"), new Double(222), tomato},
|
{"Dmitri", "Trembovetski", red, getString("TableDemo.aliens"), Double.valueOf(222), tomato},
|
||||||
{"Scott", "Violet", violet, getString("TableDemo.raiders"), new Double(-97), banana},
|
{"Scott", "Violet", violet, getString("TableDemo.raiders"), Double.valueOf(-97), banana},
|
||||||
{"Kathy", "Walrath", darkgreen, getString("TableDemo.thinman"), new Double(8), pear},
|
{"Kathy", "Walrath", darkgreen, getString("TableDemo.thinman"), Double.valueOf(8), pear},
|
||||||
{"Nathan", "Walrath", black, getString("TableDemo.chusingura"), new Double(3), grapefruit},
|
{"Nathan", "Walrath", black, getString("TableDemo.chusingura"), Double.valueOf(3), grapefruit},
|
||||||
{"Steve", "Wilson", green, getString("TableDemo.raiders"), new Double(7), onion},
|
{"Steve", "Wilson", green, getString("TableDemo.raiders"), Double.valueOf(7), onion},
|
||||||
{"Kathleen", "Zelony", gray, getString("TableDemo.dog"), new Double(13), grapes}
|
{"Kathleen", "Zelony", gray, getString("TableDemo.dog"), Double.valueOf(13), grapes}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create a model of the data.
|
// Create a model of the data.
|
||||||
@ -549,7 +549,7 @@ public class TableDemo extends DemoModule {
|
|||||||
public int getRowCount() { return data.length;}
|
public int getRowCount() { return data.length;}
|
||||||
public Object getValueAt(int row, int col) {return data[row][col];}
|
public Object getValueAt(int row, int col) {return data[row][col];}
|
||||||
public String getColumnName(int column) {return names[column];}
|
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 boolean isCellEditable(int row, int col) {return col != 5;}
|
||||||
public void setValueAt(Object aValue, int row, int column) { data[row][column] = aValue; }
|
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
|
// Create the table
|
||||||
tableView = new JTable(dataModel);
|
tableView = new JTable(dataModel);
|
||||||
TableRowSorter sorter = new TableRowSorter(dataModel);
|
TableRowSorter<TableModel> sorter = new TableRowSorter<>(dataModel);
|
||||||
tableView.setRowSorter(sorter);
|
tableView.setRowSorter(sorter);
|
||||||
|
|
||||||
// Show colors by rendering them in their own color.
|
// 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.
|
// 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(aqua);
|
||||||
comboBox.addItem(beige);
|
comboBox.addItem(beige);
|
||||||
comboBox.addItem(black);
|
comboBox.addItem(black);
|
||||||
|
@ -125,12 +125,6 @@ public class JDBCAdapter extends AbstractTableModel {
|
|||||||
connection.close();
|
connection.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void finalize() throws Throwable {
|
|
||||||
close();
|
|
||||||
super.finalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Implementation of the TableModel Interface
|
// Implementation of the TableModel Interface
|
||||||
|
@ -72,7 +72,7 @@ public class OldJTable extends JTable
|
|||||||
return addColumn(columnIdentifier, width, null, null, null);
|
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);
|
return addColumn(columnIdentifier, -1, null, null, columnData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ public class OldJTable extends JTable
|
|||||||
|
|
||||||
public TableColumn addColumn(Object columnIdentifier, int width,
|
public TableColumn addColumn(Object columnIdentifier, int width,
|
||||||
TableCellRenderer renderer,
|
TableCellRenderer renderer,
|
||||||
TableCellEditor editor, List columnData) {
|
TableCellEditor editor, List<?> columnData) {
|
||||||
checkDefaultTableModel();
|
checkDefaultTableModel();
|
||||||
|
|
||||||
// Set up the model side first
|
// Set up the model side first
|
||||||
@ -112,7 +112,7 @@ public class OldJTable extends JTable
|
|||||||
((DefaultTableModel)getModel()).addRow(rowData);
|
((DefaultTableModel)getModel()).addRow(rowData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRow(List rowData) {
|
public void addRow(List<?> rowData) {
|
||||||
checkDefaultTableModel();
|
checkDefaultTableModel();
|
||||||
((DefaultTableModel)getModel()).addRow(rowData.toArray());
|
((DefaultTableModel)getModel()).addRow(rowData.toArray());
|
||||||
}
|
}
|
||||||
@ -132,7 +132,7 @@ public class OldJTable extends JTable
|
|||||||
((DefaultTableModel)getModel()).insertRow(rowIndex, rowData);
|
((DefaultTableModel)getModel()).insertRow(rowIndex, rowData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertRow(int rowIndex, List rowData) {
|
public void insertRow(int rowIndex, List<?> rowData) {
|
||||||
checkDefaultTableModel();
|
checkDefaultTableModel();
|
||||||
((DefaultTableModel)getModel()).insertRow(rowIndex, rowData.toArray());
|
((DefaultTableModel)getModel()).insertRow(rowIndex, rowData.toArray());
|
||||||
}
|
}
|
||||||
@ -142,7 +142,7 @@ public class OldJTable extends JTable
|
|||||||
((DefaultTableModel)getModel()).setNumRows(newSize);
|
((DefaultTableModel)getModel()).setNumRows(newSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDataVector(Object[][] newData, List columnIds) {
|
public void setDataVector(Object[][] newData, List<?> columnIds) {
|
||||||
checkDefaultTableModel();
|
checkDefaultTableModel();
|
||||||
((DefaultTableModel)getModel()).setDataVector(
|
((DefaultTableModel)getModel()).setDataVector(
|
||||||
newData, columnIds.toArray());
|
newData, columnIds.toArray());
|
||||||
|
@ -73,27 +73,27 @@ public class TableExample3 {
|
|||||||
final String[] names = { "First Name", "Last Name", "Favorite Color",
|
final String[] names = { "First Name", "Last Name", "Favorite Color",
|
||||||
"Favorite Number", "Vegetarian" };
|
"Favorite Number", "Vegetarian" };
|
||||||
final Object[][] data = {
|
final Object[][] data = {
|
||||||
{ "Mark", "Andrews", "Red", new Integer(2), Boolean.TRUE },
|
{ "Mark", "Andrews", "Red", Integer.valueOf(2), Boolean.TRUE },
|
||||||
{ "Tom", "Ball", "Blue", new Integer(99), Boolean.FALSE },
|
{ "Tom", "Ball", "Blue", Integer.valueOf(99), Boolean.FALSE },
|
||||||
{ "Alan", "Chung", "Green", new Integer(838), Boolean.FALSE },
|
{ "Alan", "Chung", "Green", Integer.valueOf(838), Boolean.FALSE },
|
||||||
{ "Jeff", "Dinkins", "Turquois", new Integer(8), Boolean.TRUE },
|
{ "Jeff", "Dinkins", "Turquois", Integer.valueOf(8), Boolean.TRUE },
|
||||||
{ "Amy", "Fowler", "Yellow", new Integer(3), Boolean.FALSE },
|
{ "Amy", "Fowler", "Yellow", Integer.valueOf(3), Boolean.FALSE },
|
||||||
{ "Brian", "Gerhold", "Green", new Integer(0), Boolean.FALSE },
|
{ "Brian", "Gerhold", "Green", Integer.valueOf(0), Boolean.FALSE },
|
||||||
{ "James", "Gosling", "Pink", new Integer(21), Boolean.FALSE },
|
{ "James", "Gosling", "Pink", Integer.valueOf(21), Boolean.FALSE },
|
||||||
{ "David", "Karlton", "Red", new Integer(1), Boolean.FALSE },
|
{ "David", "Karlton", "Red", Integer.valueOf(1), Boolean.FALSE },
|
||||||
{ "Dave", "Kloba", "Yellow", new Integer(14), Boolean.FALSE },
|
{ "Dave", "Kloba", "Yellow", Integer.valueOf(14), Boolean.FALSE },
|
||||||
{ "Peter", "Korn", "Purple", new Integer(12), Boolean.FALSE },
|
{ "Peter", "Korn", "Purple", Integer.valueOf(12), Boolean.FALSE },
|
||||||
{ "Phil", "Milne", "Purple", new Integer(3), Boolean.FALSE },
|
{ "Phil", "Milne", "Purple", Integer.valueOf(3), Boolean.FALSE },
|
||||||
{ "Dave", "Moore", "Green", new Integer(88), Boolean.FALSE },
|
{ "Dave", "Moore", "Green", Integer.valueOf(88), Boolean.FALSE },
|
||||||
{ "Hans", "Muller", "Maroon", new Integer(5), Boolean.FALSE },
|
{ "Hans", "Muller", "Maroon", Integer.valueOf(5), Boolean.FALSE },
|
||||||
{ "Rick", "Levenson", "Blue", new Integer(2), Boolean.FALSE },
|
{ "Rick", "Levenson", "Blue", Integer.valueOf(2), Boolean.FALSE },
|
||||||
{ "Tim", "Prinzing", "Blue", new Integer(22), Boolean.FALSE },
|
{ "Tim", "Prinzing", "Blue", Integer.valueOf(22), Boolean.FALSE },
|
||||||
{ "Chester", "Rose", "Black", new Integer(0), Boolean.FALSE },
|
{ "Chester", "Rose", "Black", Integer.valueOf(0), Boolean.FALSE },
|
||||||
{ "Ray", "Ryan", "Gray", new Integer(77), Boolean.FALSE },
|
{ "Ray", "Ryan", "Gray", Integer.valueOf(77), Boolean.FALSE },
|
||||||
{ "Georges", "Saab", "Red", new Integer(4), Boolean.FALSE },
|
{ "Georges", "Saab", "Red", Integer.valueOf(4), Boolean.FALSE },
|
||||||
{ "Willie", "Walker", "Phthalo Blue", new Integer(4), Boolean.FALSE },
|
{ "Willie", "Walker", "Phthalo Blue", Integer.valueOf(4), Boolean.FALSE },
|
||||||
{ "Kathy", "Walrath", "Blue", new Integer(8), Boolean.FALSE },
|
{ "Kathy", "Walrath", "Blue", Integer.valueOf(8), Boolean.FALSE },
|
||||||
{ "Arnaud", "Weber", "Green", new Integer(44), Boolean.FALSE }
|
{ "Arnaud", "Weber", "Green", Integer.valueOf(44), Boolean.FALSE }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create a model of the data.
|
// Create a model of the data.
|
||||||
@ -121,7 +121,7 @@ public class TableExample3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class getColumnClass(int col) {
|
public Class<?> getColumnClass(int col) {
|
||||||
return getValueAt(0, col).getClass();
|
return getValueAt(0, col).getClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,27 +75,27 @@ public class TableExample4 {
|
|||||||
final String[] names = { "First Name", "Last Name", "Favorite Color",
|
final String[] names = { "First Name", "Last Name", "Favorite Color",
|
||||||
"Favorite Number", "Vegetarian" };
|
"Favorite Number", "Vegetarian" };
|
||||||
final Object[][] data = {
|
final Object[][] data = {
|
||||||
{ "Mark", "Andrews", "Red", new Integer(2), Boolean.TRUE },
|
{ "Mark", "Andrews", "Red", Integer.valueOf(2), Boolean.TRUE },
|
||||||
{ "Tom", "Ball", "Blue", new Integer(99), Boolean.FALSE },
|
{ "Tom", "Ball", "Blue", Integer.valueOf(99), Boolean.FALSE },
|
||||||
{ "Alan", "Chung", "Green", new Integer(838), Boolean.FALSE },
|
{ "Alan", "Chung", "Green", Integer.valueOf(838), Boolean.FALSE },
|
||||||
{ "Jeff", "Dinkins", "Turquois", new Integer(8), Boolean.TRUE },
|
{ "Jeff", "Dinkins", "Turquois", Integer.valueOf(8), Boolean.TRUE },
|
||||||
{ "Amy", "Fowler", "Yellow", new Integer(3), Boolean.FALSE },
|
{ "Amy", "Fowler", "Yellow", Integer.valueOf(3), Boolean.FALSE },
|
||||||
{ "Brian", "Gerhold", "Green", new Integer(0), Boolean.FALSE },
|
{ "Brian", "Gerhold", "Green", Integer.valueOf(0), Boolean.FALSE },
|
||||||
{ "James", "Gosling", "Pink", new Integer(21), Boolean.FALSE },
|
{ "James", "Gosling", "Pink", Integer.valueOf(21), Boolean.FALSE },
|
||||||
{ "David", "Karlton", "Red", new Integer(1), Boolean.FALSE },
|
{ "David", "Karlton", "Red", Integer.valueOf(1), Boolean.FALSE },
|
||||||
{ "Dave", "Kloba", "Yellow", new Integer(14), Boolean.FALSE },
|
{ "Dave", "Kloba", "Yellow", Integer.valueOf(14), Boolean.FALSE },
|
||||||
{ "Peter", "Korn", "Purple", new Integer(12), Boolean.FALSE },
|
{ "Peter", "Korn", "Purple", Integer.valueOf(12), Boolean.FALSE },
|
||||||
{ "Phil", "Milne", "Purple", new Integer(3), Boolean.FALSE },
|
{ "Phil", "Milne", "Purple", Integer.valueOf(3), Boolean.FALSE },
|
||||||
{ "Dave", "Moore", "Green", new Integer(88), Boolean.FALSE },
|
{ "Dave", "Moore", "Green", Integer.valueOf(88), Boolean.FALSE },
|
||||||
{ "Hans", "Muller", "Maroon", new Integer(5), Boolean.FALSE },
|
{ "Hans", "Muller", "Maroon", Integer.valueOf(5), Boolean.FALSE },
|
||||||
{ "Rick", "Levenson", "Blue", new Integer(2), Boolean.FALSE },
|
{ "Rick", "Levenson", "Blue", Integer.valueOf(2), Boolean.FALSE },
|
||||||
{ "Tim", "Prinzing", "Blue", new Integer(22), Boolean.FALSE },
|
{ "Tim", "Prinzing", "Blue", Integer.valueOf(22), Boolean.FALSE },
|
||||||
{ "Chester", "Rose", "Black", new Integer(0), Boolean.FALSE },
|
{ "Chester", "Rose", "Black", Integer.valueOf(0), Boolean.FALSE },
|
||||||
{ "Ray", "Ryan", "Gray", new Integer(77), Boolean.FALSE },
|
{ "Ray", "Ryan", "Gray", Integer.valueOf(77), Boolean.FALSE },
|
||||||
{ "Georges", "Saab", "Red", new Integer(4), Boolean.FALSE },
|
{ "Georges", "Saab", "Red", Integer.valueOf(4), Boolean.FALSE },
|
||||||
{ "Willie", "Walker", "Phthalo Blue", new Integer(4), Boolean.FALSE },
|
{ "Willie", "Walker", "Phthalo Blue", Integer.valueOf(4), Boolean.FALSE },
|
||||||
{ "Kathy", "Walrath", "Blue", new Integer(8), Boolean.FALSE },
|
{ "Kathy", "Walrath", "Blue", Integer.valueOf(8), Boolean.FALSE },
|
||||||
{ "Arnaud", "Weber", "Green", new Integer(44), Boolean.FALSE }
|
{ "Arnaud", "Weber", "Green", Integer.valueOf(44), Boolean.FALSE }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create a model of the data.
|
// Create a model of the data.
|
||||||
@ -123,7 +123,7 @@ public class TableExample4 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class getColumnClass(int c) {
|
public Class<?> getColumnClass(int c) {
|
||||||
return getValueAt(0, c).getClass();
|
return getValueAt(0, c).getClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ public class TableExample4 {
|
|||||||
tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
||||||
|
|
||||||
// Create a combo box to show that you can use one in a table.
|
// 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("Red");
|
||||||
comboBox.addItem("Orange");
|
comboBox.addItem("Orange");
|
||||||
comboBox.addItem("Yellow");
|
comboBox.addItem("Yellow");
|
||||||
|
@ -94,7 +94,7 @@ public class TableMap extends AbstractTableModel implements TableModelListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class getColumnClass(int aColumn) {
|
public Class<?> getColumnClass(int aColumn) {
|
||||||
return model.getColumnClass(aColumn);
|
return model.getColumnClass(aColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public final class TableSorter extends TableMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int compareRowsByColumn(int row1, int row2, int column) {
|
public int compareRowsByColumn(int row1, int row2, int column) {
|
||||||
Class type = model.getColumnClass(column);
|
Class<?> type = model.getColumnClass(column);
|
||||||
TableModel data = model;
|
TableModel data = model;
|
||||||
|
|
||||||
// Check for nulls
|
// Check for nulls
|
||||||
@ -339,7 +339,7 @@ public final class TableSorter extends TableMap {
|
|||||||
int column = tableView.convertColumnIndexToModel(viewColumn);
|
int column = tableView.convertColumnIndexToModel(viewColumn);
|
||||||
if (e.getClickCount() == 1 && column != -1) {
|
if (e.getClickCount() == 1 && column != -1) {
|
||||||
System.out.println("Sorting ...");
|
System.out.println("Sorting ...");
|
||||||
int shiftPressed = e.getModifiers() & InputEvent.SHIFT_MASK;
|
int shiftPressed = e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK;
|
||||||
boolean ascending = (shiftPressed == 0);
|
boolean ascending = (shiftPressed == 0);
|
||||||
sorter.sortByColumn(column, ascending);
|
sorter.sortByColumn(column, ascending);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user