0
Ok 그래서 여기에 내 프로그램이 있지만 작동하지만 다음 줄로 이동하는 데 문제가 있습니다. 대신 길어지면 화면에서 사라집니다.바이너리 프로그램에 텍스트에 대한 새 줄 만들기
import javax.swing.*;
public class TextToBinary{
public static void main(String[] args) {
String y;
JOptionPane.showMessageDialog(null, "Welcome to the Binary Canary.","Binary Canary", JOptionPane.PLAIN_MESSAGE);
y = JOptionPane.showInputDialog(null,"Write the word to be converted to binary: ","Binary Canary", JOptionPane.PLAIN_MESSAGE);
String s = y;
byte[] bytes = s.getBytes();
StringBuilder binary = new StringBuilder();
for (byte b : bytes)
{
int val = b;
for (int i = 0; i < 8; i++)
{
binary.append((val & 128) == 0 ? 0 : 1);
val <<= 1;
}
binary.append(' ');
}
JOptionPane.showMessageDialog(null, "'" + s + "' to binary: " +"\n" +binary,"Binary Canary", JOptionPane.PLAIN_MESSAGE);
}
}
System.getProperty ("line.separator"); –
여기 좀보세요 http://stackoverflow.com/questions/7696347/to-break-a-message-in-two-or-more-lines-in-joptionpane –