Don't know if it's stupid or reasonable question.

I have methods which returns float/int data (x,y,z positions) of the P5 Glove (if you know it).

I also have update method which responds to the glove pulling.

All i'm having trouble with is creating UI and presenting the data in text area, means every update the text areas presenting the data refreshed and present the data.

Since code isn't that short here are links to the class: Details presentation methods and update

let's say for now I want to present showActiveLedPosX() method which returns the X position as String.

the other classes are glove (using glove methods and creating glove object and UI).

Should I use different class for UI? or should I do it all on ShowGloveValues class

I've never created UI and therefore I'm kinda clueless here, Tried to read about it on numerous resource sites and still couldn't achieve what's needed.

有帮助吗?

解决方案

1. Keep the UI thread apart from the Non-UI thread.

2. Event Dispatcher Thread is the UI thread, keep this thread to handle your UI only.

3. You can also use SwingWorker for this.

4. Swing is based on Mode View Controller. Moreover its better to divide your app packages also on the basis of MVC.

eg:

  com.vivek.model;    // Class responsible for Business Logic and Data

  com.vivek.view;     // Class responsible for the UI
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top