JLabel未对齐左侧

时间:2017-11-24 11:39:26

标签: java swing jlabel

我的JLabel hudHeader未与左对齐。

目前的情况如下: enter image description here

HUDisplay扩展了JPanel。

with T_BUSINESS_LOC (Person_ID, Business_loc) as (
    select 101, 'Delhi'  from dual union all
    select 102, 'Mumbai' from dual union all
    select 103, 'Noida'  from dual union all
    select 104, 'Mumbai' from dual union all
    select 105, 'Noida'  from dual union all
    select 106, 'Delhi'  from dual union all
    select 107, 'Mumbai' from dual union all
    select 108, 'Delhi'  from dual union all
    select 109, 'Mumbai' from dual ),
  T_LOG_ACCESS(Person_ID, ACCESS_DATE) as (
    select 101, timestamp '2017-10-23 12:07:55.027206000' from dual union all
    select 101, timestamp '2017-10-25 12:10:36.522369000' from dual union all
    select 102, timestamp '2017-10-25 12:52:52.289198000' from dual union all
    select 103, timestamp '2017-10-23 12:15:58.494122000' from dual union all
    select 103, timestamp '2017-10-23 12:15:58.494122000' from dual union all
    select 103, timestamp '2017-10-24 12:23:41.205421000' from dual union all
    select 104, timestamp '2017-10-23 12:05:05.726392000' from dual union all
    select 104, timestamp '2017-10-25 12:05:05.726392000' from dual union all
    select 108, timestamp '2017-10-23 06:48:36.399221000' from dual union all
    select 109, timestamp '2017-10-23 06:53:13.026891000' from dual union all
    select 109, timestamp '2017-10-25 12:05:05.726392000' from dual ),
  PERSON_ROLE(Person_ID, assigned_role) as (
    select 101, 'HR_Role'   from dual union all
    select 102, 'MN_Role'   from dual union all
    select 103, 'HR_Role'   from dual union all
    select 104, 'HR_Role'   from dual union all
    select 105, 'MN_Role'   from dual union all
    select 106, 'Cont_Role' from dual union all
    select 107, 'HR_Role'   from dual union all
    select 108, 'Cont_Role' from dual union all
    select 109, 'MN_Role'   from dual )
-- end of data, query starts here
select * 
  from (
    select business_loc loc, assigned_role rol
      from t_log_access 
      join t_business_loc using (person_id)
      join person_role using (person_id)
      where date '2017-10-23' <= access_date and access_date < date '2017-10-24')
  pivot (count(1) for rol in ('MN_Role'   Mn_Role_Count, 
                              'HR_Role'   HR_Role_Count, 
                              'Cont_Role' Cont_Role_Count))
  order by loc

1 个答案:

答案 0 :(得分:1)

不是:它看起来像是一个HTML正文边距

NOT hudHeader = new JLabel(
NOT         "<html><body style='margin: 0 0 0 0;'><b>Simulation informations</b><br />" +
NOT         "<i style=\"font-size: 8px;\">Running for " + "0" + "s</i>" + "</html>");

然而,可能有一些可疑的东西,比如RTL,所以也试试

hudHeader .setAlignment(SwingConstants.LEFT);