//Streaming layout ManagerImportjava.awt.*;Importjavax.swing.*; Public classJiemian2extendsjframe{//Defining ComponentsJbutton[] an = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}; Public Static voidMain (string[] args) {//to run this class of construction methodsJiemian2 Jiemian =NewJiemian2 (); } PublicJiemian2 () {//Create buttonAn[0] =NewJButton ("Plum"); an[1] =NewJButton ("Fruit Shop")); an[2] =NewJButton ("Potato chips")); an[3] =NewJButton ("Biscuit"); an[4] =NewJButton ("Chocolate"); an[5] =NewJButton ("Cashew"); an[6] =NewJButton ("Rice crust"); an[7] =NewJButton ("Pistachio"); //add layout Manager to avoid adding errors//because Java defaults to the boundary layout manager, this is changed to a streaming layout manager//The second parameter is the alignment, left,right the default center alignment//this.setlayout (New FlowLayout ()); This. setlayout (NewFlowLayout (flowlayout.left)); //Add button This. Add (an[0]); This. Add (an[1]); This. Add (an[2]); This. Add (an[3]); This. Add (an[4]); This. Add (an[5]); This. Add (an[6]); This. Add (an[7]); //Set Window caption This. Settitle ("Streaming layout FlowLayout"); //Set the width height of the window This. SetSize (300,300); //The Settings window appears for the location of the screen This. setlocation (100,100); //no pulling the big pull small This. setresizable (false); //releasing a resource after closing a window This. Setdefaultcloseoperation (Jframe.exit_on_close); //Output Window This. setvisible (true); } }
JAVA Streaming layout Manager