📄 frame1.java~6~
字号:
package untitled1;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.net.*;import java.io.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: </p> * @author unascribed * @version 1.0 */public class Frame1 extends JFrame { JPanel contentPane; JTextField jTextField1 = new JTextField(); JLabel jLabel1 = new JLabel(); JLabel jLabel2 = new JLabel(); JLabel jLabel3 = new JLabel(); JLabel jLabel4 = new JLabel(); JButton jButton1 = new JButton(); URL myurl=null; //Construct the frame public Frame1() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]"))); contentPane = (JPanel) this.getContentPane(); jTextField1.setText("jTextField1"); jTextField1.setBounds(new Rectangle(58, 29, 260, 24)); contentPane.setLayout(null); this.setSize(new Dimension(400, 300)); this.setTitle("Frame Title"); jLabel1.setText("jLabel1"); jLabel1.setBounds(new Rectangle(76, 68, 219, 23)); jLabel2.setText("jLabel2"); jLabel2.setBounds(new Rectangle(75, 98, 222, 29)); jLabel3.setText("jLabel3"); jLabel3.setBounds(new Rectangle(72, 138, 237, 31)); jLabel4.setText("jLabel4"); jLabel4.setBounds(new Rectangle(70, 179, 247, 24)); jButton1.setBounds(new Rectangle(109, 233, 151, 48)); jButton1.setText("jButton1"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton1_actionPerformed(e); } }); contentPane.add(jTextField1, null); contentPane.add(jLabel1, null); contentPane.add(jLabel2, null); contentPane.add(jLabel3, null); contentPane.add(jLabel4, null); contentPane.add(jButton1, null); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } void jButton1_actionPerformed(ActionEvent e) { try { myurl=new URL(); URL(jTextField1.getText()); jLabel1.setText("Protocol="+myurl.getProtocol()); } catch(MalformedURLException e){ System.out.println("MalformedURLException:"+e); }}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -