A pattern: Model----View-----Controller
There are many types of patterns, such as: Model----View----Controller (the principle is to limit the number of functions that an object has); combination models-between containers and components; adorner mode----a panel with scroll bars; policy mode-----layout Manager
Content---appearance----behavior----MVC
The relationship between model and view 1:N model is independent of perception, so it is possible to reuse
The model may be the same, but the view and controller may be different
In metal perception, JButton inherits the wrapper class of JComponent, which contains Defaultbuttonmodel (model) objects and Basicbuttonui (view) objects.
Flow Layout Manager: Components are prevented from being placed in the container, the Flow layout manager is fully secure, the container can also be placed in another container, the buttons and text fields are inherited from the component class, and the hierarchy of the component class is detailed with P328
The Add method of the container can pass the component and placement method to the layout manager,. Seglayout (Prevent layout manager for containers)
The layout manager for each of the Jfram's content panes, which allows you to select a drop location for each component. Add (component, in the cardinal); When scaled, the edge component size is unchanged, the size of the intermediate component changes first, and the default is: Medium.
Flow layout Manager: Maintain optimal dimensions for each component----------Border layout Manager: Extend components to fill free space
Detailed in P330
Text fields can only accept single-line input------JTextField-----New JTextField ("content", limit number), the text area receives multiple lines------jtextarea, password input does not display the correct content--------Jpassword These three classes inherit from the JTextComponent abstract class, which has methods gettext,settext (manipulation of the text), iseditable,seteditable (for editable operations), and can be used by methods SetColumns () Reset the number of columns (the number of words), after using this method need to call the text box container Revalidate method (This method is JComponent class method) This method will recalculate the size and layout of each component within the container, However, if you want to recalculate the size of all components in the JFrame (frame), you should use the name validate method, because JFrame does not inherit from the JComponent class
Using SetText (String), this method is defined in the JTextComponent class, corresponding to the GetText method
GetText (). Trim () to get a string with no spaces
The SetFont method will change the font of the reality in detail in p335
JLabel is a swing class that implements the Jconstants interface with typographic parameter constants such as: Swingconstants.right or Jlabel.right right.
JLabel instances can be built using names, icons, and typography
The line break in the text area is just a visual effect, and the text in the document is not changed (add line breaks), and you can use the. Setlinewrap (True) method to prevent long rows from being cropped
The text area is inserted into the scroll pane to implement the scroll bar, new Jscroolpane (text area component), after joining, the scroll pane is responsible for managing the view of the text area and can add scrolling functionality to any component
The JTextArea component displays only unformatted text, which needs to be detailed with the JEditorPane class when displaying formatted text P338
This article is from the "Developing_rookie" blog, make sure to keep this source http://8942041.blog.51cto.com/8932041/1634794