Hello:

I am new to Java and I am working on a tutorial to familiarize myself with this language. The tutorial is a walk-through in building a basic text editor.

So far the build is going fine, but I have come to a point where I am unsure how to proceed in a certain area. In design view three icons (open file, delete file, help) are displayed, or rather, displayed in an incorrect area I believe. I assume the icons are being loaded by default via the tutorial. The icons instead of being aligned left-top, for example, are left-middle of the application GUI.

This is really only a visual design issue but I wish to correct it. I assumed I could simply drag-and-drop the icons to the preferred area (left-top); it allows this action, seemingly, but the icons remain in the original area, left-middle.

Am I missing something basic? Can I manually set the Y-axis to set the icons left-top?

** using Borland JBuilder

Any help would be appreciated. Thank-you in advance.

Matty D.

Dani AI

Generated

This is a classic layout/parent-container issue rather than a problem with the icons themselves. As found, buttons live inside a container (a panel or toolbar), and the GUI builder (and Swing at runtime) positions that container according to its layout manager and the parent’s constraints. The builder lets you move children visually, but moving a child usually does not change where its parent panel is placed in the frame.

A practical, robust approach is to use a JToolBar or put the button panel into the frame’s NORTH area so it stays at the top-left. For example:

JToolBar bar = new JToolBar();
bar.setFloatable(false);
bar.add(openButton);
bar.add(deleteButton);
bar.add(helpButton);
frame.getContentPane().add(bar, BorderLayout.NORTH);

In a GUI builder like JBuilder, open the component hierarchy/inspector, select the parent panel or toolbar (not an individual button), and either change its layout (e.g., FlowLayout with LEFT alignment) or change its BorderLayout constraint to NORTH. If you really need pixel placement you can setLayout(null) and use setBounds, but that makes resizing and different font/DPI settings fragile—prefer layout managers for cross-platform reliability.

After changes, run the form (or call frame.pack()) to see the true runtime layout. If the group still looks off, check nested panels, panel preferredSize, and button margins. Using JToolBar or a properly constrained panel gives the cleanest, most portable top-left toolbar behavior.

Hello:

I am new to Java and I am working on a tutorial to familiarize myself with this language. The tutorial is a walk-through in building a basic text editor.

So far the build is going fine, but I have come to a point where I am unsure how to proceed in a certain area. In design view three icons (open file, delete file, help) are displayed, or rather, displayed in an incorrect area I believe. I assume the icons are being loaded by default via the tutorial. The icons instead of being aligned left-top, for example, are left-middle of the application GUI.

This is really only a visual design issue but I wish to correct it. I assumed I could simply drag-and-drop the icons to the preferred area (left-top); it allows this action, seemingly, but the icons remain in the original area, left-middle.

Am I missing something basic? Can I manually set the Y-axis to set the icons left-top?

** using Borland JBuilder

Any help would be appreciated. Thank-you in advance.

Matty D.

OK, I figured this out. Had to drag the entire element that the buttons were placed on, not just the buttons.

Matty D.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.