読者です 読者をやめる 読者になる 読者になる

いろいろ備忘録日記

主に .NET 絡みのメモを公開しています。

正規表現チェックツール SOURCE-0003

java swing

入力エリア区画。
2つの入力フィールドを持つパネルです。

// vim: set ts=2 sw=2 et ft=java:
//
// InputAreaBean.java
// 
//
package gsf.tools.regexp.regexptester.bean;

import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.io.Serializable;

import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;

public class InputAreaBean extends JPanel {
  
  private JComponent regInputFields;
  private JComponent targetInputFields;
    
  public InputAreaBean(){
    super();
    
    this.buildContents();
  }
  
  public JComponent getRegInputFields(){
    return this.regInputFields;
  }

  public JComponent getTargetInputFields(){
    return this.targetInputFields;
  }
      
  private void buildContents(){
    super.setLayout(new GridBagLayout());
    
    super.add(this.getRegInputFieldsBean(), this.getRegInputFieldsBeanConstraints());
    super.add(this.getTargetInputFieldsBean(), this.getTargetInputFieldsBeanConstraints());
    
    super.setBorder(this.getMyBorder());  
  }
  
  private JComponent getRegInputFieldsBean(){
    JComponent regInputFields = new RegInputFieldsBean();
    
    this.regInputFields  = regInputFields;
    
    return regInputFields;
  }
  
  private GridBagConstraints getRegInputFieldsBeanConstraints(){
    GridBagConstraints c = new GridBagConstraints();
    
    c.gridx = GridBagConstraints.RELATIVE;
    c.gridy = 0;
    c.fill  = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.insets  = this.getMyInsets();
    
    return c;
  }
  
  private JComponent getTargetInputFieldsBean(){
    JComponent targetInputFields = new TargetInputFieldsBean();
    
    this.targetInputFields = targetInputFields;
    
    return targetInputFields;
  }

  private GridBagConstraints getTargetInputFieldsBeanConstraints(){
    GridBagConstraints c = new GridBagConstraints();
    
    c.gridx = GridBagConstraints.RELATIVE;
    c.gridy = 1;
    c.fill  = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.insets  = this.getMyInsets();
    
    return c;
  }
    
  private Insets getMyInsets(){
    return new Insets(3, 3, 3, 3);
  }
  
  private Border getMyBorder(){
    TitledBorder tb = BorderFactory.createTitledBorder("入力");
    tb.setTitleFont(this.getMyFont());
    
    EmptyBorder  eb = (EmptyBorder) BorderFactory.createEmptyBorder(5, 5, 5, 5);
    
    CompoundBorder cb1 = BorderFactory.createCompoundBorder(eb, tb);
    
    CompoundBorder cb2 = BorderFactory.createCompoundBorder(cb1, eb);
    
    return cb2;
    
  }
  
  private Font getMyFont(){
    return new Font("MS ゴシック", Font.PLAIN, 13);
  }
  
}

================================
過去の記事については、以下のページからご参照下さい。