Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to change the appearance of Swing programs

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "how to change the appearance of Swing programs". In daily operation, I believe many people have doubts about how to change the appearance of Swing programs. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how to change the appearance of Swing programs"! Next, please follow the editor to study!

Command line input changes the appearance of the Swing program

Sometimes, the Swing program does not provide a way to change the appearance at run time. When we use such a Swing program, we can override the default appearance configuration through command line input with the help of the Swing default property.

Java-Dswing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel

Myapp.MainClass

You can use this technique to provide a whole new look for the program that even the original programmer never thought of.

Get the appearance of a metallic texture

There are many informal properties that control the appearance of the metal texture and the cross-platform appearance of Swing. JTree's node design can connect child nodes to the parent node through a connector, but through your configuration, you can show or hide the connector. Configure these connections by setting the JTree.lineStyle property. After creating the JTree, add the following code

/ / show the lines in a JTree tree.putClientProperty ("JTree.lineStyle", "Angled"); / / hide the lines in a jtree tree.putClientProperty ("JTree.lineStyle", "None")

One complaint about the metallic look is that menus and labels are in bold. With another concise informal system feature, you can turn these off.

Java-Dswing.boldMetal=false myapp.MainClass

You can turn on the flipping of the JToolBar button by using a secret feature. This flip is useful because the user can clearly know where the current mouse pointer stays through this intuitive flip. Provide the size of the regular buttons on the toolbar, and the feedback is the substance.

Toolbar.putClientProperty ("JToolBar.isRollover", Boolean.TRUE)

There is a long (though not comprehensive) list of attributes on the Wiki page. In particular, Swing and metal textures have many informal system properties. When you find something new, add your comments to the page just mentioned. At the same time, it is particularly clear that it is often informal for some reason, and these things may be easily changed and may even be discarded in the future. So you'd better leave the risk to yourself.

At this point, the study on "how to change the appearance of Swing programs" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report