最近我根据上述的技术体系图搜集了几十套腾讯、头条、阿里、美团等公司21年的面试题,把技术点整理成了视频(实际上比预期多花了不少精力),包含知识脉络 + 诸多细节,由于篇幅有限,这里以图片的形式给大家展示一部分
}
public JFrameBackground() {
background = new ImageIcon(“003.jpg”);// 背景图片
JLabel label = new JLabel(background);// 把背景图片显示在一个标签里面
// 把标签的大小位置设置为图片刚好填充整个面板
label.setBounds(0, 0, background.getIconWidth(),
background.getIconHeight());
// 把内容窗格转化为JPanel,否则不能用方法setOpaque()来使内容窗格透明
imagePanel = (JPanel) frame.getContentPane();
imagePanel.setOpaque(false);
// 内容窗格默认的布局管理器为BorderLayout
imagePanel.setLayout(new FlowLayout());
imagePanel.add(new JButton(“测试按钮”));
frame.getLayeredPane().setLayout(null);
// 把背景图片添加到分层窗格的最底层作为背景
frame.getLayeredPane().add(label, new Integer(Integer.MIN_VALUE));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(background.getIconWidth(), background.getIconHeight());
frame.setResizable(false);
frame.setVisible(true);
}
}
- 监听JFrame窗口大小改变的方法:
frame.addComponmentListener(new ComponentAdapter(){
@Override public void componentResized(ComponentEvent e){
// write you code here
}});
2. GridBagLayout(最难布局),需要配合GridBagConstraints使用:
-
gridx和gridy: 设置Component在网格中的横向和纵向位置。
-
gridwidth和gridheight:设置Component能在横向和纵向横跨多少个网格。
-
fill:控制Component如何填充网格的区域:
NONE、HORIZONTAL 、VERTICAL 、BOTH 。
-
ipadx和ipady:设置Component的内部填充大小,即在Component的最小大小上还需要加多少
-
insets:外部填充大小,类似于Border
-
weightx和weighty:设置在横向和纵向的占用比重。
当窗口大小改变的时候,可以使用这两个属性来控制Component随着窗口变化时,Component大小的变化比率。
两个属性的默认值为0,取值范围[0.0, 1.0]。
窗口大小变化时,比较同一行或者同一列中不同Component所对应的值的比值。
3. JButton
- 去掉外面那层样式,现在这个按钮就像文本一样:registeredAccountBtn.setContentAreaFilled(false);
4. JPasswordField
- 设置明文显示文字:passwordTextField.setEchoChar(‘\0’);
5. JTextField
- 当需要限制用户输入时,需要重写PlainDocument,还可以限制用户输入的长度.调用时,userNameTextField.setDocument(new MyRegExp(NAMEREGEX,20)); 这样调用即可.
public class MyRegExp extends PlainDocument{
/**
*/
private static final long serialVersionUID = 2851695051373575598L;
private Pattern pattern;
private Matcher m;
private int maxLength;
独家面经总结,超级精彩
本人面试腾讯,阿里,百度等企业总结下来的面试经历,都是真实的,分享给大家!
Java面试准备
准确的说这里又分为两部分:
- Java刷题
- 算法刷题
Java刷题:此份文档详细记录了千道面试题与详解;
g-X0SoN3F1-1714853362061)]
[外链图片转存中…(img-74J3apcR-1714853362062)]