java - What am I missing on my layout? I can't seem to get the sizes right -
i need have sidebar measures wrong. can't make them resizable , have right size. want jlabels left of corresponding text fields , and button right of them all-- in 1 panel in north , 2 panels below, 1 center , 1 south. missing?
this panel code:
package csheets.ext.findnetworkworkbooks.ui; import csheets.core.cell; import csheets.ext.findnetworkworkbooks.searchnetworkextension; import csheets.network.protocol.echo.echo; import csheets.ui.ctrl.uicontroller; import java.awt.borderlayout; import java.awt.gridlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.awt.event.mouseadapter; import java.awt.event.mouseevent; import javax.swing.defaultlistmodel; import javax.swing.jbutton; import javax.swing.jlabel; import javax.swing.jlist; import javax.swing.jpanel; import javax.swing.jscrollpane; import javax.swing.jtextfield; import javax.swing.listselectionmodel; /** * * @author eduardo pinto <1130466@isep.ipp.pt> */ public class searchnetworkpanel extends jpanel { private final uicontroller controller; private searchworkbooksui searchui; private final searchnetworkcontroller searchnetworkcontroller; private final jlist list, details; private final jbutton searchworkbook; private final jtextfield nomeaprocurar, porta; private final jlabel name, port; /** * constructor of class findworkbookpanel * * @param controller ui controller */ public searchnetworkpanel(uicontroller controller) { super(new borderlayout()); this.controller = controller; this.searchnetworkcontroller = new searchnetworkcontroller(this, controller); setname(searchnetworkextension.name); setlayout(new gridlayout(3, 1)); jpanel panel1 = new jpanel(new borderlayout(40, 20)); jpanel panel2 = new jpanel(new borderlayout(40, 20)); jpanel panel3 = new jpanel(new borderlayout(100, 50)); jpanel panel4 = new jpanel(new borderlayout(50, 50)); jpanel panel5 = new jpanel(new borderlayout(100, 100)); jpanel panel6 = new jpanel(new borderlayout(300, 300)); jpanel panel7 = new jpanel(new borderlayout(300, 300)); list = new jlist(); list.setmodel(new defaultlistmodel()); list.setselectionmode(listselectionmodel.single_interval_selection); list.setlayoutorientation(jlist.vertical); list.setvisiblerowcount(-4); jscrollpane listscroller = new jscrollpane(list); details = new jlist(); details.setmodel(new defaultlistmodel()); details.setselectionmode(listselectionmodel.single_interval_selection); details.setlayoutorientation(jlist.vertical); details.setvisiblerowcount(-4); jscrollpane detailsscroller = new jscrollpane(details); list.addmouselistener(new mouseadapter() { @override public void mouseclicked(mouseevent event) { if (event.getclickcount() == 1) { searchui.showworkbookdetails(); } } }); this.searchnetworkcontroller.setsearchnetworklistener(new searchnetworklistener() { public void found(echo w) { defaultlistmodel model = (defaultlistmodel) list.getmodel(); if (!model.contains(w)) { model.addelement(w); } } }); searchworkbook = new jbutton("search"); searchworkbook.addactionlistener(new actionlistener() { public void actionperformed(actionevent ae) { searchui.search(); } }); name = new jlabel("name:"); name.setbounds(100, 50, 150, 50); port = new jlabel("port:"); port.setbounds(100, 50, 150, 50); nomeaprocurar = new jtextfield(30); porta = new jtextfield(8); nomeaprocurar.setbounds(150, 50, 200, 50); porta.setbounds(150, 50, 200, 50); panel1.add(name, borderlayout.line_start); panel1.add(nomeaprocurar, borderlayout.center); panel2.add(port, borderlayout.line_start); panel2.add(porta, borderlayout.center); panel3.add(panel1, borderlayout.page_start); panel3.add(panel2, borderlayout.page_end); panel4.add(searchworkbook); panel5.add(panel3, borderlayout.line_start); panel5.add(panel4, borderlayout.line_end); panel6.add(listscroller); panel7.add(detailsscroller); add(panel5, borderlayout.north); add(panel6, borderlayout.center); add(panel7, borderlayout.south); } }
Comments
Post a Comment