authorText.setPreferredSize(new Dimension(200,30));
jp.add(authorText);
jp.add(contLabel);
jp.add(contArea);
//给jp设置背景颜色
jp.setBackground(Color.PINK);
//获取组件的宽度Spring.width(组件名)
Spring titleLabelWidth=Spring.width(titleLabel);
Spring titleTextWidth=Spring.width(titleText);
Spring spaceWidth=Spring.constant(20);
Spring totalWidth=Spring.sum(Spring.sum(titleLabelWidth,titleTextWidth),spaceWidth);
int offSetX=totalWidth.getValue()/2;
/*
SpringLayout:布局管理器
SpringLayout.Constraints:使用弹簧布局的容器里面的组件的布局约束,每个组件对应一个
Spring:能够进行四则运算的整数
*/
/*
窗口相当于一个左顶角为原点的第四象限的坐标轴
*/
//设置好文章标签的位置(约束)
SpringLayout.Constraints titleLabelCon=spLayout.getConstraints(titleLabel);
//titleLabelCon.setX(Spring.constant(100));//水平偏移量
//titleLabel的西边距离jp的中心点向水平方向偏离offSetX的距离,负号代表向左偏移
spLayout.putConstraint(SpringLayout.WEST,titleLabel,-offSetX,SpringLayout.HORIZONTAL_CENTER,jp);
titleLabelCon.setY(Spring.constant(50));//垂直偏移量
//参考设置好的文章标签,设置其他组件的相对位置
/*
e1:要设置组件的哪个边界(edgeName)
c1:要设置的组件
pad:距离值
e2:参考的组件的边界名
c2:参考物(组件)
*/
//设置作者标签authorLabel和titleLabel东边对齐,authorLabel的北边距离titleLabel南边20px
spLayout.putConstraint(Sprin
必看视频!获取2024年最新Java开发全套学习资料 备注Java
gLayout.EAST,authorLabel,0,SpringLayout.EAST,titleLabel);
spLayout.putConstraint(SpringLayout.NORTH,authorLabel,20,SpringLayout.SOUTH,titleLabel);
//设置内容标签contLabel和authorLabel东边对齐,contLabel的北边距离authorLabel南边20px
spLayout.putConstraint(SpringLayout.EAST,contLabel,0,SpringLayout.EAST,authorLabel);
spLayout.putConstraint(SpringLayout.NORTH,contLabel,20,SpringLayout.SOUTH,authorLabel);
//设置标题文本titleText和titleLabel北边对齐,titleText的西边距离titleLabel东边20px
spLayout.putConstraint(SpringLayout.NORTH,titleText,0,SpringLayout.NORTH,titleLabel);
spLayout.putConstraint(SpringLayout.WEST,titleText,20,SpringLayout.EAST,titleLabel);
//设置作者文本authorText和authorLabel北边对齐,authorText的西边距离authorLabel东边20px
spLayout.putConstraint(SpringLayout.NORTH,authorText,0,SpringLayout.NORTH,authorLabel);
spLayout.putConstraint(SpringLayout.WEST,authorText,20,SpringLayout.EAST,authorLabel);
//设置作者文本contArea和contLabel北边对齐,contArea的西边距离contLabel东边20px
spLayout.putConstraint(SpringLayout.NORTH,contArea,0,SpringLayout.NORTH,contLabel);
spLayout.putConstraint(SpringLayout.WEST,contArea,20,SpringLayout.EAST,contLabel);
//设置作者文本contArea的南边和东边,参照jp
//作者文本contArea的南边参考jp的南边,作者文本contArea的东边参考jp的东边,向上偏移20px
spLayout.putConstraint(SpringLayout.SOUTH,contArea,-20,SpringLayout.SOUTH,jp);
spLayout.putConstraint(SpringLayout.EAST,contArea,-20,SpringLayout.EAST,jp);
contentPane.add(jp);
setSize(600,400);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setVisible(true);
}
public static void main(String []args) {
new SpringLayoutTest();
}
}
# **总结**
面试建议是,**一定要自信,敢于表达**,面试的时候我们对知识的掌握有时候很难面面俱到,把自己的思路说出来,而不是直接告诉面试官自己不懂,这也是可以加分的。
以上就是蚂蚁技术四面和HR面试题目,**以下最新总结的最全**,范围包含最全MySQL、Spring、Redis、JVM等最全面试题和答案,仅用于参考
![一份还热乎的蚂蚁金服面经(已拿Offer)面试流程4轮技术面+1轮HR](https://img-blog.csdnimg.cn/img_convert/523ee447f4b6d1c614770ecbbd63f0e7.webp?x-oss-process=image/format,png)
的时候我们对知识的掌握有时候很难面面俱到,把自己的思路说出来,而不是直接告诉面试官自己不懂,这也是可以加分的。
以上就是蚂蚁技术四面和HR面试题目,**以下最新总结的最全**,范围包含最全MySQL、Spring、Redis、JVM等最全面试题和答案,仅用于参考
[外链图片转存中...(img-uPd36Ndp-1716449106782)]