23.07.2013 Views

Java IO.pdf - Nguyen Dang Binh

Java IO.pdf - Nguyen Dang Binh

Java IO.pdf - Nguyen Dang Binh

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Java</strong> I/O<br />

ModePanel for it through any of several public get methods. They do not need to concern<br />

themselves with the internal details of the ModePanel GUI.<br />

Example 13.13. ModePanel<br />

import java.awt.*;<br />

import javax.swing.*;<br />

public class ModePanel extends JPanel {<br />

JCheckBox bigEndian = new JCheckBox("Big Endian", true);<br />

JCheckBox deflated = new JCheckBox("Deflated", false);<br />

JCheckBox gzipped = new JCheckBox("GZipped", false);<br />

ButtonGroup dataTypes = new ButtonGroup();<br />

JRadioButton asciiRadio = new JRadioButton("ASCII");<br />

JRadioButton decimalRadio = new JRadioButton("Decimal");<br />

JRadioButton hexRadio = new JRadioButton("Hexadecimal");<br />

JRadioButton shortRadio = new JRadioButton("Short");<br />

JRadioButton intRadio = new JRadioButton("Int");<br />

JRadioButton longRadio = new JRadioButton("Long");<br />

JRadioButton floatRadio = new JRadioButton("Float");<br />

JRadioButton doubleRadio = new JRadioButton("Double");<br />

JTextField password = new JTextField();<br />

public ModePanel() {<br />

}<br />

this.setLayout(new GridLayout(13, 1));<br />

this.add(bigEndian);<br />

this.add(deflated);<br />

this.add(gzipped);<br />

this.add(asciiRadio);<br />

asciiRadio.setSelected(true);<br />

this.add(decimalRadio);<br />

this.add(hexRadio);<br />

this.add(shortRadio);<br />

this.add(intRadio);<br />

this.add(longRadio);<br />

this.add(floatRadio);<br />

this.add(doubleRadio);<br />

dataTypes.add(asciiRadio);<br />

dataTypes.add(decimalRadio);<br />

dataTypes.add(hexRadio);<br />

dataTypes.add(shortRadio);<br />

dataTypes.add(intRadio);<br />

dataTypes.add(longRadio);<br />

dataTypes.add(floatRadio);<br />

dataTypes.add(doubleRadio);<br />

this.add(password);<br />

public boolean isBigEndian() {<br />

return bigEndian.isSelected();<br />

}<br />

public boolean isDeflated() {<br />

334

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!