当前位置: 技术问答>java相关
为什么会产生这样的错误呢?
来源: 互联网 发布时间:2015-03-28
本文导语: E:ShareJustApps_source_updatedJustApps_source_updated>javac justapps.java .MCGameScheduler.java:225: cannot resolve symbol symbol : method setVisible (boolean) location: class MCGame.Scheduler this.setVisible(false); ^ 1 error 已经设置好cla...
E:ShareJustApps_source_updatedJustApps_source_updated>javac justapps.java
.MCGameScheduler.java:225: cannot resolve symbol
symbol : method setVisible (boolean)
location: class MCGame.Scheduler
this.setVisible(false);
^
1 error
已经设置好classpath。
scheduler.java的代码如下:
package MCGame;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.filechooser.FileFilter;
import java.io.*;
import java.util.*;
import Common.*;
public class Scheduler implements ActionListener {
private JButton LoadButton;
private JButton playButton;
private JButton goback;
private JButton gonext;
private JButton realtimeplayButton;
private JButton realtimestopButton;
private JButton realtimesaveButton;
private JButton realtimereturntonewpieceButton;
private JButton realtimequitjustappsButton;
private JButton realtimejustappsButton;
private File filename1;
private File fileget;
private Interface interfaceframe;
private ComposingDialog dialog;
private RealTimeFrame realtime;
private ComposerSignaller signal;
public Scheduler(ComposerSignaller signaller) {
signal = signaller;
interfaceframe = new Interface(signal);
//Load Button
LoadButton = new JButton("Load");
interfaceframe.getControlPanel().add(LoadButton);
LoadButton.addActionListener(this);
playButton = new JButton("COMPOSE NOW");
interfaceframe.getControlPanel().add(playButton);
playButton.addActionListener(this);
interfaceframe.show();
}
public void actionPerformed(ActionEvent evt) {
Object source = evt.getSource();
if (source == playButton) {
System.out.println("playButton action performed");
interfaceframe.setVisible(false);
// if (dialog == null){ // first time
dialog = new ComposingDialog(interfaceframe);
goback = new JButton("Back");
gonext = new JButton("Next");
goback.addActionListener(this);
gonext.addActionListener(this);
dialog.getControlPanel().add(goback);
dialog.getControlPanel().add(gonext);
System.out.println("new dialog");
// }
dialog.start();
// Pong added
dialog.startCompose(); // From Pong: modify the Composer constructor to pass voices/instruments information to the composer
System.out.println("playButton action performedaa");
}
else if (source == LoadButton){
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new File("."));
chooser.setFileFilter(new FileFilter() {
public boolean accept(File f) {
return f.getName().toLowerCase()
.endsWith(".mcg")
|| f.isDirectory();
}
public String getDescription() {
return "Musical Composing Game Score Files";
}
});
int r = chooser.showOpenDialog(interfaceframe);
if ( r == JFileChooser.APPROVE_OPTION ) {
fileget = chooser.getSelectedFile();
System.out.println("file = "+fileget);
Score score;
try {
ObjectInputStream in = new ObjectInputStream(new FileInputStream(fileget));
score = (Score) in.readObject();
interfaceframe.setVisible(false);
gotoRealTimePage(score);
} catch (IOException e2) {
System.out.println("get file IOException: " + e2);
} catch (ClassNotFoundException e3) {
System.out.println("get file ClassNotFoundExcepetion " + e3);
}
} else if ( r == JFileChooser.CANCEL_OPTION) {
System.out.println("Cancelled");
}
/*
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new File("."));
chooser.setFileFilter(new FileFilter()
{ public boolean accept(File f)
{ return f.getName().toLowerCase()
.endsWith(".txt") // From Pong: Make it quick!
|| f.isDirectory();
}
public String getDescription()
{ return "Txt Files"; }
});
int r = chooser.showOpenDialog(interfaceframe);
if (r == JFileChooser.APPROVE_OPTION)
{ // filename = chooser.getSelectedFile().getPath();
//scanZipFile();
fileget = chooser.getSelectedFile();
}
System.out.println(fileget);
*/
}
else if (source == goback){ //Back to Input Stage
dialog.dispose();
interfaceframe.setVisible(true);
//Composer.scoreOne.clearAll();
//Composer.scoreOne = new Score(256, 120,4,1,2,0);
//System.out.println("Composer, num_sentence=" + Composer.scoreOne.voiceList[0].getNumSentence());
// ShowInput();
}
else if (source == gonext){ //Go to Real Time Page
dialog.dispose();
gotoRealTimePage(dialog.getScore());
}
else if (source == realtimeplayButton){
System.out.println("Play Now");
realtimeplayButton.setEnabled(false);
//dialog.getScore().reset(); // reset the score from dialog
realtime.getScore().reset();
realtime.playScore();
}
else if (source == realtimestopButton){
System.out.println("Reset");
realtimeplayButton.setEnabled(true);
realtime.stopAudio();
//dialog.getScore().reset(); // reset the score from dialog
realtime.getScore().reset();
realtime.initAudio(); // init audio after playing the score
realtime.resetSetting(); // restore interface setting
// reset realtimepage setting?
}
else if (source == realtimesaveButton){
//System.out.println("Save");
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new File("."));
chooser.setFileFilter(new FileFilter() {
public boolean accept(File f) {
return f.getName().toLowerCase().endsWith(".mcg") || f.isDirectory();
}
public String getDescription() {
return "Musical Composing Game Score Files";
}
});
int r = chooser.showSaveDialog(realtime);
if (r == JFileChooser.APPROVE_OPTION) {
filename1 = chooser.getSelectedFile();
//System.out.println(filename1);
try {
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(filename1));
out.writeObject(dialog.getScore());
out.close();
} catch (IOException e) {
System.out.println("IOExceptionO " + e);
}
}
}
else if (source == realtimequitjustappsButton){
System.exit(0);
}
else if (source == realtimejustappsButton){
this.setVisible(false);
}
else if (source == realtimereturntonewpieceButton){
}
}
private void gotoRealTimePage(Score iscore) {
realtime = new RealTimeFrame( iscore,getInstrList(),interfaceframe.getMajorMinor() );
realtimeplayButton = new JButton(" Play ");
realtimeplayButton.addActionListener(this);
realtime.getControlPanel().add(realtimeplayButton);
realtimestopButton = new JButton(" Reset ");
realtimestopButton.addActionListener(this);
realtime.getControlPanel().add(realtimestopButton);
realtimesaveButton = new JButton(" Save ");
realtimesaveButton.addActionListener(this);
realtime.getControlPanel().add(realtimesaveButton);
realtimereturntonewpieceButton = new JButton(" Return to New Piece ");
realtimereturntonewpieceButton.addActionListener(this);
realtime.getControlPanel().add(realtimereturntonewpieceButton);
realtimequitjustappsButton = new JButton(" Quit JustApps ");
realtimequitjustappsButton.addActionListener(this);
realtime.getControlPanel().add(realtimequitjustappsButton);
realtimejustappsButton = new JButton(" JustApps ");
realtimejustappsButton.addActionListener(this);
realtime.getControlPanel().add(realtimejustappsButton);
realtime.start();
try {
Thread.sleep(500);
} catch (InterruptedException e) {
}
getInterfaceParamToRealFrame();
realtime.initAudio(); // init audio after playing the score
realtime.resetSetting(); // restore interface setting
}
private void getInterfaceParamToDialog() { // Transition from Interface to Dialog
}
private void getInterfaceParamToRealFrame() { // Transition from Dialog to RealTime
// get from interfaceframe
int SF = interfaceframe.getSampling();
int BPS = interfaceframe.getBitperSample();
int NCh = interfaceframe.getChannel();
int AuQ = interfaceframe.getAudioQuality();
// set to RealTimeFrame
realtime.setAudio(SF, BPS, NCh, AuQ);
}
public InstrList getInstrList() {
return interfaceframe.getInstrList();
}
}
.MCGameScheduler.java:225: cannot resolve symbol
symbol : method setVisible (boolean)
location: class MCGame.Scheduler
this.setVisible(false);
^
1 error
已经设置好classpath。
scheduler.java的代码如下:
package MCGame;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.filechooser.FileFilter;
import java.io.*;
import java.util.*;
import Common.*;
public class Scheduler implements ActionListener {
private JButton LoadButton;
private JButton playButton;
private JButton goback;
private JButton gonext;
private JButton realtimeplayButton;
private JButton realtimestopButton;
private JButton realtimesaveButton;
private JButton realtimereturntonewpieceButton;
private JButton realtimequitjustappsButton;
private JButton realtimejustappsButton;
private File filename1;
private File fileget;
private Interface interfaceframe;
private ComposingDialog dialog;
private RealTimeFrame realtime;
private ComposerSignaller signal;
public Scheduler(ComposerSignaller signaller) {
signal = signaller;
interfaceframe = new Interface(signal);
//Load Button
LoadButton = new JButton("Load");
interfaceframe.getControlPanel().add(LoadButton);
LoadButton.addActionListener(this);
playButton = new JButton("COMPOSE NOW");
interfaceframe.getControlPanel().add(playButton);
playButton.addActionListener(this);
interfaceframe.show();
}
public void actionPerformed(ActionEvent evt) {
Object source = evt.getSource();
if (source == playButton) {
System.out.println("playButton action performed");
interfaceframe.setVisible(false);
// if (dialog == null){ // first time
dialog = new ComposingDialog(interfaceframe);
goback = new JButton("Back");
gonext = new JButton("Next");
goback.addActionListener(this);
gonext.addActionListener(this);
dialog.getControlPanel().add(goback);
dialog.getControlPanel().add(gonext);
System.out.println("new dialog");
// }
dialog.start();
// Pong added
dialog.startCompose(); // From Pong: modify the Composer constructor to pass voices/instruments information to the composer
System.out.println("playButton action performedaa");
}
else if (source == LoadButton){
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new File("."));
chooser.setFileFilter(new FileFilter() {
public boolean accept(File f) {
return f.getName().toLowerCase()
.endsWith(".mcg")
|| f.isDirectory();
}
public String getDescription() {
return "Musical Composing Game Score Files";
}
});
int r = chooser.showOpenDialog(interfaceframe);
if ( r == JFileChooser.APPROVE_OPTION ) {
fileget = chooser.getSelectedFile();
System.out.println("file = "+fileget);
Score score;
try {
ObjectInputStream in = new ObjectInputStream(new FileInputStream(fileget));
score = (Score) in.readObject();
interfaceframe.setVisible(false);
gotoRealTimePage(score);
} catch (IOException e2) {
System.out.println("get file IOException: " + e2);
} catch (ClassNotFoundException e3) {
System.out.println("get file ClassNotFoundExcepetion " + e3);
}
} else if ( r == JFileChooser.CANCEL_OPTION) {
System.out.println("Cancelled");
}
/*
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new File("."));
chooser.setFileFilter(new FileFilter()
{ public boolean accept(File f)
{ return f.getName().toLowerCase()
.endsWith(".txt") // From Pong: Make it quick!
|| f.isDirectory();
}
public String getDescription()
{ return "Txt Files"; }
});
int r = chooser.showOpenDialog(interfaceframe);
if (r == JFileChooser.APPROVE_OPTION)
{ // filename = chooser.getSelectedFile().getPath();
//scanZipFile();
fileget = chooser.getSelectedFile();
}
System.out.println(fileget);
*/
}
else if (source == goback){ //Back to Input Stage
dialog.dispose();
interfaceframe.setVisible(true);
//Composer.scoreOne.clearAll();
//Composer.scoreOne = new Score(256, 120,4,1,2,0);
//System.out.println("Composer, num_sentence=" + Composer.scoreOne.voiceList[0].getNumSentence());
// ShowInput();
}
else if (source == gonext){ //Go to Real Time Page
dialog.dispose();
gotoRealTimePage(dialog.getScore());
}
else if (source == realtimeplayButton){
System.out.println("Play Now");
realtimeplayButton.setEnabled(false);
//dialog.getScore().reset(); // reset the score from dialog
realtime.getScore().reset();
realtime.playScore();
}
else if (source == realtimestopButton){
System.out.println("Reset");
realtimeplayButton.setEnabled(true);
realtime.stopAudio();
//dialog.getScore().reset(); // reset the score from dialog
realtime.getScore().reset();
realtime.initAudio(); // init audio after playing the score
realtime.resetSetting(); // restore interface setting
// reset realtimepage setting?
}
else if (source == realtimesaveButton){
//System.out.println("Save");
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new File("."));
chooser.setFileFilter(new FileFilter() {
public boolean accept(File f) {
return f.getName().toLowerCase().endsWith(".mcg") || f.isDirectory();
}
public String getDescription() {
return "Musical Composing Game Score Files";
}
});
int r = chooser.showSaveDialog(realtime);
if (r == JFileChooser.APPROVE_OPTION) {
filename1 = chooser.getSelectedFile();
//System.out.println(filename1);
try {
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(filename1));
out.writeObject(dialog.getScore());
out.close();
} catch (IOException e) {
System.out.println("IOExceptionO " + e);
}
}
}
else if (source == realtimequitjustappsButton){
System.exit(0);
}
else if (source == realtimejustappsButton){
this.setVisible(false);
}
else if (source == realtimereturntonewpieceButton){
}
}
private void gotoRealTimePage(Score iscore) {
realtime = new RealTimeFrame( iscore,getInstrList(),interfaceframe.getMajorMinor() );
realtimeplayButton = new JButton(" Play ");
realtimeplayButton.addActionListener(this);
realtime.getControlPanel().add(realtimeplayButton);
realtimestopButton = new JButton(" Reset ");
realtimestopButton.addActionListener(this);
realtime.getControlPanel().add(realtimestopButton);
realtimesaveButton = new JButton(" Save ");
realtimesaveButton.addActionListener(this);
realtime.getControlPanel().add(realtimesaveButton);
realtimereturntonewpieceButton = new JButton(" Return to New Piece ");
realtimereturntonewpieceButton.addActionListener(this);
realtime.getControlPanel().add(realtimereturntonewpieceButton);
realtimequitjustappsButton = new JButton(" Quit JustApps ");
realtimequitjustappsButton.addActionListener(this);
realtime.getControlPanel().add(realtimequitjustappsButton);
realtimejustappsButton = new JButton(" JustApps ");
realtimejustappsButton.addActionListener(this);
realtime.getControlPanel().add(realtimejustappsButton);
realtime.start();
try {
Thread.sleep(500);
} catch (InterruptedException e) {
}
getInterfaceParamToRealFrame();
realtime.initAudio(); // init audio after playing the score
realtime.resetSetting(); // restore interface setting
}
private void getInterfaceParamToDialog() { // Transition from Interface to Dialog
}
private void getInterfaceParamToRealFrame() { // Transition from Dialog to RealTime
// get from interfaceframe
int SF = interfaceframe.getSampling();
int BPS = interfaceframe.getBitperSample();
int NCh = interfaceframe.getChannel();
int AuQ = interfaceframe.getAudioQuality();
// set to RealTimeFrame
realtime.setAudio(SF, BPS, NCh, AuQ);
}
public InstrList getInstrList() {
return interfaceframe.getInstrList();
}
}
|
this.setVisible(false);
改成
interfaceframe.setVisible(false);
看看
。。。
Scheduler类没有setVisible方法
改成
interfaceframe.setVisible(false);
看看
。。。
Scheduler类没有setVisible方法
|
realtimejustappsButton.setVisible(false);