Java notes - GUI graphical interface, data flow

  • GUI Design
    • Swing main inheritance relationship

      • Top-level container: JFrame\JApplet\JDialog\JWindow
      • Each top-level container has a content pane (ContentPane), and the components in the top-level container except the menu are placed in this content pane
      • Panel (JPane): The panel belongs to the intermediate container and cannot exist independently but can be nested. The panel must be added to other containers
        • FlowLayout: Components are placed one by one on a line in the container. When a line is full, a new line is
          created. Indicates left alignment, right alignment, and centering.
          ​•hgap and vgap set the horizontal and vertical spacing of components
        • BorderLayout
        • GridLayout: grid format
        • CardLayout: The component is regarded as a series of cards, and the order of the cards is determined by the order in which the components are placed in the container
        • BoxLayout: Line up horizontally or line up vertically
          • public BoxLayoutLayout(Container target, int axis); axis-- reverse southeast and northwest
    • event
      • Specify the name of the listener interface to be implemented in the declaration of the event listener class, such as: public class MyListener implements XxxListener { ...}
      • Implement the event processing method in the listener interface public void event processing method name (XxxEvent e) {...//Code for processing an event...}
      • Registration of instances of the listener class can be performed on one or more components. Such as: component object.addXxxListener(MyListener object);

       

      • Event Type:

  • swing components
    • button
      • JButton

      • JToggleButton: Obtain whether the current button is selected through the isSelected() method
        • JRadioButton\JCheckBox: group for grouping, after joining the group, you can only choose single, if you don’t add it, you can choose multiple

      • JComboBox: editable and non-editable
        • setEditable(boolean) whether the setting is editable, the default is not editable
      • JList
      • JScrollPane
      • JTextComponent
      • JMenuBar/JPopupMenu
        • JMenu
        • JMenuItem
      • JDialog
      • JOptionPane
      • JFileChooser
  • data flow
    • Basic byte data stream InputStream/OutputStream
      • File data stream: FileInputStream and FileOutputStream
        • out.write(in.read());
        • out.write(b, 7, b.length-7);
      • Buffer data stream: BufferedInputStream and BufferedOutputStream
        • The buffer is full of output, flush() forces the output

      • Data data stream: DataInputStream and DataOutputStream

      • Pipeline data stream: PipedInputStream must be used with class PipedOutputStream to establish a communication channel
      • Object Stream: ObjectInputStream and ObjectOutputStream
        • Serializable interface: When an object declares to implement the Serializable interface, it indicates that the class has joined the object serialization protocol
      • Character input and output streams: InputStreamReader and OutputStreamWriter
      • Buffer read and write: BufferedReader and BufferedWriter

    • file processing
      • File class
      • RandomAccessFile

Guess you like

Origin blog.csdn.net/qq_56061892/article/details/126224418