📄 frame1.java~27~
字号:
package com.hzcc.weather;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class Frame1 extends JFrame { JPanel contentPane; JLabel statusBar = new JLabel(); XYLayout xYLayout1 = new XYLayout(); JEditorPane jEditorPane1 = new JEditorPane(); JMenuBar jMenuBar1 = new JMenuBar(); JMenu jMenu1 = new JMenu(); JMenuItem jMenuItem1 = new JMenuItem(); JCheckBoxMenuItem jCheckBoxMenuItem1 = new JCheckBoxMenuItem(); JCheckBoxMenuItem jCheckBoxMenuItem2 = new JCheckBoxMenuItem(); JCheckBoxMenuItem jCheckBoxMenuItem3 = new JCheckBoxMenuItem(); JCheckBoxMenuItem jCheckBoxMenuItem4 = new JCheckBoxMenuItem(); //Construct the frame public Frame1() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(xYLayout1); this.setJMenuBar(jMenuBar1); this.setSize(new Dimension(674, 285)); this.setTitle("Get Weather"); statusBar.setText(" "); jEditorPane1.setText(""); jEditorPane1.setContentType("text/html"); jMenuItem1.setFont(new java.awt.Font("DialogInput", 0, 12)); jMenuItem1.setText(""); jMenu1.setFont(new java.awt.Font("DialogInput", 0, 12)); jMenu1.setText("天津"); jMenu1.addActionListener(new Frame1_jMenu1_actionAdapter(this)); jCheckBoxMenuItem1.setFont(new java.awt.Font("DialogInput", 0, 12)); jCheckBoxMenuItem1.setText("上海"); jCheckBoxMenuItem1.addActionListener(new Frame1_jCheckBoxMenuItem1_actionAdapter(this)); jCheckBoxMenuItem2.setFont(new java.awt.Font("DialogInput", 0, 12)); jCheckBoxMenuItem2.setText("杭州"); jCheckBoxMenuItem2.addActionListener(new Frame1_jCheckBoxMenuItem2_actionAdapter(this)); jCheckBoxMenuItem3.setFont(new java.awt.Font("DialogInput", 0, 12)); jCheckBoxMenuItem3.setText("南京"); jCheckBoxMenuItem3.addActionListener(new Frame1_jCheckBoxMenuItem3_actionAdapter(this)); jCheckBoxMenuItem4.setText("北京"); jCheckBoxMenuItem4.addActionListener(new Frame1_jCheckBoxMenuItem4_actionAdapter(this)); contentPane.add(jEditorPane1, new XYConstraints(0, 52, 675, 231)); contentPane.add(statusBar, new XYConstraints(-2, 286, 400, -1)); jMenuBar1.add(jMenu1); jMenu1.add(jCheckBoxMenuItem3); jMenu1.add(jCheckBoxMenuItem2); jMenu1.add(jCheckBoxMenuItem1); jMenu1.add(jCheckBoxMenuItem4); jMenu1.add(jMenuItem1); WeatherDialog wd = new WeatherDialog("杭州"); jEditorPane1.setContentType("text/html"); jEditorPane1.setText(wd.getWeather()); } //File | Exit action performed public void jMenuFileExit_actionPerformed(ActionEvent e) { System.exit(0); } //Help | About action performed public void jMenuHelpAbout_actionPerformed(ActionEvent e) { Frame1_AboutBox dlg = new Frame1_AboutBox(this); Dimension dlgSize = dlg.getPreferredSize(); Dimension frmSize = getSize(); Point loc = getLocation(); dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); dlg.setModal(true); dlg.pack(); dlg.show(); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { jMenuFileExit_actionPerformed(null); } } void jCheckBoxMenuItem4_actionPerformed(ActionEvent e) { WeatherDialog wd = new WeatherDialog(jCheckBoxMenuItem4.getText()); jEditorPane1.setContentType("text/html"); jEditorPane1.setText(wd.getWeather()); } void jCheckBoxMenuItem1_actionPerformed(ActionEvent e) { WeatherDialog wd = new WeatherDialog(jCheckBoxMenuItem1.getText()); jEditorPane1.setContentType("text/html"); jEditorPane1.setText(wd.getWeather()); } void jCheckBoxMenuItem2_actionPerformed(ActionEvent e) { WeatherDialog wd = new WeatherDialog(jCheckBoxMenuItem2.getText()); jEditorPane1.setContentType("text/html"); jEditorPane1.setText(wd.getWeather()); } void jCheckBoxMenuItem3_actionPerformed(ActionEvent e) { WeatherDialog wd = new WeatherDialog(jCheckBoxMenuItem3.getText()); jEditorPane1.setContentType("text/html"); jEditorPane1.setText(wd.getWeather()); } void jMenu1_actionPerformed(ActionEvent e) { WeatherDialog wd = new WeatherDialog("天津"); jEditorPane1.setContentType("text/html"); jEditorPane1.setText(wd.getWeather()); }}class Frame1_jCheckBoxMenuItem4_actionAdapter implements java.awt.event.ActionListener { Frame1 adaptee; Frame1_jCheckBoxMenuItem4_actionAdapter(Frame1 adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jCheckBoxMenuItem4_actionPerformed(e); }}class Frame1_jCheckBoxMenuItem1_actionAdapter implements java.awt.event.ActionListener { Frame1 adaptee; Frame1_jCheckBoxMenuItem1_actionAdapter(Frame1 adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jCheckBoxMenuItem1_actionPerformed(e); }}class Frame1_jCheckBoxMenuItem2_actionAdapter implements java.awt.event.ActionListener { Frame1 adaptee; Frame1_jCheckBoxMenuItem2_actionAdapter(Frame1 adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jCheckBoxMenuItem2_actionPerformed(e); }}class Frame1_jCheckBoxMenuItem3_actionAdapter implements java.awt.event.ActionListener { Frame1 adaptee; Frame1_jCheckBoxMenuItem3_actionAdapter(Frame1 adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jCheckBoxMenuItem3_actionPerformed(e); }}class Frame1_jMenu1_actionAdapter implements java.awt.event.ActionListener { Frame1 adaptee; Frame1_jMenu1_actionAdapter(Frame1 adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jMenu1_actionPerformed(e); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -