0

I made a GUI using Jframe so I just added the textarea using the editor. And I want it to display a text that gets updated based on a changing int amount.

The GUI editor places a bunch of

private void scoreInputMethodTextChanged(java.awt.event.InputMethodEvent evt)

for every GUI element, so dont know how to set and/or refresh the displayed text. If you need a sample of my code just say so, Thanks!

Magiichalo
  • 31
  • 5

2 Answers2

1

Just add an actionlistener to whatever you want to trigger the change

then in your actionlistener, get value of your int field and set the text to what you want

If your int is inside a textfield, you can try how add a listener for jtexfield when it changing?

Community
  • 1
  • 1
Xavjer
  • 8,838
  • 2
  • 22
  • 42
0

My take is that just add an event to a swing component such as a Jbutton. The event should be an actionlistener that will get the value from the int amount and then display the text to the JTextArea whenever the int amount changes. To achieve this you will need to research on the following: Adding events to Swing components and also the types of decision making statements in Java which you may use especially for the changing int amounts.

Ford
  • 1
  • 2