Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #39328

JLabel Text Cutoff

Newsgroups comp.lang.java.programmer
Date 2020-03-04 10:06 -0800
Message-ID <c906ffa0-dddc-452b-8a59-afa3ace910d3@googlegroups.com> (permalink)
Subject JLabel Text Cutoff
From Eric Douglas <e.d.programmer@gmail.com>

Show all headers | View raw


Is there an easy way to show text on a JLabel cutoff from the left?
I've tried every method and parameter I can think of but when the text runs out of the control it just wants to cut it off from the right.
 sample:
import java.awt.Dimension;
import java.awt.FlowLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;

public class TestLabel {

    public static void main(String[] args) {
        JFrame f = new JFrame();
        f.setPreferredSize(new Dimension(600,480));
        f.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
        String text = "too long text to fit in control";
        
        JLabel lbl_1 = new JLabel();
        lbl_1.setPreferredSize(new Dimension(70,20));
        lbl_1.setHorizontalAlignment(SwingConstants.TRAILING);
        lbl_1.setText(text);
        f.getContentPane().add(lbl_1);
        
        f.pack();
        f.setVisible(true);
    }
}

I see text displayed as "too long te..."
I want to see text displayed like "...in control"

Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

JLabel Text Cutoff Eric Douglas <e.d.programmer@gmail.com> - 2020-03-04 10:06 -0800
  Re: JLabel Text Cutoff Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2020-03-04 19:23 +0100
    Re: JLabel Text Cutoff Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2020-03-04 19:23 +0100
    Re: JLabel Text Cutoff Eric Douglas <e.d.programmer@gmail.com> - 2020-03-04 12:15 -0800
      Re: JLabel Text Cutoff Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2020-03-04 21:39 +0100
        Re: JLabel Text Cutoff Eric Douglas <e.d.programmer@gmail.com> - 2020-03-04 12:59 -0800
          Re: JLabel Text Cutoff Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2020-03-04 22:26 +0100
  Re: JLabel Text Cutoff Eric Sosman <esosman@comcast-dot-net.invalid> - 2020-03-04 13:25 -0500

csiph-web