Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Apress committed Oct 7, 2016
0 parents commit cb2bf52
Show file tree
Hide file tree
Showing 1,055 changed files with 14,251 additions and 0 deletions.
Binary file added 2162.pdf
Binary file not shown.
Binary file added 9781590594476.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ch01/ColorSample$1$1.class
Binary file not shown.
Binary file added Ch01/ColorSample$1.class
Binary file not shown.
Binary file added Ch01/ColorSample.class
Binary file not shown.
30 changes: 30 additions & 0 deletions Ch01/ColorSample.java
@@ -0,0 +1,30 @@
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ColorSample {
public static void main (String args[]) {
Runnable runner = new Runnable() {
public void run() {
JFrame f = new JFrame("JColorChooser Sample");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JButton button = new JButton("Pick to Change Background");

ActionListener actionListener = new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
Color initialBackground = button.getBackground();
Color background = JColorChooser.showDialog(null, "JColorChooser Sample", initialBackground);
if (background != null) {
button.setBackground(background);
}
}
};
button.addActionListener(actionListener);
f.add(button, BorderLayout.CENTER);
f.setSize (300, 200);
f.setVisible (true);
}
};
EventQueue.invokeLater(runner);
}
}
Binary file added Ch01/DesktopSample$1.class
Binary file not shown.
Binary file added Ch01/DesktopSample$SelfInternalFrame.class
Binary file not shown.
Binary file added Ch01/DesktopSample.class
Binary file not shown.
37 changes: 37 additions & 0 deletions Ch01/DesktopSample.java
@@ -0,0 +1,37 @@
import java.awt.*;
import javax.swing.*;

public class DesktopSample {
public static void main (String args[]) {
Runnable runner = new Runnable() {
public void run() {
JFrame f = new JFrame("JDesktopPane Sample");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLayeredPane desktop = new JDesktopPane();
desktop.setOpaque(false);
desktop.add (createLayer ("Open 1"), JLayeredPane.POPUP_LAYER);
desktop.add (createLayer ("Iconified"), JLayeredPane.DEFAULT_LAYER);
desktop.add (createLayer ("Open 2"), JLayeredPane.PALETTE_LAYER);
f.add(desktop, BorderLayout.CENTER);
f.setSize (300, 200);
f.setVisible (true);
}
};
EventQueue.invokeLater(runner);
}
public static JInternalFrame createLayer (String label) {
return new SelfInternalFrame(label);
}
static class SelfInternalFrame extends JInternalFrame {
public SelfInternalFrame(String s) {
getContentPane().add (new JLabel (s), BorderLayout.CENTER);
setBounds (50, 50, 100, 100);
setResizable (true);
setClosable (true);
setMaximizable (true);
setIconifiable (true);
setTitle (s);
setVisible (true);
}
}
}
Binary file added Ch01/EditorSample$1.class
Binary file not shown.
Binary file added Ch01/EditorSample.class
Binary file not shown.
20 changes: 20 additions & 0 deletions Ch01/EditorSample.java
@@ -0,0 +1,20 @@
import java.awt.*;
import javax.swing.*;

public class EditorSample {
public static void main (String args[]) {
Runnable runner = new Runnable() {
public void run() {
JFrame f = new JFrame("JEditorPane Sample");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JEditorPane editor = new JEditorPane("text/html", "<H3>Help</H3><center><IMG src=file:///c:/swing3/code/Ch01/logo.jpg></center><li>One<li><i>Two</i><li><u>Three</u>");
editor.setEditable(false);
JScrollPane scrollPane = new JScrollPane(editor);
f.add(scrollPane, BorderLayout.CENTER);
f.setSize (300, 200);
f.setVisible (true);
}
};
EventQueue.invokeLater(runner);
}
}
Binary file added Ch01/FormattedSample$1.class
Binary file not shown.
Binary file added Ch01/FormattedSample.class
Binary file not shown.
34 changes: 34 additions & 0 deletions Ch01/FormattedSample.java
@@ -0,0 +1,34 @@
import java.awt.*;
import java.text.*;
import javax.swing.*;
import javax.swing.text.*;

public class FormattedSample {
public static void main (String args[]) {
Runnable runner = new Runnable() {
public void run() {
JFrame f = new JFrame("JFormattedTextField Sample");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Box rowOne = Box.createHorizontalBox();
rowOne.add(new JLabel("SSN:"));
try {
MaskFormatter mf1 = new MaskFormatter("###-##-####");
rowOne.add(new JFormattedTextField(mf1));
} catch (ParseException e) {
}
Box rowTwo = Box.createHorizontalBox();
rowTwo.add(new JLabel("Telephone #: "));
try {
MaskFormatter mf2 = new MaskFormatter("(###) ###-####");
rowTwo.add(new JFormattedTextField(mf2));
} catch (ParseException e) {
}
f.add(rowOne, BorderLayout.NORTH);
f.add(rowTwo, BorderLayout.SOUTH);
f.setSize (300, 100);
f.setVisible (true);
}
};
EventQueue.invokeLater(runner);
}
}
Binary file added Ch01/NamedVector.class
Binary file not shown.
17 changes: 17 additions & 0 deletions Ch01/NamedVector.java
@@ -0,0 +1,17 @@
import java.util.Vector;
public class NamedVector extends Vector {
String name;
NamedVector(String name) {
this.name = name;
}
NamedVector(String name, Object elements[]) {
this.name = name;
for (int i=0, n=elements.length; i<n; i++) {
add(elements[i]);
}
}
public String toString() {
return name;
}
}

Binary file added Ch01/OptionPaneSample$1$1.class
Binary file not shown.
Binary file added Ch01/OptionPaneSample$1.class
Binary file not shown.
Binary file added Ch01/OptionPaneSample.class
Binary file not shown.
34 changes: 34 additions & 0 deletions Ch01/OptionPaneSample.java
@@ -0,0 +1,34 @@
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class OptionPaneSample {
public static void main (String args[]) {
Runnable runner = new Runnable() {
public void run() {
JFrame f = new JFrame("JOptionPane Sample");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton button = new JButton ("Ask");
ActionListener actionListener = new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
Component source = (Component)actionEvent.getSource();
Object response = JOptionPane.showInputDialog(
source,
"Where do you want to go tomorrow?",
"JOptionPane Sample",
JOptionPane.QUESTION_MESSAGE,
null,
new String[] {"Tower of London", "Westminster Abbey", "Buckingham Palace", "Trafalgar Square", "Madame Tussaud's Wax Museum"},
"Westminster Abbey");
System.out.println ("Response: " + response);
}
};
button.addActionListener(actionListener);
f.add(button, BorderLayout.CENTER);
f.setSize (300, 200);
f.setVisible (true);
}
};
EventQueue.invokeLater(runner);
}
}
Binary file added Ch01/PasswordSample$1.class
Binary file not shown.
Binary file added Ch01/PasswordSample.class
Binary file not shown.
24 changes: 24 additions & 0 deletions Ch01/PasswordSample.java
@@ -0,0 +1,24 @@
import java.awt.*;
import javax.swing.*;

public class PasswordSample {
public static void main (String args[]) {
Runnable runner = new Runnable() {
public void run() {
JFrame f = new JFrame("JPasswordField Sample");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Box rowOne = Box.createHorizontalBox();
rowOne.add(new JLabel("Username"));
rowOne.add(new JTextField());
Box rowTwo = Box.createHorizontalBox();
rowTwo.add(new JLabel("Password"));
rowTwo.add(new JPasswordField());
f.add(rowOne, BorderLayout.NORTH);
f.add(rowTwo, BorderLayout.SOUTH);
f.setSize (300, 200);
f.setVisible (true);
}
};
EventQueue.invokeLater(runner);
}
}
Binary file added Ch01/ProgressSample$1.class
Binary file not shown.
Binary file added Ch01/ProgressSample.class
Binary file not shown.
23 changes: 23 additions & 0 deletions Ch01/ProgressSample.java
@@ -0,0 +1,23 @@
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;

public class ProgressSample {
public static void main (String args[]) {
Runnable runner = new Runnable() {
public void run() {
JFrame f = new JFrame("JProgressBar Sample");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JProgressBar progressBar = new JProgressBar();
progressBar.setValue(25);
progressBar.setStringPainted(true);
Border border = BorderFactory.createTitledBorder("Reading...");
progressBar.setBorder(border);
f.add(progressBar, BorderLayout.NORTH);
f.setSize (300, 100);
f.setVisible (true);
}
};
EventQueue.invokeLater(runner);
}
}
Binary file added Ch01/RadioButtonMenuSample$1.class
Binary file not shown.
Binary file added Ch01/RadioButtonMenuSample.class
Binary file not shown.
45 changes: 45 additions & 0 deletions Ch01/RadioButtonMenuSample.java
@@ -0,0 +1,45 @@
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class RadioButtonMenuSample {
public static void main (String args[]) {
Runnable runner = new Runnable() {
public void run() {
JFrame f = new JFrame("JRadioButtonMenuItem Sample");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JMenuBar bar = new JMenuBar();
JMenu menu = new JMenu("Options");
menu.setMnemonic(KeyEvent.VK_O);

ButtonGroup group = new ButtonGroup();

JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem("North");
group.add(menuItem);
menu.add(menuItem);

menuItem = new JRadioButtonMenuItem("East");
group.add(menuItem);
menu.add(menuItem);

menuItem = new JRadioButtonMenuItem("West");
group.add(menuItem);
menu.add(menuItem);

menuItem = new JRadioButtonMenuItem("South");
group.add(menuItem);
menu.add(menuItem);

menuItem = new JRadioButtonMenuItem("Center");
group.add(menuItem);
menu.add(menuItem);

bar.add(menu);
f.setJMenuBar(bar);
f.setSize (300, 200);
f.setVisible (true);
}
};
EventQueue.invokeLater(runner);
}
}
Binary file added Ch01/SeparatorSample$1.class
Binary file not shown.
Binary file added Ch01/SeparatorSample.class
Binary file not shown.
23 changes: 23 additions & 0 deletions Ch01/SeparatorSample.java
@@ -0,0 +1,23 @@
import java.awt.*;
import javax.swing.*;

public class SeparatorSample {
public static void main (String args[]) {
Runnable runner = new Runnable() {
public void run() {
JFrame f = new JFrame("JSeparator Sample");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setLayout(new GridLayout(0, 1));
JLabel above = new JLabel("Above Separator");
f.add(above);
JSeparator separator = new JSeparator();
f.add(separator);
JLabel below = new JLabel("Below Separator");
f.add(below);
f.setSize (300, 100);
f.setVisible (true);
}
};
EventQueue.invokeLater(runner);
}
}
Binary file added Ch01/SliderSample$1.class
Binary file not shown.
Binary file added Ch01/SliderSample.class
Binary file not shown.
24 changes: 24 additions & 0 deletions Ch01/SliderSample.java
@@ -0,0 +1,24 @@
import java.awt.*;
import javax.swing.*;

public class SliderSample {
public static void main (String args[]) {
Runnable runner = new Runnable() {
public void run() {
JFrame f = new JFrame("JSlider Sample");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JSlider slider = new JSlider ();
slider.setMinorTickSpacing (5);
slider.setMajorTickSpacing (10);
slider.setPaintTicks (true);
slider.setSnapToTicks(true);
slider.setPaintTrack (false);
slider.setPaintLabels (true);
f.add(slider, BorderLayout.CENTER);
f.setSize (300, 100);
f.setVisible (true);
}
};
EventQueue.invokeLater(runner);
}
}
Binary file added Ch01/SpinnerSample$1.class
Binary file not shown.
Binary file added Ch01/SpinnerSample.class
Binary file not shown.
26 changes: 26 additions & 0 deletions Ch01/SpinnerSample.java
@@ -0,0 +1,26 @@
import java.awt.*;
import javax.swing.*;
import java.text.*;
import java.util.*;

public class SpinnerSample {
public static void main (String args[]) {
Runnable runner = new Runnable() {
public void run() {
JFrame f = new JFrame("JSpinner Sample");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
DateFormatSymbols symbols = new DateFormatSymbols(Locale.FRENCH);
String days[] = symbols.getWeekdays();
SpinnerModel model1 = new SpinnerListModel(days);
SpinnerModel model2 = new SpinnerDateModel();
JSpinner spinner1 = new JSpinner(model1);
JSpinner spinner2 = new JSpinner(model2);
f.add(spinner1, BorderLayout.NORTH);
f.add(spinner2, BorderLayout.SOUTH);
f.setSize (300, 100);
f.setVisible (true);
}
};
EventQueue.invokeLater(runner);
}
}
Binary file added Ch01/SplitSample$1.class
Binary file not shown.
Binary file added Ch01/SplitSample.class
Binary file not shown.
19 changes: 19 additions & 0 deletions Ch01/SplitSample.java
@@ -0,0 +1,19 @@
import java.awt.*;
import javax.swing.*;

public class SplitSample {
public static void main (String args[]) {
Runnable runner = new Runnable() {
public void run() {
JFrame frame = new JFrame("JSplitPane Sample");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JSplitPane splitPane = new JSplitPane();
splitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
frame.add(splitPane, BorderLayout.CENTER);
frame.setSize(300, 200);
frame.setVisible(true);
}
};
EventQueue.invokeLater(runner);
}
}
Binary file added Ch01/SwingTree$1.class
Binary file not shown.
Binary file added Ch01/SwingTree.class
Binary file not shown.

0 comments on commit cb2bf52

Please sign in to comment.