C
CD1
Hi guys!
There's a situation in my program that I want to resize a JLabel:
I have a JDialog with a JPanel on it (with FlowLayout - it's one of the
panels... not the only one). There's a JTextField, where the user can
type a numeric code and after it, there's JLabel INITIALLY
[height=0;width=0]. When the user types a valid code, I wanna retrieve
the name of the person associated with it. That's simple and it's
already done. I SELECT it from the database and
mylabel.setText(myname). The JLabel shows it. BUT (here's the "but"!)
if the name is longer than the JDialog width, the JLabel doesn't show
nothing of the string! If i resize to the necessary width, it pops up
the name, suddenly. I wanted it to always show the part of the name
that fits in the JDialog, with a "..." in the end, like "I have a big
name and ..." (if the screen ended up here). Got it?
I tried to calculate the available width, but it seems complicated... I
had to calculate the JDialog's width minus the JTextField's width minus
the JLabel's (associated with the JTextField) width minus the gaps
between them... I think that'd be a simpler way to do it.
Thank you, anyway
Crístian Deives
There's a situation in my program that I want to resize a JLabel:
I have a JDialog with a JPanel on it (with FlowLayout - it's one of the
panels... not the only one). There's a JTextField, where the user can
type a numeric code and after it, there's JLabel INITIALLY
[height=0;width=0]. When the user types a valid code, I wanna retrieve
the name of the person associated with it. That's simple and it's
already done. I SELECT it from the database and
mylabel.setText(myname). The JLabel shows it. BUT (here's the "but"!)
if the name is longer than the JDialog width, the JLabel doesn't show
nothing of the string! If i resize to the necessary width, it pops up
the name, suddenly. I wanted it to always show the part of the name
that fits in the JDialog, with a "..." in the end, like "I have a big
name and ..." (if the screen ended up here). Got it?
I tried to calculate the available width, but it seems complicated... I
had to calculate the JDialog's width minus the JTextField's width minus
the JLabel's (associated with the JTextField) width minus the gaps
between them... I think that'd be a simpler way to do it.
Thank you, anyway
Crístian Deives