swing - Java JList GUI formatting -
I have trouble formatting a GUI to develop a program. I need four buttons with a jellist over it. . My JLIT continues to appear in addition to all my buttons instead of above them. Can anyone tell me in the right direction to solve my problem?
Import java.awt.BorderLayout; Import java.awt.GridLayout; Import javax.swing.JButton; Import javax.swing.JFrame; Import javax.swing.JList; Import javax.swing.JPanel; Import javax.swing.JScrollPane; Public Class Test extends JPN {Private Static Finals Long Serial Weirsian UID = 1 L; Private Jellist Jistle; Public static zero main (string [] Args) {Jeffrey Box Option = New Gefram ("Calculator"); boxOptions.setSize (0,0); BoxOptions.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); boxOptions.setResizable (wrong); BoxOps.Setletout (new border layout ()); BoxOptions.add (new test (), border layout .a); BoxOptions.pack (); boxOptions.setLocationRelativeTo (zero); boxOptions.setVisible (true); } Public Test () {Set Layout (New Grid Layout (1, 4, 5, 5)); Addition (new pocket ("junk"); Add (new pocket ("check in"); Addition (new pocket ("check out")); Addition (new pocket ("remove")); String [] titles = {"one", "two", "three"}; Jlist = new jellist (title); jlist.setVisibleRowCount (3); Addition (new JScrollPane (jlist), border layout.NORTH); First, the border layout parameter is used only when there is a layout border layout. You can use GridBagLayout instead of the sample code below setLayout (new gridboutout ()); New Zebbutton ("Ed"), New Gridbag Concepts (0, 1, 1, 1, 1.0, 1.0, Gridbang Constants. CER, Gridbag Constance .both, New Ints (0, 0, 0, 0), 0, 0) ); New Payben ("Check In"), New Gridbag Consultants (1, 1, 1, 1, 1.0, 1.0, Gridbag Consultants. CER, Gridbag Consultants.both, New Ints (0, 0, 0, 0), 0, 0 )); New Zebbutton ("Check Out"), New Gridbag Concepts (2, 1, 1, 1, 1.0, 1.0, Gridbag Constants., CAR, Gridbag Consultants. BOTF, New Inset (0, 0, 0, 0), 0, 0 )); New PocketBug Concepts (3, 1, 1, 1, 1.0, 1.0, Gridbag Consultants, CER, Gridbag Consultants. Booth, New Ints (0, 0, 0, 0), 0, 0) ); String [] titles = {"one", "two", "three"}; Jlist = new jellist (title); Jlist.setVisibleRowCount (3); (New JScrollPane (jlist), New GridBagConstraints (0, 0, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, New Insets (0, 0, 0, 0), 0, 0)); Is this your hope?
Comments
Post a Comment