Java form basic operation statement JFrame, basic operation jframe
Package com. swift; import java. awt. color; import java. awt. gridLayout; import java. util. random; import javax. swing. JFrame; import javax. swing. JPanel; public class RP_Frame extends JFrame {private static final long serialVersionUID = 1L; public RP_Frame () {setBounds (200,200,500,300 ); // set the form size position setTitle ("basic operation statement of Java form"); // set the Form title JPanel pnBasic = new JPanel (); // generate a large canvas setContentPane (pnBasic); // put it in the form pnBa Sic. setLayout (new GridLayout (,); // The canvas is arranged in a grid of two rows and one column. The row and column are separated by five pixels. // JPanel pnGreen = new JPanel (); // regenerate a small green canvas // JPanel pnYellow = new JPanel (); // regenerate a small yellow canvas // pnYellow. setBackground (Color. YELLOW); // set the color of the canvas // pnGreen. setBackground (Color. GREEN); // set the color of the canvas // pnBasic. add (pnYellow); // pnBasic. add (pnGreen); for (int I = 0; I <(4*3); I ++) {JPanel pn = new JPanel (); // generate multiple small canvas Random ran = new Random (); int red = ran. nextInt (2 56); int yellow = ran. nextInt (256); int blue = ran. nextInt (256); pn. setBackground (new Color (red, yellow, blue); // set the random Color pnBasic for the canvas. add (pn); // put it into the large canvas} // final JButton btn = new JButton (); // btn. setText ("too many broken button too many"); // setContentPane (btn); // btn. addActionListener (new ActionListener () {// @ Override // public void actionreceivmed (ActionEvent e) {// Random ran = new Random (); // int index = ran. nextIn T (101); // System. out. println ("Hello! "+ Index); // btn. setText ("variable" + index); //}); setdefaclocloseoperation (JFrame. EXIT_ON_CLOSE); // sets the program to stop running setVisible (true) when the form is closed; // sets the form to be visible, otherwise nothing will be displayed} public static void main (String [] args) {new RP_Frame ();}}