In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article focuses on "how to use Java Swing intermediate containers". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use Java Swing intermediate containers.
Getting started with Java Foundation Swing Intermediate Container
In Swing, there are not only top-level windows such as JFrame and JDialog, but also some intermediate containers, which cannot exist alone and must be stored in the top-level window. The most common ones are JPanel and JScrollPane.
The Panel component in JPanel:JPanel is basically the same as that in AWT. It is a panel without borders that cannot be zoomed in, moved or closed. Its default layout manager is FlowLayout, which can of course be reset using the setLayout () method.
JScrollPane: unlike JPanel, JScrollPane is a panel container with scroll bars and only one component can be added to this panel. If you want to add multiple components, you must first add multiple components to Panel and then add Panel to JScroollPane.
The following example illustrates JScrollPane's method JScrollPane construction method and method declaration function description JScrollPane () creates an empty JScrollPane panel JScrollPane (Component view) creates a JScrollPane panel that displays the specified component, as long as the component size exceeds the panel size, horizontal and vertical scroll bars JScrollPane (Component view,int vsbPolicy,int hsbPoliy) create a JScrollPane panel import java.awt.*;import javax.swing.* that displays the specified container Public class Main extends JFrame {public Main () {this.setTitle ("PanelDemo"); JScrollPane scrollPane=new JScrollPane (); / / set the horizontal progress bar to appear scrollPane.setHorizontalScrollBarPolicy (ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED) when needed. / / set the vertical progress bar to always appear scrollPane.setVerticalScrollBarPolicy (ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); JPanel panel=new JPanel (); panel.add (new JButton ("button 1"); panel.add (new JButton ("button 2")) Panel.add (new JButton ("button 3")); panel.add (new JButton ("button 4")); for (int iButton 5)
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.