Commit f9079eb9 authored by O'Reilly Media, Inc.'s avatar O'Reilly Media, Inc.
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading

9780596009076

0 → 120000
+1 −0
Changes for 9780596009076: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
9780596009076
 No newline at end of file

CHANGELOG

0 → 100644
+24 −0
Changes for CHANGELOG: 24 added lines, 0 removed lines.
Original line number Diff line number Diff line
          Change log for "Swing Hacks" sample code download
          -------------------------------------------------

Jan. 9, 2006:
* Hack 7: Replaced incorrect main() method with the one from the book
* Hack 14: Added missing image
* Hack 16: Added missing images
* Hack 26: Removed superfluous package statement
* Hack 37: Added handling of missing "configuration.props" file (see book
           errata page at http://www.oreilly.com/catalog/swinghks/errata/ )
* Hack 47: Added missing images
* Hack 63: Added missing images
* Hack 64: Added missing images
* Hack 70: Added index.html for convenience (see book for security gotchas
           on running any applet, however)
* Hack 75: Removed superfluous package statements
* Hack 75: Uses a BufferedInputStream for the AudioInputStream to avoid
           "mark/reset not supported" errors on some JVMs (see book
           errata page at http://www.oreilly.com/catalog/swinghks/errata/ )
* Hack 85: Added manifest.txt file
* Hack 99: Removed two-line debug dialog (not in book, but appeared in
           last code example zip)
* Hack 100: Added note that this one-line hack has no sample class
+21 −0
Changes for Ch01-JComponents/01/ImageButton.java: 21 added lines, 0 removed lines.
Original line number Diff line number Diff line
import java.awt.*;
import javax.swing.*;

public class ImageButton extends JButton {

    public ImageButton(String img) {
        this(new ImageIcon(img));
    }

    public ImageButton(ImageIcon icon) {
        setIcon(icon);
        setMargin(new Insets(0,0,0,0));
        setIconTextGap(0);
        setBorderPainted(false);
        setBorder(null);
        setText(null);
        setSize(icon.getImage().getWidth(null),
                icon.getImage().getHeight(null));
    }

}
+21 −0
Changes for Ch01-JComponents/01/ImageLabel.java: 21 added lines, 0 removed lines.
Original line number Diff line number Diff line
import java.awt.*;
import javax.swing.*;

public class ImageLabel extends JLabel {

    public ImageLabel(String img) {
        this(new ImageIcon(img));
    }

    public ImageLabel(ImageIcon icon) {
        setIcon(icon);
        //setMargin(new Insets(0,0,0,0));
        setIconTextGap(0);
        //setBorderPainted(false);
        setBorder(null);
        setText(null);
        setSize(icon.getImage().getWidth(null),
                icon.getImage().getHeight(null));
    }

}
+26 −0
Changes for Ch01-JComponents/01/ImagePanel.java: 26 added lines, 0 removed lines.
Original line number Diff line number Diff line
import java.awt.*;
import javax.swing.*;

public class ImagePanel extends JPanel {
    
    private Image img;

    public ImagePanel(String img) {
        this(new ImageIcon(img).getImage());
    }

    public ImagePanel(Image img) {
        this.img = img;
        Dimension size = new Dimension(img.getWidth(null),img.getHeight(null));
        setPreferredSize(size);
        setMinimumSize(size);
        setMaximumSize(size);
        setSize(size);
        setLayout(null);
    }

    public void paintComponent(Graphics g) {
        g.drawImage(img,0,0,null);
    }

}
Loading