I searched for longer hours, but still the answer can not be found I needed.
I'm trying to do a simple layout set up and anything I want it to look like a Gridbagleaut including two Jepianls I Build the layout on the image went down.
I'v found using BoxLayout
import java.awt.Color. Public category proportional panels JFrame {Personal JPanel contentPane; / ** * Create Frame * / Public ProportionalPanels () {setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); Setbound (100, 100, 450, 300); ContentPane = new zpn (); ContentPane.setBorder (new blank border (0, 0, 0, 0)); SetContentPane (contentPane); ContentPane.setLayout (New BoxLayout (contentPane, BoxLayout.X_AXIS)); Final JP Penal panel_A = new zpn (); Panel_A.setBackground (new color (255, 165, 0)); ContentPane.add (panel_A); Last JPanel panel_B = new zpn (); Panel_B.setBackground (new color (176, 196, 222)); ContentPane.add (panel_B); Panel_A.set Minimum size (new dimension (0, 0)); Panel_B.set Minimum size (new dimension (0, 0)); Panel_A.setPreferredSize (new dimension (0, 0)); Panel_B.setPreferredSize (new dimension (0, 0)); Panel_A.setMaximumSize (new dimension (Short.MAX_VALUE / 5, Short.MAX_VALUE)); Panel_B.setMaximumSize (new dimension (Short.MAX_VALUE, Short.MAX_VALUE)); AddComponentListener (New ComponentAdapter () {@Override public void componentResized (ComponentEvent e) {System.out.printf ( "Panel Width Rate:% n .2f%"., panel_B.getSize () width / (double) panel_A.getSize ( ). Width);}}); } / ** * Launch Application * / Public Fixed Zero Main (string [] Args) {Proportional panels frame = new proportional panels (); Frame.setVisible (true); }
}
Comments
Post a Comment