퀴즈 응용 프로그램 만들기. 그리고 팀이 버튼을 밀면 여전히 질문을 보거나 비디오/오디오 부분을 볼 수 없습니다. 이러한 종류의 정보는 부모 JFrame에 추가 된 퀴즈 뷰 (jpanel)에 표시됩니다. 내가 뭘하려는 건 팀에서 버튼을 밀 때 JFrame을 최소화하는 것입니다. 이것은 완벽하게 작동합니다. 버튼을 누르면 관리자가 자신의 견해에서 팝업을 얻습니다. 대답이 틀리면 JFrame을 다시 최대화해야합니다. 따라서 답이 틀린 경우 버튼을 누르면 부울이 퀴즈 모델에서 true로 설정됩니다 ($ 최대화). 우리는 그때의 견해를 업데이트합니다. 뷰의 업데이트에서 boolean이 true로 설정되었는지 확인합니다. 그것이 사실이라면 maximize 메서드를 호출합니다. 대답이 잘못되었을 때 다시 최대화하십시오. 최소화는 완벽하게 작동하지만 최대화는하지 않습니다.부모 JFrame 최소화/최대화
누구든지 무엇이 잘못되었는지 알고 계십니까?
이보기에 내 코드,보기가 극대화 일이 더 큰 JFrame의,에 JPanel의이다 : 팀이 자신의 버튼을 누르면 때 최소화가 발생
public void update(Observable arg0, Object arg1) {
$question = (Question) arg1;
if(((QuizModel) getModel()).getMaximize()) /* Only maximize the JFrame when needed */
maximizeFrame(); /* Maximize the frame first */
repaint();
}
/**
* Maximize the parent JFrame so the teams can see the question
*/
protected void maximizeFrame() {
System.out.println("MAXIMIZE");
JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this);
topFrame.setState(JFrame.MAXIMIZED_BOTH);
}
는, 여기에 코드입니다 :
/**
* If a button gets pressed we call this function
* @param team the team that pressed their button
*/
protected void buttonPressed(int team) {
/* Check if a button is pressed */
if(((QuizModel) getModel()).getTeamPressed() > 0)
$isPressed = true;
else
$isPressed = false;
/* If there hasn't been pressed yet and the question is not null */
if(!$isPressed && $question != null){
minimizeFrame(); /* Minimize the frame */
/* If this question has a media path we need to pause the audio/video, we also check if the user has installed vlcplayer and selected the right path */
if($question.getMediaPath() != null && QuizSoftwareModel.$vlcPath != null)
((QuizController)getController()).pause(); /* Pause the video */
/* Give a pop up message to the admin that a team has pushed their button */
((QuizController)getController()).showScoreView(team);
}
}
/**
* Minimize the parent JFrame so the teams can't see the question anymore
*/
protected void minimizeFrame() {
JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this);
topFrame.setState(JFrame.ICONIFIED);
}
[EDIT] 코드가 줄었습니다.
감사합니다.
이 정보가 도움이됩니까? http://stackoverflow.com/questions/5258207/how-to-maximize-a-jframe-through-code –
지금은 SSCCE/MCVE를 게시 할 시간이 아니십니까 – mKorbel
이것은 PHP가 아니므로 사용하지 마십시오. 변수 이름에'$ '. – user1803551