Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #23429
| From | Nigel Wade <nmw@ion.le.ac.uk> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: How to move text within Jlabels to the right |
| Date | 2013-04-12 15:07 +0100 |
| Message-ID | <asqipbF4ee0U1@mid.individual.net> (permalink) |
| References | <334f5820-444d-409b-ab37-913a2bc6a6d5@googlegroups.com> |
On 12/04/13 14:12, clusardi2k@aol.com wrote: > I have two JLabels with different lenght of text. One JLabel is below the other. I'd like to get the two "colons" in them to line-up vertically. > > I tried padding one with "space" characters, but that didn't line up perfectly. My guess is that certain characters have different widths. > > (I tried the align vertical and horizontal properties, etc but they didn't work.) > > Eg, In the below text of two JLabels, the addition of a space character didn't line up the two colons. > > Label1 My First Name: > Label2 Last Name: > > Thanks, > Place them in a JPanel, and set a layout manager which allows you to align them. GridBagLayout will do this. Align them with java.awt.GridBagConstraints.EAST, or LINE_END so they are at the right of the JPanel. The Tutorial has all the gory details: http://docs.oracle.com/javase/tutorial/uiswing/layout/index.html -- Nigel Wade
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to move text within Jlabels to the right clusardi2k@aol.com - 2013-04-12 06:12 -0700
Re: How to move text within Jlabels to the right Nigel Wade <nmw@ion.le.ac.uk> - 2013-04-12 15:07 +0100
Re: How to move text within Jlabels to the right bob smith <bob@coolfone.comze.com> - 2013-04-12 11:47 -0700
Re: How to move text within Jlabels to the right "John B. Matthews" <nospam@nospam.invalid> - 2013-04-13 15:20 -0400
Re: How to move text within Jlabels to the right Roedy Green <see_website@mindprod.com.invalid> - 2013-04-12 13:51 -0700
Re: How to move text within Jlabels to the right Knute Johnson <nospam@knutejohnson.com> - 2013-04-12 20:56 -0700
Re: How to move text within Jlabels to the right "John B. Matthews" <nospam@nospam.invalid> - 2013-04-13 15:16 -0400
csiph-web