`
jayliu
  • 浏览: 51211 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论
阅读更多

package test;


import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.MenuItem;
import java.awt.PopupMenu;
import java.awt.SystemTray;
import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.LinkedList;


import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JTabbedPane;
import javax.swing.JTextPane;
import javax.swing.JWindow;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;


public class MyFrame extends JFrame implements ActionListener {
private static final long serialVersionUID = 1026416994451303162L;
private static MyFrame mf = null;
private JTabbedPane jtp = new JTabbedPane();
private JWindow windowSplash;


public static MyFrame getInstance() {
if (mf == null)
mf = new MyFrame();
return mf;
}


public MyFrame() {
super("改变窗体测试");
prepareSplash();
this.startSplash();
init();
systemTray();
this.stopSplash();
}


private void init() {
jtp.add("天气", WeatherPanel.getInstance());
jtp.add("计算器",MyCalculator.getInstance());
jtp.add("万年历",MyCalendar.getInstance());
jtp.add("测试", TestWindow.getInstance());

//jtp.add("设置",SetCity.getInstance());
this.getContentPane().add(jtp, BorderLayout.CENTER);
jtp.getAccessibleContext().setAccessibleName("");
this.setSize(400, 350);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
int h = (int) d.getHeight() / 3;
int w = (int) d.getWidth() / 3;
this.setLocation(w, h);
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
LinkedList<Image> icon = new LinkedList<Image>();
try {
icon.add(new ImageIcon(new URL("http://weather.tq121.com.cn/images/sun.gif")).getImage());
} catch (MalformedURLException e1) {
e1.printStackTrace();
}
this.setIconImages(icon);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
MyFrame.getInstance().setVisible(false);
}
});
this.setVisible(true);
}


private void prepareSplash(){
Toolkit toolkit=Toolkit.getDefaultToolkit();
windowSplash=new JWindow(this);
windowSplash.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
Container container = windowSplash.getContentPane();
URL url = getClass().getResource("1.png"); // 图片的位置
if (url != null) {
container.add(new JLabel(new ImageIcon(url)), BorderLayout.CENTER); // 增加图片
}
JProgressBar progress=new JProgressBar();
progress.setVisible(true);
progress.setIndeterminate(true);
container.add(progress, BorderLayout.SOUTH);
Dimension scmSize = toolkit.getScreenSize();
windowSplash.setLocation(scmSize.width/2 , scmSize.height/2 );
windowSplash.pack();
}

private void startSplash(){
windowSplash.setVisible(true);
windowSplash.toFront();
}


private void stopSplash(){
windowSplash.dispose();
}



public void actionPerformed(ActionEvent e) {


}


public void systemTray() {
try {
if (SystemTray.isSupported()) {// 判断当前平台是否支持系统托盘
SystemTray st = SystemTray.getSystemTray();
Image image = Toolkit.getDefaultToolkit().getImage(
getClass().getResource("1.gif"));// 定义托盘图标的图片
TrayIcon ti = new TrayIcon(image);
ti.setToolTip("改变窗体测试");
ti.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1)// 鼠标左键单击,打开窗体
MyFrame.getInstance().setVisible(true);
MyFrame.getInstance().setExtendedState(JFrame.NORMAL);
}
});
PopupMenu p = new PopupMenu("OK");
MenuItem about = new MenuItem("关于");
about.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Thread t = new Thread(AboutUI.getInstance());
t.start();
AboutUI.getInstance().setVisible(true);
}
});
p.add(about);
p.addSeparator();
MenuItem m1 = new MenuItem("打开");
m1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MyFrame.getInstance().setVisible(true);
MyFrame.getInstance().setExtendedState(JFrame.NORMAL);
}
});
p.add(m1);
MenuItem m2 = new MenuItem("最大化");
m2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MyFrame.getInstance().setVisible(true);
MyFrame.getInstance().setExtendedState(
JFrame.MAXIMIZED_BOTH);
}
});
p.add(m2);
p.addSeparator();
MenuItem m = new MenuItem("退出");
m.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
p.add(m);
ti.setPopupMenu(p); // 为托盘添加右键菜单
st.add(ti);
}
} catch (Exception e) {


}


}


public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
// JFrame.setDefaultLookAndFeelDecorated(true);
MyFrame.getInstance();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
}
}


class AboutUI extends JDialog implements Runnable {
private static final long serialVersionUID = -6285085789330239239L;
private JTextPane messageText = new JTextPane();
ImageIcon icon = new ImageIcon("1.gif");


private AboutUI() {
// super(frame,true);
init();
}


private static AboutUI au;


public static AboutUI getInstance() {
if (au == null)
au = new AboutUI();
return au;
}


private void init() {
messageText.setFont(new Font("", Font.PLAIN, 12));
messageText.setBackground(Color.LIGHT_GRAY);
messageText.setText(" 作者:Bllows.Van\n Email(MSN):haidii@126.com\n QQ:417616683");
messageText.setEditable(false);
JPanel panel = new JPanel() {
private static final long serialVersionUID = 1L;
protected void paintComponent(Graphics g) {
g.drawImage(icon.getImage(), 0, 0, null);
super.paintComponent(g);
}
};
panel.setOpaque(false);
panel.setPreferredSize(new Dimension(10, 20));
this.setTitle("关于Billows窗体测试");
this.getContentPane().add(messageText, BorderLayout.CENTER);
this.getContentPane().add(panel, BorderLayout.NORTH);
this.setSize(new Dimension(200, 150));
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
this.pack();
}


public void run() {
while (true) {
this.repaint();
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
WeatherPanel.java

package test;


import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.regex.Pattern;


import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JTextField;


public class WeatherPanel extends JPanel implements ActionListener{
private static final long serialVersionUID = 1L;
private static WeatherPanel wp;
private Pattern cityP;
private JTextField jta=new JTextField(10);
private JButton button=new JButton("设定城市");
private JProgressBar loading_jpb=new JProgressBar();
private String city="上海";
private OpenUrl openUrl=new OpenUrl();
private Weather weather = null;

public static WeatherPanel getInstance(){
if(wp==null)
wp=new WeatherPanel();
return wp;
}

private WeatherPanel(){
jta.setText("上海");
init();
new Thread(){
public void run(){
//weather=openUrl.getWeatherByUrl("http://weather.tq121.com.cn/detail.php?city="+city);
weather=openUrl.getWeatherByUrl("D:\\aaa\\tomcat6\\webapps\\aaa\\detail.html");
WeatherPanel.getInstance().repaint();
}
}.start();
}

private void init(){
this.setOpaque(false);
JPanel south=new JPanel();
south.setLayout(new BorderLayout());
JPanel panel=new JPanel();
panel.add(jta);
jta.addKeyListener(new KeyAdapter(){
public void keyPressed(KeyEvent e) {
if(e.getKeyCode()==KeyEvent.VK_ENTER){
paintWeather();
}
}
});
panel.add(button);
south.add(panel,BorderLayout.SOUTH);
south.add(loading_jpb,BorderLayout.NORTH);
//button.addActionListener(this);
button.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e) {
paintWeather();
}
});
this.setLayout(new BorderLayout());
this.add(south,BorderLayout.SOUTH);
loading_jpb.setVisible(true);
loading_jpb.setIndeterminate(true);
}

protected void paintComponent(Graphics g){
int x=10,y=20;
if(weather==null){
// city="上海";
// weather = openUrl.getWeatherByUrl("http://weather.tq121.com.cn/detail.php?city="+city);
return;
}
g.drawString(weather.getCity()+":"+weather.getDate1(), x, y);
String weatherName1="";
String weatherName2="";
String legend1="";
String legend2="";
ImageIcon icon1=null,icon2=null;
Image img1=null,img2=null;
int t1=0;
if((t1=weather.getWeather1().indexOf("转"))!=-1){
weatherName1=weather.getWeather1().substring(0, t1);
weatherName2=weather.getWeather1().substring(t1+1, weather.getWeather1().length());
legend1="weather_legend/a"+openUrl.getWeatherNumber(weatherName1)+".gif";
legend2="weather_legend/a"+openUrl.getWeatherNumber(weatherName2)+".gif";
icon1=new ImageIcon(legend1);
icon2=new ImageIcon(legend2);
img1=icon1.getImage();
img2=icon2.getImage();
g.drawImage(img1, x, y+10, 60, 51,null);
g.drawImage(img2, x+58, y+10, 60, 51,null);
}else{
weatherName1=weather.getWeather1();
legend1="weather_legend/a"+openUrl.getWeatherNumber(weatherName1)+".gif";
icon1=new ImageIcon(legend1);
img1=icon1.getImage();
g.drawImage(img1, x+30, y+10, 60, 51, null);
}
g.drawString("天气:"+weather.getWeather1(), x, y+80);
g.drawString("气温:"+weather.getTemperature1(), x, y+80+25);
g.drawString("风力:"+weather.getWind1(), x, y+80+25+25);

g.drawLine(180, 20, 180, 180);
x+=190;
g.drawString(weather.getCity()+":"+weather.getDate2(), x, y);
String weatherName3="";
String weatherName4="";
String legend3="";
String legend4="";
ImageIcon icon3=null,icon4=null;
Image img3=null,img4=null;
int t2=0;
if((t2=weather.getWeather2().indexOf("转"))!=-1){
weatherName3=weather.getWeather2().substring(0, t2);
weatherName4=weather.getWeather2().substring(t2+1, weather.getWeather2().length());
legend3="weather_legend/a"+openUrl.getWeatherNumber(weatherName3)+".gif";
legend4="weather_legend/a"+openUrl.getWeatherNumber(weatherName4)+".gif";
icon3=new ImageIcon(legend3);
icon4=new ImageIcon(legend4);
img3=icon3.getImage();
img4=icon4.getImage();
g.drawImage(img3, x, y+10, 60, 51,null);
g.drawImage(img4, x+58, y+10, 60, 51,null);
}else{
weatherName3=weather.getWeather2();
legend3="weather_legend/a"+openUrl.getWeatherNumber(weatherName3)+".gif";
icon3=new ImageIcon(legend3);
img3=icon3.getImage();
g.drawImage(img3, x+30, y+10, 60, 51, null);
}
g.drawString("天气:"+weather.getWeather2(), x, y+80);
g.drawString("气温:"+weather.getTemperature2(), x, y+80+25);
g.drawString("风力:"+weather.getWind2(), x, y+80+25+25);
//super.paintComponent(g);
loading_jpb.setVisible(false);
jta.setEditable(true);
button.setEnabled(true);
}

/**
* 城市改变时,执行的操作
*/
private void paintWeather(){
cityP = Pattern.compile("[^\\d\\w\\p{Punct}]{2,10}");
city=jta.getText().trim();
if (cityP.matcher(city).matches()) {
jta.setEditable(false);
button.setEnabled(false);
loading_jpb.setVisible(true);
new Thread(){
public void run(){
weather = openUrl.getWeatherByUrl("http://weather.tq121.com.cn/detail.php?city="+city);
if(weather==null){
jta.setEditable(true);
button.setEnabled(true);
loading_jpb.setVisible(false);
return;
}
else{
WeatherPanel.getInstance().repaint();
}
}
}.start();
}else{
JOptionPane.showMessageDialog(WeatherPanel.getInstance(), "对不起,请输入正确的城市名!");
}
}


public void actionPerformed(ActionEvent e) {
String str=e.getActionCommand();
if(str.equals("设定城市")){
paintWeather();
}
}
}


WeatherPanel.java中用到OpenUrl.java和Weather.java,代码如下:
OpenUrl.java

package test;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


import javax.swing.JOptionPane;

public class OpenUrl {
String[] s1 = {"晴", "多云", "阴", "阵雨", "雷阵雨", "雷阵雨并伴有冰雹", "雨加雪", "小雨", "中雨", "大雨", "暴雨", "大暴雨", "特大暴雨", "阵雪", "小雪", "中雪", "大雪", "暴雪", "雾", "冻雨", "沙尘暴", "小雨-中雨", "中雨-大雨", "大雨-暴雨", "暴雨-大暴雨", "大暴雨-特大暴雨", "小雪-中雪", "中雪-大雪", "大雪-暴雪", "浮尘", "扬沙", "强沙尘暴"};
public static void main(String[] args){
OpenUrl openUrl = new OpenUrl();
Weather w = openUrl.getWeatherByUrl("http://weather.tq121.com.cn/detail.php?city=上海");
System.out.println(w.getCity());
System.out.println(w.getDate1());
System.out.println(w.getTemperature1());
System.out.println(w.getWeather1());
System.out.println(w.getWind1());

System.out.println(w.getDate2());
System.out.println(w.getTemperature2());
System.out.println(w.getWeather2());
System.out.println(w.getWind2());

System.out.println(w.getDate3());
System.out.println(w.getTemperature3());
System.out.println(w.getWeather3());
System.out.println(w.getWind3());

System.out.println(w.getDate4());
System.out.println(w.getTemperature4());
System.out.println(w.getWeather4());
System.out.println(w.getWind4());

System.out.println(w.getDate5());
System.out.println(w.getTemperature5());
System.out.println(w.getWeather5());
System.out.println(w.getWind5());

System.out.println(w.getUltravioletData());
System.out.println(w.getAirData());
}

/**
* 根据连接抓出5天天气
*/
public Weather getWeatherByUrl(String url){
Weather weather = new Weather();
try {
long l1 = System.currentTimeMillis();
String content = getContent(url);
weather = getCity(content , weather);
weather = getDateTemperature(content , weather);
weather = getWind3(content , weather);
weather = getWeather3(content , weather);
weather = getDate(content , weather);
weather = getTemperature(content , weather);
weather = getWind2(content , weather);
weather = getWeather2(content , weather);
weather = this.getAirData(content, weather);
long l2 = System.currentTimeMillis();
System.out.println("获取天气信息所用时间为:"+(l2 - l1)+" 毫秒");
}catch (Exception e){
JOptionPane.showMessageDialog(WeatherPanel.getInstance(), "对不起,请输入正确的城市名!");
return null;
}
return weather;
}

/**
* 根据连接地址抓出页面内容
* @param 根据一个连接地址
* @return 页面内容
*/
private String getContent(String strUrl){
try{
URL url = new URL(strUrl);
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
String s = "";
StringBuffer sb=new StringBuffer();
while((s = br.readLine())!=null){
sb.append(s+"\r\n");
}
br.close();
return sb.toString();
}catch(Exception e){
System.out.println("打开地址:" + strUrl+" 失败!");
return "打开地址失败:" + strUrl;
}
}

/**
* 抓取城市名称
* @param content
* @param weather
* @return
* @throws Exception
*/
private Weather getCity(String content , Weather weather) throws Exception{
String[] s = analysis(" <td width=\"222\" class=\"big-cn\">(.*?)</td>", content , 1);
weather.setCity(s[0].trim());
return weather;
}

/**
* 取当前3天内的温度和时间 <br>
* 返回一个天气bean <br>
* 0和1 2个参数为第一天时间和温度 后面相同 <br>
* content 为页面内容
* weather 为天气bean
*/
private Weather getDateTemperature(String content , Weather weather) throws Exception{
String[] s = analysis("<td width=\"215\" align=\"center\" valign=\"middle\"><span class=\"big-cn\">(.*?)</span></td>", content , 6);
weather.setDate1(s[0].trim());
weather.setTemperature1(s[1].trim());
weather.setDate2(s[2].trim());
weather.setTemperature2(s[3].trim());
weather.setDate3(s[4].trim());
weather.setTemperature3(s[5].trim());
return weather;
}

/**
* 取前3天的风向
* content 为页面内容
* weather 为天气bean
*/
private Weather getWind3(String content , Weather weather){
String[] s = analysis("<td width=\"215\" align=\"center\" valign=\"middle\"><span class=\"cn\">(.*?)</span></td>", content , 3);
weather.setWind1(s[0].trim());
weather.setWind2(s[1].trim());
weather.setWind3(s[2].trim());
return weather;
}

/**
* 取前3天的天气情况
* content 为页面内容
* weather 为天气bean
*/
private Weather getWeather3(String content , Weather weather){
String[] s = analysis("align=\"center\" valign=\"top\"><img src=\"../images/a(.*?).gif\" width=\"70\" height=\"65\"></td>" , content , 6);
s = ConversionWeather(s);
weather.setWeather1(s[0]);
weather.setWeather2(s[1]);
weather.setWeather3(s[2]);
return weather;
}

/**
* 取后2天的日期
*/
private Weather getDate(String content , Weather weather){
String[] s = analysis("<td width=\"121\"><span class=\"cn\">(.*?)</span></td>" , content , 2);
weather.setDate4(s[0].trim());
weather.setDate5(s[1].trim());
return weather;
}

/**
* 取后天2天的温度
*/
private Weather getTemperature(String content , Weather weather){
String[] s = analysis("<td width=\"86\" class=\"cn\"><span class=\"wendu\">(.*?)</span></td>" , content , 2);
weather.setTemperature4(s[0].trim());
weather.setTemperature5(s[1].trim());
return weather;
}

/**
* 取后天2天的风向
*/
private Weather getWind2(String content , Weather weather){
String[] s = analysis("<td width=\"157\"><span class=\"cn\">(.*?)</span></td>" , content , 2);
weather.setWind4(s[0].trim());
weather.setWind5(s[1].trim());
return weather;
}

/**
*
*/
private Weather getWeather2(String content , Weather weather){
String[] s = analysis("<img src=\"../images/b(.*?).gif\" width=\"50\" height=\"46\"></td>" , content , 4);
s = ConversionWeather(s);
weather.setWeather4(s[0]);
weather.setWeather5(s[1]);
return weather;
}

/**
* 获取紫外线指数和空气净化指数
*/
private Weather getAirData(String content , Weather weather){
String[] s=analysis("<td width=\"87\" align=\"left\" valign=\"middle\" class=\"cn\">(.*?)</td>",content,19);
String[] s1=analysis("<td width=\"120\" align=\"left\" class=\"cn\">(.*?)</td>",content,16);
weather.setUltravioletData(s[7]+":"+s1[6]);
weather.setAirData(s[8]+":"+s1[7]);
return weather;
}


/**
* 根据页面内容和正则表达式来分析页面,得到分析结果
* @param pattern 正则表达式
* @param match 页面内容
* @return content 结果
*/
private String[] analysis(String pattern, String match , int i){
Pattern sp = Pattern.compile(pattern);
Matcher matcher = sp.matcher(match);
String[] content = new String[i];
for (int j = 0; matcher.find(); j++){
content[j] = matcher.group(1);
}
return content;
}

/**
* 转换天气情况
* @param s第1张图片
* @return 天气情况
*/
private String[] ConversionWeather(String s[]){
String[] s2 = new String[s.length/2];
int i1 = 0;
for (int i = 0; i < s.length; i += 2){
if (s[i].trim().equals(s[i+1].trim())){
s2[i1] = s1[Integer.parseInt(s[i])];
}else {
s2[i1] = s1[Integer.parseInt(s[i])] + "转" + s1[Integer.parseInt(s[i+1])];
}
i1++;
}
return s2;
}

public int getWeatherNumber(String weatherName){
int t=0;
for(int i=0;i<s1.length;i++){
if(weatherName.equals(s1[i])){
t=i;
break;
}
}
return t;
}
}


Weather.java:

package test;

public class Weather {
// 第1天时间
private String date1;

// 第1天温度
private String temperature1;

// 第1天天气情况
private String weather1;

// 第1天风向
private String wind1;

// 第2天时间
private String date2;

// 第2天温度
private String temperature2;

// 第2天天气情况
private String weather2;

// 第2天风向
private String wind2;

// 第3天时间
private String date3;

// 第3天温度
private String temperature3;

// 第3天天气情况
private String weather3;

// 第3天风向
private String wind3;

// 第4天时间
private String date4;

// 第4天温度
private String temperature4;

// 第4天天气情况
private String weather4;

// 第4天风向
private String wind4;

// 第5天时间
private String date5;

// 第5天温度
private String temperature5;

// 第5天天气情况
private String weather5;

// 第5天风向
private String wind5;

// 紫外线指数
private String ultravioletData;

// 空气净化指数
private String airData;
private String city;

public String getCity() {
return city.trim().replace(">", ".").replace(" ", "");
}

public void setCity(String city) {
this.city = city;
}

public String getDate1() {
return date1;
}

public void setDate1(String date1) {
this.date1 = date1;
}

public String getDate2() {
return date2;
}

public void setDate2(String date2) {
this.date2 = date2;
}

public String getDate3() {
return date3;
}

public void setDate3(String date3) {
this.date3 = date3;
}

public String getDate4() {
return date4;
}

public void setDate4(String date4) {
this.date4 = date4;
}

public String getDate5() {
return date5;
}

public void setDate5(String date5) {
this.date5 = date5;
}

public String getTemperature1() {
return temperature1;
}

public void setTemperature1(String temperature1) {
this.temperature1 = temperature1;
}

public String getTemperature2() {
return temperature2;
}

public void setTemperature2(String temperature2) {
this.temperature2 = temperature2;
}

public String getTemperature3() {
return temperature3;
}

public void setTemperature3(String temperature3) {
this.temperature3 = temperature3;
}

public String getTemperature4() {
return temperature4;
}

public void setTemperature4(String temperature4) {
this.temperature4 = temperature4;
}

public String getTemperature5() {
return temperature5;
}

public void setTemperature5(String temperature5) {
this.temperature5 = temperature5;
}

public String getWeather1() {
return weather1;
}

public void setWeather1(String weather1) {
this.weather1 = weather1;
}

public String getWeather2() {
return weather2;
}

public void setWeather2(String weather2) {
this.weather2 = weather2;
}

public String getWeather3() {
return weather3;
}

public void setWeather3(String weather3) {
this.weather3 = weather3;
}

public String getWeather4() {
return weather4;
}

public void setWeather4(String weather4) {
this.weather4 = weather4;
}

public String getWeather5() {
return weather5;
}

public void setWeather5(String weather5) {
this.weather5 = weather5;
}

public String getWind1() {
return wind1;
}

public void setWind1(String wind1) {
this.wind1 = wind1;
}

public String getWind2() {
return wind2;
}

public void setWind2(String wind2) {
this.wind2 = wind2;
}

public String getWind3() {
return wind3;
}

public void setWind3(String wind3) {
this.wind3 = wind3;
}

public String getWind4() {
return wind4;
}

public void setWind4(String wind4) {
this.wind4 = wind4;
}

public String getWind5() {
return wind5;
}

public void setWind5(String wind5) {
this.wind5 = wind5;
}

public String getUltravioletData() {
return ultravioletData;
}

public void setUltravioletData(String ultravioletData) {
this.ultravioletData = ultravioletData;
}

public String getAirData() {
return airData;
}

public void setAirData(String airData) {
this.airData = airData;
}
}

MyCalculator.java(计算器的代码)

package test;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.math.BigDecimal;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;


public class MyCalculator extends JPanel implements ActionListener{
private static final long serialVersionUID = 1L;
private JButton[] jbs;
private JTextField jta;
private JLabel label;
private double firstNum,secondNum,res;
private String operator;
private static MyCalculator mc;

public static MyCalculator getInstance(){
if(mc==null)
mc=new MyCalculator();
return mc;
}

private MyCalculator(){
//super("我的计算器v1.0");
jbs=new JButton[20];
jta=new JTextField(20);
jta.setHorizontalAlignment(JTextField.RIGHT);
label=new JLabel("算式提示:");
firstNum=0;
secondNum=0;
operator="";

init();
addActionHandle();
}

public void init(){
JPanel north=new JPanel();
JPanel center=new JPanel();

this.setLayout(new BorderLayout());

north.setLayout(new BorderLayout());
center.setLayout(new GridLayout(5,4));

jta.setFont(new Font("",Font.BOLD,18));
jta.setEditable(false);
label.setForeground(Color.BLUE);
north.add(jta,BorderLayout.CENTER);
north.add(label,BorderLayout.SOUTH);

jbs[0]=new JButton("sqrt");
jbs[1]=new JButton("1/x");
jbs[2]=new JButton("+/-");
jbs[3]=new JButton("清零");
String str="123+456-789*0.=/";
for(int i=4;i<jbs.length;i++){
jbs[i]=new JButton(str.charAt(i-4)+"");
}
for(int i=0;i<jbs.length;i++)
center.add(jbs[i]);

this.add(north,BorderLayout.NORTH);
this.add(center,BorderLayout.CENTER);
}

public void showMe(){
//this.pack();
this.setVisible(true);
//this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

public void addActionHandle(){
for(int i=0;i<jbs.length;i++){
jbs[i].addActionListener(this);
}
}

String la="算式提示:";
public void actionPerformed(ActionEvent e) {
String str=e.getActionCommand();
if(!str.equals("sqrt") && !str.equals("1/x") && !str.equals("+/-") && !str.equals("清零") )
la+=str;

if(operator.equals("=")){
operator="";
firstNum=0;
secondNum=0;
jta.setText("");
}

if("0123456789.".indexOf(str) != -1){
jta.setText(jta.getText()+str);
label.setText(la);
}
if("+-*/".indexOf(str) != -1){
operator=str;
try {
firstNum=Double.valueOf(jta.getText());
jta.setText("");
label.setText(la);
} catch (NumberFormatException e1) {
JOptionPane.showMessageDialog(WeatherPanel.getInstance(), "对不起,转换出错。\n"+e1.getMessage());
}
}
if(str.equals("=")){
secondNum=Double.valueOf(jta.getText());
double s=cal(firstNum,secondNum);
String result=takeOut0(firstNum)+operator+takeOut0(secondNum)+"="+takeOut0(s);
jta.setText(takeOut0(s));
label.setText("算式提示:"+result);

operator="=";
firstNum=0;
secondNum=0;
la="算式提示:";
}

if(str.equals("清零")){
operator="";
firstNum=0;
secondNum=0;
jta.setText("");
la="算式提示:";
label.setText(la);
}

if(str.equals("1/x")){
try {
Double s=Double.parseDouble(jta.getText());
String st=String.valueOf(1/s);
if(st.equals("Infinity"))
throw new NumberFormatException("该数没有倒数....");
jta.setText(takeOut0(1/s));
} catch (NumberFormatException e1) {
JOptionPane.showMessageDialog(WeatherPanel.getInstance(), "对不起,运算出错。\n"+e1.getMessage());
}
}

if(str.equals("sqrt")){
try {
Double s=Double.parseDouble(jta.getText());
String st=String.valueOf(Math.sqrt(s));
if(st.equals("NaN"))
throw new NumberFormatException("该数不能开根号....");
jta.setText(takeOut0(Math.sqrt(s)));
} catch (NumberFormatException e1) {
JOptionPane.showMessageDialog(WeatherPanel.getInstance(), "对不起,运算出错。\n"+e1.getMessage());
}
}

if(str.equals("+/-")){
try {
Double s=Double.parseDouble(jta.getText());
jta.setText(takeOut0(-s));
} catch (NumberFormatException e1) {
JOptionPane.showMessageDialog(WeatherPanel.getInstance(), "对不起,转换出错。\n"+e1.getMessage());
}
}

}

private String takeOut0(double d){
String s=d+"";
if(s.endsWith(".0"))
s=s.substring(0, s.indexOf(".0"));
return s;
}
private double cal(double f,double s){
BigDecimal b1 = new BigDecimal(Double.toString(f));
BigDecimal b2 = new BigDecimal(Double.toString(s));
res=0;
if(operator.equals("+")){
res=b1.add(b2).doubleValue();
}
if(operator.equals("-")){
res=b1.subtract(b2).doubleValue();
}
if(operator.equals("*")){
res=b1.multiply(b2).doubleValue();
}
if(operator.equals("/")){
res=f/s;
}
return res;
}

public static void main(String[] args) {
new MyCalculator().showMe();
System.out.println(">>>>>>>>>>>>");
}

}

MyCalendar.java(万年历)

package test;

import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

class MyCalendar extends JPanel {
private static final long serialVersionUID = 1L;
private JPanel panel = new JPanel(new BorderLayout());
private JPanel panel1 = new JPanel();
private JPanel panel2 = new JPanel(new GridLayout(7, 7));
private JPanel panel3 = new JPanel();
private JButton[] button = new JButton[49];
private JLabel y_label = new JLabel("年份");
private JLabel m_label = new JLabel("月份");
private JComboBox com1 = new JComboBox();
private JComboBox com2 = new JComboBox();
private int re_year, re_month;
private int x_size, y_size;
private String year_num;
private Calendar now = Calendar.getInstance(); // 实例化Calendar
private static MyCalendar mf;

public static MyCalendar getInstance(){
if(mf==null)
mf=new MyCalendar();
return mf;
}

private MyCalendar() {
// super("万年历");
setSize(350, 350);
x_size = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth());
y_size = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight());
setLocation((x_size - 300) / 2, (y_size - 350) / 2);
// setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panel1.add(y_label);
panel1.add(com1);
panel1.add(m_label);
panel1.add(com2);
for (int i = 0; i < 49; i++) {
button[i] = new JButton("");// 将显示的字符设置为居中
button[i].setBackground(new Color(211,233,243));
panel2.add(button[i]);
}
panel.add(panel1, BorderLayout.NORTH);
panel.add(panel2, BorderLayout.CENTER);
panel.add(panel3, BorderLayout.SOUTH);
Init();
com1.addActionListener(new ClockAction());
com2.addActionListener(new ClockAction());

//setContentPane(panel);
this.add(panel);
setVisible(true);
//setResizable(false);
}

class ClockAction implements ActionListener {
public void actionPerformed(ActionEvent arg0) {
int c_year, c_month, c_week;
c_year = Integer.parseInt(com1.getSelectedItem().toString()); // 得到当前所选年份
c_month = Integer.parseInt(com2.getSelectedItem().toString()) - 1; // 得到当前月份,并减1,计算机中的月为0-11
c_week = use(c_year, c_month); // 调用函数use,得到星期几
Resetday(c_week, c_year, c_month); // 调用函数Resetday
}
}

public void Init() {
Integer year, month_num, first_day_num;
String log[] = { "日", "一", "二", "三", "四", "五", "六" };
for (int i = 0; i < 7; i++) {
button[i].setBackground(new Color(39,109,143));
if(i==0 || i==6){
button[i].setBackground(new Color(255,102,0));
button[i].setForeground(new Color(255,255,255));
button[i].setFont(new Font("",Font.BOLD,14));
}
button[i].setText(log[i]);
}
for (int i = 7; i < 49; i = i + 7) {
button[i].setFont(new Font("",Font.BOLD,18));
button[i].setForeground(new Color(255,102,0)); // 将星期日的日期设置为红色
}
for (int i = 13; i < 49; i = i + 7) {
button[i].setFont(new Font("",Font.BOLD,18));
button[i].setForeground(new Color(255,102,0));// 将星期六的日期设置为绿色
}
for (int i = 1900; i < 2100; i++) {
com1.addItem("" + i);
}
for (int i = 1; i < 13; i++) {
com2.addItem("" + i);
}
month_num = (Integer) (now.get(Calendar.MONTH)); // 得到当前时间的月份
year = (Integer) (now.get(Calendar.YEAR)); // 得到当前时间的年份
com1.setSelectedIndex(year - 1900); // 设置下拉列表显示为当前年
com2.setSelectedIndex(month_num); // 设置下拉列表显示为当前月
first_day_num = use(year, month_num);
Resetday(first_day_num, year, month_num);
}

public int use(int reyear, int remonth) {
int week_num;
now.set(reyear, remonth, 1); // 设置时间为所要查询的年月的第一天
week_num = (int) (now.get(Calendar.DAY_OF_WEEK));// 得到第一天的星期
return week_num;
}

@SuppressWarnings("deprecation")
public void Resetday(int week_log, int year_log, int month_log) {
int month_day_score; // 存储月份的天数
int count;
month_day_score = 0;
count = 1;

Date date = new Date(year_log, month_log + 1, 1); // now
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.MONTH, -1); // 前个月
month_day_score = cal.getActualMaximum(Calendar.DAY_OF_MONTH);// 最后一天

for (int i = 7; i < 49; i++) { // 初始化按钮
button[i].setText("");
}
week_log = week_log + 6; // 将星期数加6,使显示正确
month_day_score = month_day_score + week_log;
for (int i = week_log; i < month_day_score; i++, count++) {
button[i].setText(count+"");
now.set(Calendar.DAY_OF_MONTH, count);
Lunar lunar = new Lunar(now);
button[i].setToolTipText(lunar.toString());
}
}

public static void main(String[] args) {
//JFrame.setDefaultLookAndFeelDecorated(true);
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
new MyCalendar();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

Lunar.java

package test;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Lunar {
private int gyear;
private int gmonth;
private int gday;
private static int year;
private int month;
private int day;
private boolean leap;
final static String chineseNumber[] = {"一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"};
static SimpleDateFormat chineseDateFormat = new SimpleDateFormat("yyyy年MM月dd日");
final static long[] lunarInfo = new long[]
{0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2,
0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0, 0x14977,
0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970,
0x06566, 0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3, 0x092e0, 0x1c8d7, 0x0c950,
0x0d4a0, 0x1d8a6, 0x0b550, 0x056a0, 0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950, 0x0b557,
0x06ca0, 0x0b550, 0x15355, 0x04da0, 0x0a5d0, 0x14573, 0x052d0, 0x0a9a8, 0x0e950, 0x06aa0,
0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, 0x0f263, 0x0d950, 0x05b57, 0x056a0,
0x096d0, 0x04dd5, 0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b5a0, 0x195a6,
0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570,
0x04af5, 0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x055c0, 0x0ab60, 0x096d5, 0x092e0,
0x0c960, 0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0, 0x0cab5,
0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9, 0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930,
0x07954, 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0, 0x0d260, 0x0ea65, 0x0d530,
0x05aa0, 0x076a3, 0x096d0, 0x04bd7, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520, 0x0dd45,
0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0};

//====== 传回农历 y年的总天数
final private static int yearDays(int y) {
int i, sum = 348;
for (i = 0x8000; i > 0x8; i >>= 1) {
if ((lunarInfo[y - 1900] & i) != 0) sum += 1;
}
return (sum + leapDays(y));
}

//====== 传回农历 y年闰月的天数
final private static int leapDays(int y) {
if (leapMonth(y) != 0) {
if ((lunarInfo[y - 1900] & 0x10000) != 0)
return 30;
else
return 29;
} else
return 0;
}

//====== 传回农历 y年闰哪个月 1-12 , 没闰传回 0
final private static int leapMonth(int y) {
return (int) (lunarInfo[y - 1900] & 0xf);
}

//====== 传回农历 y年m月的总天数
final private static int monthDays(int y, int m) {
if ((lunarInfo[y - 1900] & (0x10000 >> m)) == 0)
return 29;
else
return 30;
}

//====== 传回农历 y年的生肖
final public String animalsYear() {
final String[] Animals = new String[]{"鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"};
return Animals[(year - 4) % 12];
}

//====== 传入 月日的offset 传回干支, 0=甲子
final private static String cyclicalm(int num) {
final String[] Gan = new String[]{"甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"};
final String[] Zhi = new String[]{"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"};
return (Gan[num % 10] + Zhi[num % 12]);
}

//====== 传入 offset 传回干支, 0=甲子
final public String cyclical() {
int num = year - 1900 + 36;
return (cyclicalm(num));
}

/** *//**
* 传出y年m月d日对应的农历.
* yearCyl3:农历年与1864的相差数 ?
* monCyl4:从1900年1月31日以来,闰月数
* dayCyl5:与1900年1月31日相差的天数,再加40 ?
* @param cal
* @return
*/
public Lunar(Calendar cal) {
@SuppressWarnings("unused") int yearCyl, monCyl, dayCyl;
int leapMonth = 0;
Date baseDate = null;
gyear=cal.get(Calendar.YEAR);
gmonth=cal.get(Calendar.MONTH);
gday=cal.get(Calendar.DAY_OF_MONTH);
try {
baseDate = chineseDateFormat.parse("1900年1月31日");
} catch (ParseException e) {
e.printStackTrace(); //To change body of catch statement use Options | File Templates.
}

//求出和1900年1月31日相差的天数
int offset = (int) ((cal.getTime().getTime() - baseDate.getTime()) / 86400000L);
dayCyl = offset + 40;
monCyl = 14;

//用offset减去每农历年的天数
// 计算当天是农历第几天
//i最终结果是农历的年份
//offset是当年的第几天
int iYear, daysOfYear = 0;
for (iYear = 1900; iYear < 2050 && offset > 0; iYear++) {
daysOfYear = yearDays(iYear);
offset -= daysOfYear;
monCyl += 12;
}
if (offset < 0) {
offset += daysOfYear;
iYear--;
monCyl -= 12;
}
//农历年份
year = iYear;

yearCyl = iYear - 1864;
leapMonth = leapMonth(iYear); //闰哪个月,1-12
leap = false;

//用当年的天数offset,逐个减去每月(农历)的天数,求出当天是本月的第几天
int iMonth, daysOfMonth = 0;
for (iMonth = 1; iMonth < 13 && offset > 0; iMonth++) {
//闰月
if (leapMonth > 0 && iMonth == (leapMonth + 1) && !leap) {
--iMonth;
leap = true;
daysOfMonth = leapDays(year);
} else
daysOfMonth = monthDays(year, iMonth);

offset -= daysOfMonth;
//解除闰月
if (leap && iMonth == (leapMonth + 1)) leap = false;
if (!leap) monCyl++;
}
//offset为0时,并且刚才计算的月份是闰月,要校正
if (offset == 0 && leapMonth > 0 && iMonth == leapMonth + 1) {
if (leap) {
leap = false;
} else {
leap = true;
--iMonth;
--monCyl;
}
}
//offset小于0时,也要校正
if (offset < 0) {
offset += daysOfMonth;
--iMonth;
--monCyl;
}
month = iMonth;
day = offset + 1;
}

public static String getChinaDayString(int day) {
String chineseTen[] = {"初", "十", "廿", "卅"};
int n = day % 10 == 0 ? 9 : day % 10 - 1;
if (day > 30)
return "";
if (day == 10)
return "初十";
else
return chineseTen[day / 10] + chineseNumber[n];
}

public static String getChinaYearString(int day) {
String[] y=new String[]{"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
String yy=year+"";
String rety="";
for(int i=0;i<yy.length();i++){
rety+=y[Integer.parseInt(yy.charAt(i)+"")];
}
return rety;
}

public String toString() {
return "<html><b>详细信息</b>:<br>" +
"<b>公历:</b>"+gyear+" 年 "+addZero(gmonth+1)+" 月 "+addZero(gday)+" 日<br>"+
"<b>农历:</b>"+year+" 年 "+(leap ? "闰" : "")+addZero(month)+" 月 "+addZero(day)+ " 日<br>"+
cyclical()+ "年【"+animalsYear()+"】<br>";
}

private String addZero(int i){
String ret="";
if(i<10)
ret="0"+i;
else
ret=""+i;
return ret;
}

public static void main(String[] args) throws ParseException {
Calendar today = Calendar.getInstance();
// today.setTime(chineseDateFormat.parse("2009年10月1日"));
Lunar lunar = new Lunar(today);
System.out.println("北京时间:" + chineseDateFormat.format(today.getTime()) + " " + lunar+lunar.cyclical());
}
}

最后,TestWindow.java

package test;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class TestWindow extends JPanel implements ActionListener {
private JButton jb1 = new JButton("最大化");
private JButton jb2 = new JButton("最小化");
private JButton jb3 = new JButton("正常");
private static TestWindow tw;

public static TestWindow getInstance(){
if(tw==null)
tw=new TestWindow();
return tw;
}

private TestWindow(){
this.setLayout(new BorderLayout());
this.add(jb1, BorderLayout.NORTH);
this.add(jb2, BorderLayout.SOUTH);
this.add(jb3, BorderLayout.CENTER);
jb1.addActionListener(this);
jb2.addActionListener(this);
jb3.addActionListener(this);

}


public void actionPerformed(ActionEvent e) {
String str = e.getActionCommand();
if (str.equals("最大化")) {
MyFrame.getInstance().setExtendedState(JFrame.MAXIMIZED_BOTH);
}
if (str.equals("最小化")) {
MyFrame.getInstance().setExtendedState(JFrame.ICONIFIED);
}
if (str.equals("正常")) {
MyFrame.getInstance().setExtendedState(JFrame.NORMAL);
}
}
}

分享到:
评论

相关推荐

    Java网络编程第三版.pdf

    《Java网络编程第三版》是Java开发者深入理解网络编程的重要参考资料。这本书主要涵盖了Java平台上的网络应用程序开发,从基础概念到高级技术,为读者提供了一套全面的学习路径。以下是本书中涉及的一些关键知识点:...

    Windows网络编程.pdf

    Windows 网络编程 概述 Windows 网络编程是指在 Windows 操作系统平台上进行网络编程的技术,涉及到 Windows Socket、网络协议、网络应用程序的开发等方面。 Windows 网络编程的主要目的是实现高性能的网络应用...

    TCP IP网络编程

    扫描版 超清百度网盘资源!!! 为初学者准备的网络编程! 韩国TCP/IP经典教程!... 本书针对网络编程初学者,面向具备C语言基础的套接字网络编程学习者,适合所有希望学习Linux和Windows网络编程的人。

    C++网络编程文档

    C++网络编程是计算机科学中的一个重要领域,它允许开发者创建能够通过网络进行通信的应用程序。这份"C++网络编程文档"涵盖了这一主题的广泛内容,旨在帮助程序员深入理解并掌握网络编程的基本概念和技术。 首先,...

    c#网络编程实例教程源代码

    《C#网络编程实例教程源代码》是一份深入浅出的教学资源,旨在帮助开发者掌握C#语言在网络编程领域的应用。这份教程结合了理论与实践,提供了丰富的源代码示例,让学习者能够通过实际操作来理解和掌握网络编程的核心...

    Linux网络编程教程pdf完整版

    《Linux网络编程教程》这本书是Linux系统中进行网络编程的重要参考资料。它涵盖了广泛的知识点,旨在帮助读者理解和掌握如何在Linux环境下开发网络应用程序。以下是对这些主题的详细阐述: 1. **网络编程基础**:...

    java网络编程第四版pdf

    《Java网络编程(第四版)》是一本深入探讨Java在互联网环境下的编程技术的经典书籍。本书旨在帮助读者理解和掌握如何利用Java语言进行高效、安全的网络通信。书中内容覆盖了从基本的网络概念到复杂的多线程编程,是...

    c++网络编程实例.pdf

    C++ 网络编程实例 本文档提供了 C++ 网络编程的基础知识,涵盖了网络编程的概述、OSI 七层网络模型、TCP/IP 协议和 C/S 编程模型等内容。 网络编程概述 网络编程是指用户使用 MFC 类库在 VC 编译器中编写程序,以...

    Linux网络编程,包括tcp/upd,select/poll/epoll/pdf

    linux网络编程 pdf # Linux网络编程基础 Linux网络编程是指在Linux操作系统上开发网络应用程序的过程。它主要涉及到TCP/UDP协议以及select/poll/epoll等多路复用技术。 TCP/UDP协议是网络通信的基础,其中TCP协议...

    Java网络编程(第4版)PDF

    《Java网络编程(第4版)》是一本深入探讨Java平台上的网络编程技术的专业书籍,适合想要提升Java通讯技术的学者阅读。此书全面覆盖了Java网络编程的基础和高级概念,帮助开发者理解如何利用Java语言构建高效、可靠的...

    Visual C++网络编程案例实战.pdf

    《Visual C++网络编程案例实战》一书深入探讨了如何利用Visual C++及MFC类库进行网络编程,尤其强调了Windows Socket的应用。本书不仅覆盖了理论基础,还提供了丰富的实践案例,帮助读者掌握网络编程的核心技能。 #...

    Java网络编程实验报告.pdf

    "Java网络编程实验报告" 本实验报告主要介绍了Java网络编程的基本概念和实现方法,通过设计和实现一个简单的客户端/服务器应用程序,了解Java网络编程的基本原理和实现方法。 知识点1:Java 网络编程基础 Java ...

    Java网络编程案例教程习题参考答案 .pdf

    Java网络编程案例教程习题参考答案 Java_network_programming是Java编程语言中一个基础组件,用于实现网络通信。以下是Java网络编程案例教程习题参考答案中涉及到的知识点: 1. Socket编程:Socket是Java网络编程...

    unix网络编程三卷合一中文版

    《Unix网络编程》是一套由美国著名计算机科学家W. Richard Stevens撰写的经典教材,涵盖了Unix系统下的网络编程各个方面。这套书共分为三卷,每卷都深入探讨了其主题,对于理解和掌握网络编程技术具有极高的参考价值...

    UNIX网络编程第1卷(1-19章)

    《UNIX网络编程》第一卷主要涵盖了网络编程的基本概念、传输层协议TCP和UDP的细节、套接口编程的原理与应用,以及高级网络编程技术。该书是网络编程领域的经典之作,作者是著名的网络编程专家W. Richard Stevens。...

    IT公司笔试\linux c网络网络编程面试题收集

    Linux C 网络编程面试题收集 本文总结了 Linux C 网络编程面试题,涵盖了基础知识、网络编程、路由等方面的知识点,旨在帮助读者更好地理解和掌握相关知识。 一、基础知识 1. 对于程序 `func(char *str){printf(...

    C#网络编程高级篇之网页游戏辅助程序设计.part3_C#_网络编程_

    这本书是关于c#网络编程的,关于c#入门的书有很多,但是关于c#网络编程的并不多,很多教材中虽有涉及网络编程但都是泛泛而谈,很多理论概念掺杂在其中,让人很难理解,而这本不同,含有非常多的例子,从简到深,甚至...

    Unix 网络编程 卷1 第三版 源代码

    《UNIX网络编程》(第1卷)(套接口API第3版)第1版和第2版由已故UNIX网络专家W. Richard Stevens博士独自编写。《UNIX网络编程》(第1卷)(套接口API第3版)是3版,由世界著名网络专家Bill Fenner和Andrew M. Rudoff执笔,...

    UNIX环境高级编程+UNIX网络编程卷1.PDF版

    《UNIX环境高级编程》与《UNIX网络编程卷1:协议》是两本深入解析UNIX系统编程的经典著作。在深入理解这些书籍的知识点之前,我们先要了解UNIX系统的基础概念。 UNIX是一个多用户、多任务的操作系统,其设计哲学...

    网络编程实用教程(程序源代码).zip

    全书分为10章,第1章介绍网络编程的基本概念及模式,第2章介绍套接字网络编程基础,第3章介绍Windows环境的WinSock编程基础,第4章介绍MFC编程,第5章介绍MFC WinSock类的编程,第6章介绍WinInet编程,第7章介绍...

Global site tag (gtag.js) - Google Analytics