回答編集履歴
1
追記(変更最小)
answer
CHANGED
@@ -113,4 +113,141 @@
|
|
113
113
|
|
114
114
|
|
115
115
|
日付を選択し指定日のメモ等が新たにウィンドウを出すということだと思いますが、SelectDateは閉じちゃっていいんでしょうか?
|
116
|
-
戻れなくなってしまいそうですが。
|
116
|
+
戻れなくなってしまいそうですが。
|
117
|
+
|
118
|
+
---
|
119
|
+
|
120
|
+
追記(変更最小)
|
121
|
+
|
122
|
+
```Java
|
123
|
+
import java.awt.Component;
|
124
|
+
import java.awt.EventQueue;
|
125
|
+
import java.awt.Window;
|
126
|
+
import java.awt.event.ActionEvent;
|
127
|
+
import java.awt.event.ActionListener;
|
128
|
+
import javax.swing.JButton;
|
129
|
+
import javax.swing.JFrame;
|
130
|
+
import javax.swing.JLabel;
|
131
|
+
import javax.swing.JPanel;
|
132
|
+
import javax.swing.JTextField;
|
133
|
+
import javax.swing.SwingConstants;
|
134
|
+
import javax.swing.SwingUtilities;
|
135
|
+
import javax.swing.border.EmptyBorder;
|
136
|
+
|
137
|
+
public class SelectDate extends JFrame {
|
138
|
+
|
139
|
+
private JPanel contentPane;
|
140
|
+
private JTextField txtDate;
|
141
|
+
|
142
|
+
/**
|
143
|
+
* Launch the application.
|
144
|
+
*/
|
145
|
+
public static void main(String[] args) {
|
146
|
+
EventQueue.invokeLater(new Runnable() {
|
147
|
+
public void run() {
|
148
|
+
try {
|
149
|
+
SelectDate frame = new SelectDate();
|
150
|
+
frame.setVisible(true);
|
151
|
+
} catch (Exception e) {
|
152
|
+
e.printStackTrace();
|
153
|
+
}
|
154
|
+
}
|
155
|
+
});
|
156
|
+
}
|
157
|
+
|
158
|
+
/**
|
159
|
+
* Create the frame.
|
160
|
+
*/
|
161
|
+
public SelectDate() {
|
162
|
+
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
163
|
+
setBounds(500, 250, 450, 300);
|
164
|
+
contentPane = new JPanel();
|
165
|
+
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
166
|
+
setContentPane(contentPane);
|
167
|
+
contentPane.setLayout(null);
|
168
|
+
|
169
|
+
JLabel lblDate = new JLabel("日付を選択", SwingConstants.RIGHT);
|
170
|
+
lblDate.setBounds(118, 65, 98, 32);
|
171
|
+
contentPane.add(lblDate);
|
172
|
+
|
173
|
+
txtDate = new JTextField();
|
174
|
+
txtDate.setBounds(236, 68, 130, 26);
|
175
|
+
contentPane.add(txtDate);
|
176
|
+
txtDate.setColumns(10);
|
177
|
+
//txtDateの値を取り出す
|
178
|
+
String txtdata = txtDate.getText();
|
179
|
+
|
180
|
+
JButton btnSearch = new JButton("検索");
|
181
|
+
btnSearch.setBounds(236, 120, 117, 29);
|
182
|
+
contentPane.add(btnSearch);
|
183
|
+
|
184
|
+
//ボタン押下時(past)
|
185
|
+
btnSearch.addActionListener(new ActionListener() {
|
186
|
+
public void actionPerformed(ActionEvent e) {
|
187
|
+
String txtdata = txtDate.getText();
|
188
|
+
SeePast frame = new SeePast(txtdata);
|
189
|
+
frame.setVisible(true);
|
190
|
+
//ウィンドウを閉じる
|
191
|
+
Component c = (Component) e.getSource();
|
192
|
+
Window w = SwingUtilities.getWindowAncestor(c);
|
193
|
+
w.dispose();
|
194
|
+
}
|
195
|
+
|
196
|
+
});
|
197
|
+
}
|
198
|
+
}
|
199
|
+
|
200
|
+
class SeePast extends JFrame {
|
201
|
+
|
202
|
+
private JPanel contentPane;
|
203
|
+
|
204
|
+
/**
|
205
|
+
* Launch the application.
|
206
|
+
*/
|
207
|
+
public static void main(String[] args) {
|
208
|
+
EventQueue.invokeLater(new Runnable() {
|
209
|
+
public void run() {
|
210
|
+
try {
|
211
|
+
SeePast frame = new SeePast("aaa");
|
212
|
+
frame.setVisible(true);
|
213
|
+
} catch (Exception e) {
|
214
|
+
e.printStackTrace();
|
215
|
+
}
|
216
|
+
}
|
217
|
+
});
|
218
|
+
}
|
219
|
+
|
220
|
+
/**
|
221
|
+
* Create the frame.
|
222
|
+
*/
|
223
|
+
public SeePast(String str) {
|
224
|
+
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
225
|
+
setBounds(500, 250, 450, 300);
|
226
|
+
contentPane = new JPanel();
|
227
|
+
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
228
|
+
setContentPane(contentPane);
|
229
|
+
contentPane.setLayout(null);
|
230
|
+
|
231
|
+
String lbl = str;
|
232
|
+
JLabel lblSelectDate = new JLabel(lbl);
|
233
|
+
lblSelectDate.setBounds(60, 35, 61, 16);
|
234
|
+
contentPane.add(lblSelectDate);
|
235
|
+
|
236
|
+
JLabel lblContents = new JLabel("学習内容", SwingConstants.RIGHT);
|
237
|
+
lblContents.setBounds(60, 99, 61, 16);
|
238
|
+
contentPane.add(lblContents);
|
239
|
+
|
240
|
+
JLabel lblFeel = new JLabel("感想", SwingConstants.RIGHT);
|
241
|
+
lblFeel.setBounds(60, 147, 61, 16);
|
242
|
+
contentPane.add(lblFeel);
|
243
|
+
|
244
|
+
JLabel lbljava = new JLabel("(例)Java");
|
245
|
+
lbljava.setBounds(182, 99, 119, 16);
|
246
|
+
contentPane.add(lbljava);
|
247
|
+
|
248
|
+
JLabel lblUnderstand = new JLabel("(例)理解できた");
|
249
|
+
lblUnderstand.setBounds(182, 147, 150, 16);
|
250
|
+
contentPane.add(lblUnderstand);
|
251
|
+
}
|
252
|
+
}
|
253
|
+
```
|