>>857
width = JOptionPane.showInputDialog("文字数を入力");
を
String width = JOptionPane.showInputDialog("文字数を入力");
とすればOK