1
계산기를 만들려고하고 있는데 JTextField에 문제가 있습니다. 1,2,3,4,5와 같은 숫자 (JButtons)를 클릭하면 54321과 같은 JTextField에 나타납니다. 따라서 어떻게 54321 대신 12345를 표시 할 수 있습니까? 당신이 질문을하기 전에 당신은 정말 이것에 대해JTextField 번호가 왼쪽에서 오른쪽
public void actionPerformed(ActionEvent e) {
JButton clickedButton = (JButton) e.getSource();
String displayValue = parent.getDisplayValue();
String clickedBtnValue = clickedButton.getText();
parent.setDisplayValue(clickedBtnValue + displayValue);
contentPane = new JPanel();
textField = new JTextField(30);
textField.setAlignmentX(Component.LEFT_ALIGNMENT);
contentPane.add(textField);
textField.setHorizontalAlignment(JTextField.RIGHT);
textField.setBounds(10, 11, 152, 32);
textField.setColumns(1);
textField.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
textField.addActionListener(eng);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 184, 312);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
@Sinclair, 네, 그건 오타였습니다. – camickr
오. 나는 한달 동안 초보자이기 때문에 내가 물어보기 전에 3 일 동안 고생했다. 대답 해줘서 고마워! :) –