| import javax.swing.SwingUtilities;
import javax.swing.SwingConstants; // 定数用に追加
import java.util.Date; // 当日日付取得用に追加
import javax.swing.JPanel;
import javax.swing.JFrame;
import jp.co.flatsoft.fscomponent.FSCalenderCombo;
import java.awt.Rectangle;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JLabel;
public class TestFrame extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private FSCalenderCombo FSCalenderCombo1 = null;
private JTextField jTextField = null;
private JButton jButton = null;
private JLabel jLabel = null;
private static String myLabel = "<HTML>" +
"左右矢印で年・月・日を移動<br>" +
"上下矢印で、値変更<br>" +
"F4でカレンダーを開く<br>" +
"再びF4でカレンダーを閉じる<br>" +
"ESCでもカレンダーを閉じる<br>" +
"<br>" +
"カレンダー内で矢印で日付移動<br>" +
"</HTML>"; // @jve:decl-index=0:
/**
* This method initializes FSCalenderCombo
*
* @return jp.co.flatsoft.fscomponent.FSCalenderCombo
*/
private FSCalenderCombo getFSCalenderCombo() {
if (FSCalenderCombo1 == null) {
FSCalenderCombo1 = new FSCalenderCombo();
FSCalenderCombo1.setBounds(new Rectangle(25, 27, 144, 28));
FSCalenderCombo1.setDate(new Date());
}
return FSCalenderCombo1;
}
/**
* This method initializes jTextField
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField() {
if (jTextField == null) {
jTextField = new JTextField();
jTextField.setBounds(new Rectangle(230, 78, 144, 25));
}
return jTextField;
}
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setBounds(new Rectangle(230, 27, 142, 26));
jButton.setFont(new Font("MS Pゴシック", Font.BOLD, 12));
jButton.setText("↓文字列に変換");
jButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
jTextField.setText(
FSCalenderCombo.formatDate(
FSCalenderCombo1.getDate(),"/"
)
);
System.out.println(
FSCalenderCombo.formatDate(
FSCalenderCombo1.getDate(),"/"
)
);
}
});
}
return jButton;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
SwingUtilities.invokeLater(new Runnable() {
public void run() {
TestFrame thisClass = new TestFrame();
thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
thisClass.setVisible(true);
}
});
}
/**
* This is the default constructor
*/
public TestFrame() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(432, 262);
this.setContentPane(getJContentPane());
this.setTitle("FSCalenderCombo のテスト"); // タイトル変更
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabel = new JLabel();
jLabel.setBounds(new Rectangle(23, 75, 174, 129));
jLabel.setFont(new Font("MS Pゴシック", 0, 12));
jLabel.setText(myLabel);
jLabel.setVerticalAlignment(SwingConstants.TOP);
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getFSCalenderCombo(), null);
jContentPane.add(getJTextField(), null);
jContentPane.add(getJButton(), null);
jContentPane.add(jLabel, null);
}
return jContentPane;
}
} // @jve:decl-index=0:visual-constraint="10,10"
| |