마우스 어댑터 클래스를 사용하여 다음과 같은 오류가 발생하면 마우스 클릭 횟수를 가져 오려고합니다.
"AWT-EventQueue-0"스레드의 예외 java.util.FormatFlagsConversionMismatchException : Conversion = c, Flags = java.util.Formatter $ FormatSpecifier.failMismatch (알 수없는 소스) java.util.Formatter $ FormatSpecifier.checkCharacter에서 java.util.Formatter $ FormatSpecifier.checkBadFlags (알 수없는 소스) (알 수없는 소스) 자바에서 에서 에서
. util.Formatter $ FormatSpecifier (알 수없는 소스) at java.util.Formatter.parse (알 수없는 소스) 의 java.util.Formatter.format (알 수없는 소스) java.util.Formatter.format (알 수없는 소스) at java.lang.String.format (알 수없는 소스) at practice2.window12 $ Mouseclass.mouseClicked (window12.java:20) at java.awt.Component.processMouseEvent java.awt.Component의에 java.awt.Window.processEvent (알 소스)에 java.awt.Container.processEvent (알 소스)에 java.awt.Component.processEvent (알 소스)에 (알 소스) java.awt의에 java.awt.Component.dispatchEvent (알 소스)에 java.awt.Window.dispatchEventImpl (알 소스)에 java.awt.Container.dispatchEventImpl (알 소스)에 .dispatchEventImpl (알 소스) .EventQueue.dispatchEventImpl (알 수없는 소스) at java.awt.EventQueue.access $ 200 (알 수없는 소스) at java.awt.EventQueue $ 3.run (알 수없는 소스) at java.awt.EventQueue $ 3.run (알 수없는 소스) at java.security.AccessController. 자바에서 java.awt.EventQueue $의 4.run에서 java.security.ProtectionDomain $ 1.doIntersectionPrivilege에서 java.security.ProtectionDomain $ 1.doIntersectionPrivilege (알 수없는 소스) (알 수없는 소스) (알 수없는 소스) 에서 doPrivileged의 (기본 방법) .awt.EventQueue $ 4.run (알 수없는 소스)at java.security.AccessController.doPrivileged (네이티브 메소드) at java.security.ProtectionDomain $ 1.doIntersectionPrivilege (알 수없는 소스) at java.awt.EventQueue.dispatchEvent (알 수없는 소스)알 java.awt.EventDispatchThread.pumpOneEventForFilters (알 소스)에 java.awt.EventDispatchThread.pumpEvents java.awt.EventDispatchThread.pumpEventsForHierarchy (알 소스)에 java.awt.EventDispatchThread.pumpEventsForFilter (알 소스)에 에서 6,(출처) at java.awt.EventDispatchThread.pumpEvents (알 수없는 소스) at java.awt.EventDispatchThread.실행 (알 수없는 소스)`MouseAdapter 클래스
package practice2;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class window12 extends JFrame{
private String details;
private JLabel statusbar;
public window12(){
super("this will be title");
setVisible(true);
setSize(400,400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
statusbar=new JLabel("this will be defalt");
add(statusbar,BorderLayout.SOUTH);
addMouseListener(new Mouseclass());
}
private class Mouseclass extends MouseAdapter{
public void mouseClicked(MouseEvent event){
details=String.format("you clicked % `enter code here`clicks",event.getClickCount());
if(event.isMetaDown()){
details+=" with right button";
}
else if(event.isAltDown()){
details+=" with center button";
}
else{
details+=" with left button";
}
statusbar.setText(details);
}
}
public static void main(String[] args){
new window12();
}
}
예외가 모든 것을 말한다. 형식 문자열이 잘못되었습니다. 여기에 코드를 입력하세요? –