我一直在将我为c#所做的项目转换为java,而我在实现最后一部分时遇到了麻烦。该项目是一个梦幻般的足球跟踪器,问题在于让用户进入并更改活跃的名单和主要名单。
到目前为止,对其中任何一个进行更改都没有问题,或者问题是我想要组合功能,以便当他们完成一个名单时,他们可以根据需要对其他名单进行更改。
奇怪的是,我让它以一种方式工作,以便用户可以更改那里的活动名单,然后切换到那里没有问题的主名单;但是它不起作用的另一种方式用户可以更改主名单。
当他们说他们想要更改其他名单时,setVisible不会对包含用户主名单的JList起作用。
//This is the method that sets up the users active roster
public void activeRosterLook()
{
//scroll holds the users master roster
// this is the issue it will work in one instance but not the other
// so when this method is called the first time it works
// but when it is called a second time or called after
//the user changes the master roster
// it decides not to become invisible
scroll.setVisible(false);
//bar holds the users active roster
bar.setVisible(true);
// master is a button that when clicked starts the master roster change
master.setVisible(false);
//actuve is a button that when clicked starts the active roster change
active.setVisible(false);
// prompt is a label that gives directions on the frame
prompt.setVisible(false);
}
// this if checks to see that the Done button which triggers this change is clicked
if(Done.equals(e.getSource()))
{
// this if makes sure the master button was clicked
if(ismaster)
{
// changing the booleans up so that my frame runs properly
isactive = true;
ismaster = false;
// this if makes sure that the active roster is not empty
// I have this here because when they go change the active roster it
// fills both rosters and when they go change the master it only fills the master
// roster
if(activePlayers[0] == null)
{
try
{
this method accesses the file that has the active roster data
loadActiveRoster();
}
catch(IOException ioe)
{
//This catch will never run the way I have the files set up
}
}
// this method is called the issue is with the actual look method
activeRosterLook();
}
// this runs when active is clicked
if(isactive)
{
// doing the same thing swapping the booleans
ismaster = true
isactive = false
// and this method will change the frame to the master roster changes
// the only difference is that this method works and the changes occure
masterRosterLook();
}
}
else
{
// this also works if the user does not want to change anything else sends
// them back to the hub or the form that launches these frames
StartUpForm hub = new StartUpForm(true);
dispose();
}
}
我想知道是否有人会想到为什么setVisible会在一个上工作 jList而不是其他?也就是为什么setVisible将在这个特定的名册中工作 一种情况而不是另一种情况?