layout-manager

Panel added to BorderLayout.CENTER does not occupy remaining space

蓝咒 提交于 2019-12-11 10:38:26
问题 I am currently learning to program GUI in Java, and I have a problem where the CENTER component does not occupy the remaining space in the frame. From what I've read BorderLayout will grant components in north/south their preferred height and the stretch it out to the edges, and west/east will be the opposite. The center component will then get whatever space is left. What I am trying to do is to create a simple window with a panel in the north region, and a panel in the center region. I give

How to add one image multiple times in one JFrame?

为君一笑 提交于 2019-12-11 10:23:16
问题 I am trying to make one image display multiple times. Here's part of my code: JFrame window = new JFrame(); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setBounds(30, 30, 800, 600); JLabel blue = new JLabel(new ImageIcon("blue.jpg")); JLabel green = new JLabel(new ImageIcon("green.jpg")); window.add(blue); window.add(green); window.add(blue); window.setLayout(new GridLayout(3, 3)); window.setVisible(true); Unfortunately what is created is just one image of each kind. What am

JTextFields automatically resizing

谁说胖子不能爱 提交于 2019-12-11 10:07:34
问题 I am making a program that is supposed to allow you to type in text, and it will that text in every single font on the computer. Here is a screenshot of what happens just as the fonts are loaded: Now, I realize that there are a billion other problems besides the automatic resizing of the JTextFields, but I want to focus on one thing at a time. Anyway, whenenver I scroll down in the JScrollPane, here's what happens: Could someone please tell me what I have to do with the GridBagConstraints or

Creating dcheckbox dynamically in Java-NetBeans

浪子不回头ぞ 提交于 2019-12-11 09:54:51
问题 I am developing a simple "To-do List" application which involves obtaining 'things to do' for a particular day from the database and displaying them as checkbox text on a panel resting on a frame.There is a button "done" which can be used to remove the ticked checkboxes after a task is complete. The code that I used for the dynamic creation of the checkboxes is shown below: //cnt-variable used to store the number of tasks for a day //rs1-ResultSet variable into which the task description is

Align the label column of different DesignGridLayout

為{幸葍}努か 提交于 2019-12-11 09:52:59
问题 Consider two JPanel instances using DesignGridLayout, like the following: JFrame demoApplicationFrame = new JFrame(); JPanel singleDesignGridLayout1 = new JPanel(); DesignGridLayout layout1 = new DesignGridLayout(singleDesignGridLayout1); layout1.row().grid(new JLabel("Short lbl1")).add(new JTextField("")); layout1.row().grid(new JLabel("Short lbl2")).add(new JTextField("")); JPanel singleDesignGridLayout2 = new JPanel(); DesignGridLayout layout2 = new DesignGridLayout(singleDesignGridLayout2

How to change CardLayout panels from a separate panel?

点点圈 提交于 2019-12-11 09:03:47
问题 My software layout is kinda wizard-base. So the base panel is divided into two JPanel s. One left panel which never changes. And one right panel that works with CardLayout . It has many sub-panels and show each one of them by a method. I can easily go from one inner panel to another one. But I want to have a button in left panel and change panels of the right side. Here is a sample code which you can run it: BASE: public class Base { JFrame frame = new JFrame("Panel"); BorderLayout bl = new

JLayeredPane and GridBagConstraints

佐手、 提交于 2019-12-11 08:13:40
问题 Inspired by this question JLayeredPane with a LayoutManager I'm trying to get the JLayeredPane to work with the GridBagLayout. Here's the custom LayeredPane-class: class StackConstraints { public final int layer; public final Object layoutConstraints; public StackConstraints(int layer, Object layoutConstraints) { this.layer = layer; this.layoutConstraints = layoutConstraints; } } class LXLayeredPane extends JLayeredPane { private static final long serialVersionUID = 1946283565823567689L;

Center panel when window resized

你。 提交于 2019-12-11 07:50:12
问题 I would like to keep a panel I have created using an absolute layout in the center of my window even when the window is resized (if possible). I've come across a couple of suggestions here and [here][2] but no dice! Below is my sample code, any ideas or suggestions? I have no problems centered a single component like a JLable but I want to center a panel with many components! import java.awt.Color; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import javax.swing.JFrame;

How much support does GWT have for Java layout managers?

萝らか妹 提交于 2019-12-11 07:49:12
问题 This seems to be a question where the answer is implicit, hence I can't find anything explicit. Does Google Web Toolkit only support custom layout managers, or a sub-set of the Java layout managers? For example, is it possible to take a Java Swing application using GroupLayout and get it to work with GWT? 回答1: GWT layout support is done through subclasses of 'Panel'. Some of them like 'DockPanel' behave a little bit like Swing layouts (BorderLayout) but there's no way you'll ever be able to

plMortgage Calculator GUI Issue with A Lot

只愿长相守 提交于 2019-12-11 07:31:41
问题 I am having a lot of issues with this application. I have been at this all day and cannot get this figured out. I have a Java application that is for a class. The issue that I am having is trying to get the JRadioButtons assigned to variables in the array then passing them into the formula. If someone could help I would appreciate it a lot. import java.awt.*; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.text.NumberFormat; import javax.swing.*; import