⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 widthhack.java

📁 java swing 开发代码
💻 JAVA
字号:
// WidthHack.java// A hack to make a JTextField _really_ 2 columns wide//package	jswing.ch19;import javax.swing.*;public class WidthHack {  public static void main(String[] args) {    JTextField tf = new JTextField("mm");    tf.setPreferredSize( tf.getPreferredSize() );    tf.setText(""); // Empty the field.    JPanel pHacked = new JPanel();    pHacked.setBorder(new javax.swing.border.TitledBorder("hacked 2 columns"));    pHacked.add(tf);    JPanel pStock = new JPanel();    pStock.setBorder(new javax.swing.border.TitledBorder("stock 2 columns"));    pStock.add( new JTextField(2) );    JFrame frame = new JFrame();    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);    frame.getContentPane().setLayout(new java.awt.GridLayout(0, 1));    frame.getContentPane().add(pHacked);    frame.getContentPane().add(pStock);    frame.setSize(150, 150);    frame.setVisible(true);    tf.requestFocus();  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -