java - Filling a JPanel -
i have few items in jpanel pushed top , used toolbar basic search engine. i'm having issue last combobox isn't displaying there isn't enough room. however, there's lot of empty space on left side , need move across fill jpanel can display. question how make these items start far left , go right, thanks.
//labels combo boxes jlabel bookmarklbl = new jlabel("bookmarks:"); jlabel historylbl = new jlabel("history:"); flowlayout flowlayout = new flowlayout(); mainbrowser.toolbar.setlayout(flowlayout); //adding items panel mainbrowser.toolbar.add(bookmarklbl); mainbrowser.toolbar.add(bookmarklist); mainbrowser.toolbar.add(bookmarkbtn); mainbrowser.toolbar.add(back); mainbrowser.toolbar.add(forward); mainbrowser.toolbar.add(mainbrowser.addressbar); mainbrowser.toolbar.add(home); mainbrowser.toolbar.add(reload); mainbrowser.toolbar.add(historylbl); mainbrowser.toolbar.add(historylist); //set things added left right mainbrowser.main.setcomponentorientation( componentorientation.left_to_right); //add panel main frame mainbrowser.main.add(mainbrowser.toolbar,borderlayout.north);
how bar looks:http://postimg.org/image/l314iw6eh/
assuming toolbar
jpanel
, using flowlayout
, code might you,
jpanel panel = new jpanel(); // toolbar panel flowlayout flowlayout = (flowlayout) panel.getlayout(); // flowlayout flowlayout.setalignment(flowlayout.left); // alignment left contentpane.add(panel, borderlayout.north); // adding panel original frame
hope helps
Comments
Post a Comment