JTextArea textArea; // 実行結果を表示するJTextArea (中央)
//}}
+ @SuppressWarnings("OverridableMethodCallInConstructor")
public DoDialog(JFrame parentFrame, String[] args) {
super(parentFrame, true); // モーダルダイアログを基盤にする
this.parentFrame = parentFrame;
this.args = args;
// INIT_CONTROLS
+ @SuppressWarnings("OverridableMethodCallInConstructor")
Container container = getContentPane();
container.setLayout(new BorderLayout());
parentFrame.setVisible(false);
super.addNotify();
- if (fComponentsAdjusted)
+ if (fComponentsAdjusted) {
return;
+ }
// Adjust components according to the insets
setSize(getInsets().left + getInsets().right + d.width, getInsets().top + getInsets().bottom + d.height);
* JTextAreaに書き出すOutputStream
*/
public static class JTextAreaOutputStream extends OutputStream {
- private ByteArrayOutputStream os;
+ private final ByteArrayOutputStream os;
/** 書き出し対象 */
- private JTextArea textArea;
- private String encode;
+ private final JTextArea textArea;
+ private final String encode;
public JTextAreaOutputStream(JTextArea textArea, String encode) {
this.textArea = textArea;
/**
* OutputStream#write(byte[])のオーバーライド
* @param arg
+ * @throws java.io.IOException
*/
@Override
public void write(int arg) throws IOException {
/**
* flush()でJTextAreaに書き出す
+ * @throws java.io.IOException
*/
@Override
public void flush() throws IOException {
// 文字列のエンコード
final String str = new String(this.os.toByteArray(), this.encode);
// 実際の書き出し処理
- SwingUtilities.invokeLater(new Runnable(){
- @Override
- public void run() {
- JTextAreaOutputStream.this.textArea.append(str);
+ SwingUtilities.invokeLater(
+ new Runnable(){
+ @Override
+ public void run() {
+ JTextAreaOutputStream.this.textArea.append(str);
+ }
}
- });
+ );
// 書き出した内容はクリアする
this.os.reset();
}
// 非同期に行う処理を記述するためのクラス
class LongTaskWorker extends SwingWorker<Object, Object> {
- private JButton button;
+ private final JButton button;
public LongTaskWorker(JButton button) {
this.button = button;
// 非同期に行われる処理
@Override
+ @SuppressWarnings("SleepWhileInLoop")
public Object doInBackground() {
// ながーい処理
PrintStream defOut = System.out;