質問するログイン新規登録

質問編集履歴

8

修正

2021/09/11 07:10

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -138,6 +138,9 @@
138
138
  new Sc().setVisible(true);
139
139
  }
140
140
  public Sc(){
141
+ setSize(1450, 900);
142
+ setLocationRelativeTo(null);
143
+ setDefaultCloseOperation(EXIT_ON_CLOSE);
141
144
 
142
145
 
143
146
 

7

修正

2021/09/11 07:10

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -121,9 +121,14 @@
121
121
  frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
122
122
  frame.setVisible(true);
123
123
  }
124
+ public Sc(){
124
-
125
+
125
-
126
+
126
-
127
+
128
+ }
129
+
130
+
131
+
127
132
  }
128
133
  ```
129
134
  修正後
@@ -132,8 +137,13 @@
132
137
  public static void main(String[] args) {
133
138
  new Sc().setVisible(true);
134
139
  }
140
+ public Sc(){
135
-
141
+
136
-
142
+
137
-
143
+
144
+ }
145
+
146
+
147
+
138
148
  }
139
149
  ```

6

追記

2021/09/11 07:06

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -108,4 +108,32 @@
108
108
  #
109
109
  質問を見やすくするために何箇所か省略させていただいておりますが、
110
110
  その関係でプログラムが変になっている箇所がありましたら申し訳ありません。
111
- ご回答よろしくお願い致します。
111
+ ご回答よろしくお願い致します。
112
+
113
+ #追記
114
+ 修正前
115
+ ```
116
+ public class Sc extends JFrame implements ActionListener{
117
+ public static void main(String[] args) {
118
+ Sc frame = new Sc();
119
+ frame.setTitle("画面遷移テスト");
120
+ frame.setSize(1450, 900);
121
+ frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
122
+ frame.setVisible(true);
123
+ }
124
+
125
+
126
+
127
+ }
128
+ ```
129
+ 修正後
130
+ ```
131
+ public class Sc extends JFrame implements ActionListener{
132
+ public static void main(String[] args) {
133
+ new Sc().setVisible(true);
134
+ }
135
+
136
+
137
+
138
+ }
139
+ ```

5

修正

2021/09/11 07:02

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -87,24 +87,23 @@
87
87
  String cmd = e.getActionCommand();
88
88
  CardLayout.show(cardPanel, cmd);
89
89
  }
90
+ class Code implements ActionListener{
91
+ public void actionPerformed(ActionEvent e) {
92
+ Clip clip = null;
93
+ AudioInputStream audioInputStream;
94
+ try{
95
+   //省略
96
+ i++;
97
+ } catch (UnsupportedAudioFileException e1) {
98
+ e1.printStackTrace();
99
+ } catch (LineUnavailableException e1) {
100
+ e1.printStackTrace();
101
+ } catch (IOException e1) {
102
+ e1.printStackTrace();
103
+ }
104
+ }
105
+ }
90
106
  }
91
-
92
- class Code implements ActionListener{
93
- public void actionPerformed(ActionEvent e) {
94
- Clip clip = null;
95
- AudioInputStream audioInputStream;
96
- try{
97
-   //省略
98
- i++;
99
- } catch (UnsupportedAudioFileException e1) {
100
- e1.printStackTrace();
101
- } catch (LineUnavailableException e1) {
102
- e1.printStackTrace();
103
- } catch (IOException e1) {
104
- e1.printStackTrace();
105
- }
106
- }
107
- }
108
107
  ```
109
108
  #
110
109
  質問を見やすくするために何箇所か省略させていただいておりますが、

4

修正

2021/09/11 02:42

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -94,15 +94,7 @@
94
94
  Clip clip = null;
95
95
  AudioInputStream audioInputStream;
96
96
  try{
97
- //コードを鳴らす
97
+   //省略
98
- String cmdName = e.getActionCommand();
99
- File soundFile = new File("/Users/sanpeikazunari/Documents/workspace/即興伴奏能力向上のための学習支援システム/src/code/"+cmdName+".wav");
100
- audioInputStream = AudioSystem.getAudioInputStream(soundFile);
101
- AudioFormat audioFormat = audioInputStream.getFormat();
102
- DataLine.Info info = new DataLine.Info(Clip.class, audioFormat);
103
- clip = (Clip)AudioSystem.getLine(info);
104
- clip.open(audioInputStream);
105
- clip.start();
106
98
  i++;
107
99
  } catch (UnsupportedAudioFileException e1) {
108
100
  e1.printStackTrace();

3

プログラムの修正

2021/09/10 14:02

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -41,9 +41,10 @@
41
41
  // panel02
42
42
  JPanel p2 = new JPanel();
43
43
  p2.setLayout(null);
44
+
44
- JButton btn02 = new JButton("panel02");
45
+      JButton btn02 = new JButton("C"); //iを増やすイベントを持ったボタン
46
+ btn02.addActionListener(new Code());
45
- p2.add(btn02);
47
+ p2.add(btn02)
46
-
47
48
 
48
49
  // panel03
49
50
  JPanel p3 = new JPanel();
@@ -88,8 +89,31 @@
88
89
  }
89
90
  }
90
91
 
92
+ class Code implements ActionListener{
93
+ public void actionPerformed(ActionEvent e) {
94
+ Clip clip = null;
95
+ AudioInputStream audioInputStream;
96
+ try{
97
+ //コードを鳴らす
98
+ String cmdName = e.getActionCommand();
99
+ File soundFile = new File("/Users/sanpeikazunari/Documents/workspace/即興伴奏能力向上のための学習支援システム/src/code/"+cmdName+".wav");
100
+ audioInputStream = AudioSystem.getAudioInputStream(soundFile);
101
+ AudioFormat audioFormat = audioInputStream.getFormat();
102
+ DataLine.Info info = new DataLine.Info(Clip.class, audioFormat);
103
+ clip = (Clip)AudioSystem.getLine(info);
104
+ clip.open(audioInputStream);
105
+ clip.start();
106
+ i++;
107
+ } catch (UnsupportedAudioFileException e1) {
108
+ e1.printStackTrace();
109
+ } catch (LineUnavailableException e1) {
110
+ e1.printStackTrace();
111
+ } catch (IOException e1) {
112
+ e1.printStackTrace();
113
+ }
114
+ }
115
+ }
91
116
  ```
92
-
93
117
  #
94
118
  質問を見やすくするために何箇所か省略させていただいておりますが、
95
119
  その関係でプログラムが変になっている箇所がありましたら申し訳ありません。

2

修正

2021/09/10 14:00

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -86,6 +86,8 @@
86
86
  String cmd = e.getActionCommand();
87
87
  CardLayout.show(cardPanel, cmd);
88
88
  }
89
+ }
90
+
89
91
  ```
90
92
 
91
93
  #

1

書式の改善

2021/09/10 09:06

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -86,4 +86,9 @@
86
86
  String cmd = e.getActionCommand();
87
87
  CardLayout.show(cardPanel, cmd);
88
88
  }
89
- ```
89
+ ```
90
+
91
+ #
92
+ 質問を見やすくするために何箇所か省略させていただいておりますが、
93
+ その関係でプログラムが変になっている箇所がありましたら申し訳ありません。
94
+ ご回答よろしくお願い致します。