如何将JLabel对齐到JPanel的左侧? [英] How to align JLabel to the left of the JPanel?
本文介绍了如何将JLabel对齐到JPanel的左侧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将JLabel对齐到左侧.
I want to align my JLabel to the left.
String lText = "<html><b><font color = white face = comic sans ms size = 20>mybook</font></b></html>";
JLabel label = new JLabel(lText);
label.setBorder(new EmptyBorder(25,0,25,500));
我尝试使用EmptyBorder来执行此操作,但是它无法正确对齐.我正在使用FlowLayout
I tried to do it using EmptyBorder but it isnt aligning properly. I am using FlowLayout
推荐答案
FlowLayout
默认情况下使用CENTER
对齐方式.尝试对JLabel
JPanel
容器使用LEFT
对齐方式
FlowLayout
uses CENTER
alignment by default. Try using LEFT
alignment for your JLabel
JPanel
container
myJPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
这篇关于如何将JLabel对齐到JPanel的左侧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文