gridbaglayout

Swing GridBagLayout with screen resizing

六眼飞鱼酱① 提交于 2019-12-24 05:24:05
问题 For my Java Swing GUI I have two major components: One part is a vertical list of a few check boxes, the other is an image. When the jframe window is resized/maximised the proportions stay the same when I would much rather the absolute size of the check box list stay the same and just the image resize like: Is this possible using GridBagLayout? I have been laying everthing out into one JPanel ( ContentPane ) using the following: CheckBoxes: for(int i=0; i<5; i++){ GridBagConstraints gbc = new

Java gridbaglayout problems

别说谁变了你拦得住时间么 提交于 2019-12-24 03:07:51
问题 I'm having problems adjusting my combobox so it is closer to the 'band directory' label. How do i move the combobox to the left, just 5px besides the label. I have tried setting horizontal insets for my label and negative insets for my combobox but that still did not work. Here is my code: public void createGUI() { main_panel = new JPanel(); main_panel.setLayout(new GridBagLayout()); GridBagConstraints gc = new GridBagConstraints(); label = new JLabel("Band Directory:"); band_combobox = new

Various grid sizes and JPanel elements with GridBagLayout

房东的猫 提交于 2019-12-24 02:37:29
问题 I am trying to match the following while implementing a GridBagLayout. The GBL is the only way I know i can get the different sized elements. I know I can do something like the above picture but I don't know how to do it with GBL. I am also ready to take suggestions on a better idea. 回答1: import java.awt.*; import javax.swing.*; import javax.swing.border.*; class PlayerGui { public static void main(String[] args) { JPanel gui = new JPanel(new BorderLayout()); gui.setBorder(new BevelBorder

GridBag Layout or Absolute Positioning?

岁酱吖の 提交于 2019-12-24 02:14:14
问题 I'm working on a piece of code where several imageIcons will overlap several other imageIcons. imageIcons in the foreground will stay the same while imageIcons in the background will change to different imageIcons I don't usually have the best luck with layouts. Components will move when I adjust the frame size, for instance. Also, when I add one object and then add another object, the second object will "push" the other object right (or wherever the particular layout is designed to put the

Nested JPanel with GridBagLayout

左心房为你撑大大i 提交于 2019-12-23 17:35:05
问题 I have a JFrame with GridBagLayout . weightx and weighty values are assigned different no-zero values and GridBagConstraints.fill = GridBagConstraints.BOTH. I nested a JPanel in one of the cells and gave it a GridBagLayout too. When adding components to the nested JPanel, the cell size where the nested JPanel resides grows on all sides missing up the parent's layout. Insets and padding are not used. How can I fix this problem?Thanks. This is an example of the GridBagConstraints values:

GridBag Layout How to push components north

余生颓废 提交于 2019-12-23 17:12:22
问题 Here's my code public class HomeTopPanel extends JPanel { //BUTTONS private final JButton myAccountButton = new JButton("My Account"); private final JButton updatePhoto = new JButton("Update Photo"); //PANELS private final JPanel rightPanel_1 = new JPanel(new GridBagLayout()); private final JPanel rightPanel_2 = new JPanel(new GridBagLayout()); private final JPanel logHistoryPanel = new JPanel(new GridBagLayout()); //BORDERS private final Border homeTopPanel_LineBorder = BorderFactory

JToolBar IllegalArgumentException when dropped back into GridBagLayout

守給你的承諾、 提交于 2019-12-23 15:15:54
问题 Why does this code throw an IllegalArgumentException when the tool bar is dragged off the GUI, then closed (to return it to the GUI)? I could understand why it might be improper to add a component with no constraint, but in this case, the initial addition of the toolbar to the panel (which uses GridBagLayout ) without a constraint causes no such problem. Why should it occur the 2nd and subsequent times it is added? The code is adapted from this answer, but both codes show the same problem.

java grid bag layout: avoiding center alignment

纵饮孤独 提交于 2019-12-23 12:54:07
问题 In my GUI application, I have several JPanels that are instantiated at various points during the running of my program, and certain actions will cause one of them to be displayed in a scroll pane: mViewport.setViewportView(currentPanel); The trouble is, that my panels are done using Grid Bag Layouts, and the behaviour of that is to center itself within the JScrollPane it is inside of. This make the GUI look weird. Anyone know of a way to force a grid bag layout panel to top-left align? Thanks

Swing dynamic(auto) fit-layouting

好久不见. 提交于 2019-12-23 05:48:22
问题 Considering 100(dynamic) JLabel Object, and I want to show them inside a resizable JPanel . Currently I use grid bag layout (2 columns and 50 rows), but when user resizes and expands the form, I want to have(for example) 4 columns and 25 rows, and same for small form(1 column, and 100 rows), in other way fill up the whole panel(no any white spaces). I know this is should be done manually, currently I redraw(repaint) all members once user resize the form, but I just was wondering if there is

One column layout does not use full width of window

女生的网名这么多〃 提交于 2019-12-22 20:04:34
问题 I would like to create a layout: 2 rows, 1 column. 1st row should occupy 70% height of the window and 2nd row 30% of the window. I achieve this by using weighty attribute of GridBagConstraints . However I have problem with the width of my component, because when I resize application window the component remain in the center, its width is constant and I get a white spaces in the left and right of the component (even if I set fill to BOTH ). This problem does not occur when I change the height