User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 391,706 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,293 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 2975 | Replies: 1
Reply
Join Date: Nov 2004
Posts: 86
Reputation: MrScruff is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
MrScruff's Avatar
MrScruff MrScruff is offline Offline
Junior Poster in Training

Panel Layouts

  #1  
Nov 28th, 2004
Is there anyway i can get some labels and sliders to alignproperly when they are both using grid layouts attached to a border layout.

Basically using one gridlayout for the lot meant that the labels had excessive space - so i opted for a border layout so the sizes would adjust accordingly. However this means the labels and sliders do not align.

Any suggestions?! Cheers

Ta Ta Mr Scruff

If someone could provide me with a means of a grid layout with automatically sized coloums that would be just as good.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,646
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 18
Solved Threads: 191
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Panel Layouts

  #2  
Nov 29th, 2004
You will have to nest different layout managers.
Make a component that is a JPanel with a GridLayout containing a label and a slider (so 1 row of 2 columns).
Then add that to your borderlayout where you want it to appear.
That way it should line up as you wish.

A simple test yields this (note it will look a bit weird as I didn't try to constrain the horizontal allignment):
public class TestLayout1 extends javax.swing.JFrame
{
	
	/** Creates new form TestLayout1 */
	public TestLayout1()
	{
		initComponents();
	}
	
	/** This method is called from within the constructor to
	 * initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
    private void initComponents()
    {
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jSlider1 = new javax.swing.JSlider();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        jPanel1.setLayout(new java.awt.GridLayout(1, 2));

        jLabel1.setText("jLabel1");
        jPanel1.add(jLabel1);

        jPanel1.add(jSlider1);

        getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);

        pack();
    }
	
	/**
	 * @param args the command line arguments
	 */
	public static void main(String args[])
	{
		java.awt.EventQueue.invokeLater(new Runnable()
		{
			public void run()
			{
				new TestLayout1().setVisible(true);
			}
		});
	}
	
    // Variables declaration - do not modify
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JSlider jSlider1;
    // End of variables declaration
	
}
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Java Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 2:55 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC