📄 intframeadaptdemo.java
字号:
import javax.swing.*;import javax.swing.event.*;import java.awt.*;import java.awt.event.*;public class IntFrameAdaptDemo extends JFrame implements ActionListener{ private JInternalFrame jif; private JTextField jtf; private JButton button; public IntFrameAdaptDemo() {/* A JInternalFrame object is created and placed on a JFrame. *//* The JInternalFrame registers an InternalFrameListener. */ jif = new JInternalFrame("Bailey", true, true, true, true); jif.getContentPane().add(new JLabel(new ImageIcon("Bailey.jpg"))); jif.setSize(200, 100); jif.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); jif.addInternalFrameListener(new InternalFrameHandler()); button = new JButton("show"); button.setBorder(BorderFactory.createRaisedBevelBorder()); button.addActionListener(this); jtf = new JTextField(20); jtf.setEditable(false); JPanel centerPanel = new JPanel(); centerPanel.add(jif); JPanel southPanel = new JPanel(); southPanel.add(jtf); southPanel.add(button); getContentPane().add(centerPanel, BorderLayout.CENTER); getContentPane().add(southPanel, BorderLayout.SOUTH); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 300, 300); setVisible(true); }/* The InternalFrameListener is implemented as an inner class that *//* extends the InternalFrameAdapter class. If the JInternalFrame *//* is iconified or de-inconified, an InternalFrameEvent is *//* generated and sent to the appropriate method where the iconified *//* state of the JInternalFrame is displayed in a JTextField. *//* Because the InternalFrameAdapter class is used, implementations *//* don't have to be provided for the methods declared in the *//* InternalFrameListener interface that aren't needed for this *//* example. */ class InternalFrameHandler extends InternalFrameAdapter { public void internalFrameDeiconified(InternalFrameEvent event) { jtf.setText("internal frame deiconified"); invalidate(); validate(); } public void internalFrameIconified(InternalFrameEvent event) { jtf.setText("internal frame iconified"); invalidate(); validate(); } }/* When the "show" button is pressed, the JInternalFrame is made *//* visible. */ public void actionPerformed(ActionEvent event) { jif.show(); } public static void main(String args[]) { IntFrameAdaptDemo demo = new IntFrameAdaptDemo(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -