layout-manager

Swing layout - Using a grid while keeping component dimensions

I'd like to make a login bar for an application and I can't figure out how to organize a series of JLabels and JTextFields such that they are organized in a horizontal grid without these same components being resized to fit each cell. I also want to make sure that the group of components isn't resized below a certain width. How can this ...

How can I control the width of JTextFields in Java Swing?

I am trying to have several JTextFields on a single row, but I don't want them to have the same width. How can I control the width and make some of them wider than others? I want that they together take up 100% of the total width, so it would be good if I could use some kind of weigthing. I have tried with .setColumns() but it doesn't m...

How can I "pack()" a printable Java Swing component?

I have implemented a Java Swing component that implements Printable. If I add the component to a JFrame, and do this.pack(); on the JFrame, it prints perfect. But if I don't add the component to a JFrame, just a blank page is printed. This code gives a great printout: final PrintablePanel p = new PrintablePanel(pageFormat); new JFrame(...

SWT Layout for absolute positioning with minimal-spanning composites

Hi, I'm writing a DND-editor where I can position elemtents (like buttons, images ...) freely via absolute positioning. Every element has a parent composite. These composites should span/grasp/embrace every element they contain. There can be two or more elements in the same composite and a composite can contain another composite. This i...

Building a Monopoly Board with GridBagLayout

I have been building a Java version of Monopoly in my spare time and am having some trouble understanding layouts etc for Swing. Each one of my spaces on the board is a essentially a custom JButton and I have been trying to lay them around the edge of a frame (like on the monopoly board itself). I can't seem to find a useful explanation...

How to build a custom draw2d layoutmanager?

I would like to have a layout manager that can arrange two elements as follows: one main element ABCDEF centered one "postscript" element XYZ, positioned on the top right corner of the encapsulating figure For example: ***********XYZ* * ABCDEF * *************** Can I use an existing layoutmanager for this? How do I build a c...

Laying ot components in Java Swing

Oh hay there, didn't see you. I was wondering if there is a better, more efficient way of formatting the labels, panels, and buttons in java then what I have done below. Here is my code, I want to make Welcome, the date, and the button to all be on separate lines. And the only logical way of doing so is creating blank labels, right? pri...

Fixed width, variable height in JPanel with flow

I have an annoying problem with Java’s layout managers. I have the following situation: In a panel A are two other panels B with an absolute layout and C with a FlowLayout. B is highly customized and has a fixed size set via setPreferredSize. C should have the same fixed width as B but otherwise be of a variable height, depending on how ...

GridBagLayout: equally distributed cells

Is it possible to completely emulate the behavior of a GridLayout with the GridBagLayout manager? Basically, I have a 8x8 grid in which each cell should have the same width and height. The GridLayout automatically did this. But I want to add another row and column to the grid which size is not the same as the other ones. That row/column...

why doesnt setLocation() move my label

I have the following code where I try to place a JLabel in a custom location on a JFrame. public class GUI extends JFrame { /** * * @param args */ public static void main(String args[]) { new GUI(); } /** * */ public GUI() { JLabel addLbl = new JLabel("Add: "); ...

Why the layout managers in QT doesn't work ?

this->setWindowTitle(tr("数据转移程序")); edt_ftp_server = new QLineEdit; edt_ftp_port = new QLineEdit; edt_ftp_account = new QLineEdit; edt_ftp_pwd = new QLineEdit; edt_ftp_pwd->setEchoMode( QLineEdit::Password ); lbl_ftp_server = new QLabel; lbl_ftp_server->setText(tr("FTP服务器地址:")); lbl_ftp_server->setBuddy( edt_ftp_server ); lbl...

GridBagLayout goes crazy

I have a GridBagLayout, but one label (maxSizeLbl) goes crazy and an other one (maxDateLbl) isnt visible, anyone knows what I've done wrong? Here is the Picture: And here is the Code: import java.awt.Component; import java.awt.Container; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import javax.swing.JButton; ...

Java Swing: How do I define one minimal dimension (of the two) for components?

To define minimal size successfully, I have to do the following: // setting minimal width AND height Dimension min = new Dimension(100, 100); comp.setMinimumSize(min); comp.setPreferredSize(min); comp.setSize(min); When I left one line out it doesn't work, which is strange, but it's not the point. What do I do to limit just one of tw...

Help regarding java swing/GridBagLaytout

Hi all, I'm currently trying to implement a Swing/GUI that could be regarded as a RDF editor. For each property , I can add/remove one ore more widgets storing the values (JTextField, JScrollPane+JTextArea, JCombo, etc.... ). I've been trying to use the GridBagLayout to put the Components in place but I can get any good result. Any ...

how to write a layout manager?

I'd like write a layout manager for j2me. I already have widgets and panels (panel is a set of widgets in this context). Now I'd like to add dynimc layout management so when i call doLayout on the outer most panel, internal widgets and panels rearrange according device's width and height. I was wondering whether there any well known pa...

jQuery form layout plugin

Hello, any advice on a good form layout plugin available for jQuery? I am thinking to something like the ExtJs Layout Managers' ...