Write the panel really is to write to vomit blood, deeply feel what is called smelly and long, may be oneself use of too rotten.
About the layout manager does not write a bit or do not understand, plus the idea of adding a panel is similar to the sense of the div in HTML.
Found a small egg: with JScrollPane When you want to add JTextArea must be in the Newjscrollpane, with Jsp.add (t) is how also will not appear.
There is a small problem, every time the test opens the graphical interface must change the window size to refresh the interface is why?
1 Importjava.awt.*;2 Importjava.awt.event.*;3 4 Importjavax.swing.*;5 6 7 Public classOutlookextendsJFrameImplementsactionlistener{8 PublicOutlook ()9 {TenJFrame frm=NewJFrame ("Text editor"); OneFrm.setvisible (true); A -Frm.setbounds (50, 50, 500, 400); -Frm.setlayout (NewBorderLayout (5,5)); the -JPanel areabottom=NewJPanel (); - -Areabottom.setlayout (NewFlowLayout (flowlayout.center,40,10)); + -JButton save=NewJButton ("Save"); +JButton can=NewJButton ("Cancel"); AJButton exit=NewJButton ("Exit"); at -JTextArea t=NewJTextArea (); -JScrollPane mid=NewJScrollPane (t,jscrollpane.vertical_scrollbar_always,jscrollpane.horizontal_scrollbar_as_needed); - -T.setlinewrap (true); -T.setwrapstyleword (true); in -Save.setpreferredsize (NewDimension (80,30)); toCan.setpreferredsize (NewDimension (80,30)); +Exit.setpreferredsize (NewDimension (80,30)); - the Areabottom.add (save); * Areabottom.add (CAN); $ Areabottom.add (exit);Panax Notoginseng -Frm.add ("South", areabottom); theFrm.add ("Center", mid); + AAreabottom.setsize (140, 0); the +Can.addactionlistener (NewMyListener ( This)); - $ } $ Public Static voidMain (string[] args) { - NewOutlook (); - } the - Public voidactionperformed (ActionEvent e) {Wuyi the - } Wu}
Event handling is still a myth.
Java Panel Design