Creating more advanced elements in Java: Swing or images

When creating a GUI in Java with Swing, how should more complex "elements" be created? As an example, consider: enter image description here

This can be done using ~ 10 images depending on the current page or status. I am also sure that it would be possible to do this programmatically, however, given my past experience with Swing, I am also sure that this will be a lot of code for something relatively simple . Especially considering this can be done in CSS with max ~ 40 lines of code.

In such a situation, is there an alternative approach for creating this “element”? If not; which is preferable: images or swing?

+3
source share
3 answers
  • You can use a suitable Unicode character, for example. ✓-CHECK MARK or any number

    • as the label text is shown here .

    • like GlyphVector, mentioned here .

    • as shown in the picture here .

  • You can get a tinted, smooth circle by implementing an interface Icon; ColorIconis an example.

  • You can get many solid and dashed lines using the BasciStrokeone seen here .

  • Among stocks layout management , FlowLayoutmay be adequate.

+4
source

This will meet the requirements.

, , Swing - . , . , ( n ), Swing-. , , .

, . , .

. , , , .

, , .

. , , MouseListeners , , .

+3

Java ( , CSS - ), , .

, , , , , : .

, , ( , ..).

Performance using swing or another library gives you an increase in application size of several kilobytes, while using images can make your application more responsive in case of limited resources (mobile applications, old computers)

+2
source

Source: https://habr.com/ru/post/1787201/


All Articles