그래서 특정 글꼴을 표시하려면이 프로젝트를하고 있어요. 문제는 원래 코드가 작동한다는 것입니다하지만 스캐너를 사용하려고하면 그것은하지 않습니다 스캐너자바 글꼴 사용 프로젝트 오류
public static void font2(){
World canvas = new World();//Creates a new world called canvas
Graphics picGraphics = canvas.getGraphics();//creates picGraphics which gets used in the world
picGraphics.setColor(Color.MAGENTA);//Color is set to Magenta
Scanner keyboard=new Scanner(System.in);
String x = keyboard.next();
Font font = new Font(x,Font.BOLD,80);
picGraphics.setFont(font);//sets the font
//drawString parameters tell the string that is written and the coordinates to place the word
picGraphics.drawString("Font Tester",105,255);
canvas.repaint();
}
와 코드 이제 원본 코드
public static void main(String[]args)
{
font("Times New Roman");
}
public static void font(String x){
World canvas = new World();//Creates a new world called canvas
Graphics picGraphics = canvas.getGraphics();//creates picGraphics which gets used in the world
picGraphics.setColor(Color.MAGENTA);//Color is set to Magenta
Font font = new Font(x,Font.BOLD,80);
picGraphics.setFont(font);//sets the font
//drawString parameters tell the string that is written and the coordinates to place the word
picGraphics.drawString("Font Tester",105,255);
canvas.repaint();
}
그 코드에서 볼 수 있듯이 사용자가 직접 표시 할 프로그램에 원하는 글꼴을 입력 할 수 있도록 스캐너가 있습니다. 그러나 새 코드를 Time New Roman과 같은 예제에서 사용할 때마다 창에 표시되는 글꼴은 Times New Roman이 아니지만 Arial과 비슷합니다. 또한 주된 방법으로 스캐너를 사용하려고 시도했습니다. 결과가 다를 수 있습니다.
도움 말 하시겠습니까?
BTW : 많은 사전 설정 코드가 이미 추가되어 World canvas = new World(); 내가
Scanner.next
방법은 Times
이 될 것입니다 귀하의 의견의 첫 번째 단어를 반환 감사
그것은했다! 무리 감사!! – user2070292