JButton调用另一个类

时间:2014-03-10 11:51:39

标签: java swing jsoup jbutton actionlistener

我对ActionListener没什么问题。当我按下按钮它不运行代码我在这里得到很多错误。我做错了什么,以及如何运行另一个类而不是按下按钮后放置所有动作代码。

package org.jsoup.examples;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.io.PrintWriter;

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

import org.jsoup.*;
import org.jsoup.nodes.*;


public class JavaApplication17 {
    public static void main( String[] args ) throws IOException {

        JFrame frame = new JFrame ("Orai");
        frame.setVisible(true);
        frame.setSize(200,200);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JLabel label = new JLabel("InfoDienos Orai");
        JPanel panel = new JPanel();
        frame.add(panel);
        panel.add(label);

        JButton lietuvoje = new JButton("Lietuvoje");
        panel.add(lietuvoje);   

        lietuvoje.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String[] nuoroda = new String[10];
                nuoroda[0] = "http://www.gismeteo.lt/city/hourly/4230/#wdaily2";
                nuoroda[1] = "http://www.gismeteo.lt/city/hourly/4202/#wdaily2";
                nuoroda[2] = "http://www.gismeteo.lt/city/hourly/4157/#wdaily2";
                nuoroda[3] = "http://www.gismeteo.lt/city/hourly/4170/#wdaily2";
                nuoroda[4] = "http://www.gismeteo.lt/city/hourly/4175/#wdaily2";
                nuoroda[5] = "http://www.gismeteo.lt/city/hourly/4152/#wdaily2";
                nuoroda[6] = "http://www.gismeteo.lt/city/hourly/4203/#wdaily2";
                nuoroda[7] = "http://www.gismeteo.lt/city/hourly/4163/#wdaily2";
                nuoroda[8] = "http://www.gismeteo.lt/city/hourly/4166/#wdaily2";
                nuoroda[9] = "http://www.gismeteo.lt/city/hourly/4201/#wdaily2";    

                for (int j = 0; j < 10; j++) {
                Document doc = Jsoup.connect(nuoroda[j]).timeout(10*10000).userAgent("Mozilla/17.0").get();
                PrintWriter temp = new PrintWriter("D:/User Documents/Desktop/Orai/LIETUVOJE/TEMP/"+j+".txt");
                PrintWriter pav = new PrintWriter("D:/User Documents/Desktop/Orai/LIETUVOJE/PAV/"+j+".txt");
                PrintWriter atmosfera = new PrintWriter("D:/User Documents/Desktop/Orai/LIETUVOJE/ATMOSFERA/"+j+".txt");
                PrintWriter vejas = new PrintWriter("D:/User Documents/Desktop/Orai/LIETUVOJE/VEJAS/"+j+".txt");
                PrintWriter greitis = new PrintWriter("D:/User Documents/Desktop/Orai/LIETUVOJE/GREITIS/"+j+".txt");
                PrintWriter dregnumas = new PrintWriter("D:/User Documents/Desktop/Orai/LIETUVOJE/DREGNUMAS/"+j+".txt");
                PrintWriter faze = new PrintWriter("D:/User Documents/Desktop/Orai/LIETUVOJE/FAZE/"+j+".txt");
                PrintWriter menulis = new PrintWriter("D:/User Documents/Desktop/Orai/LIETUVOJE/MENULIS/"+j+".txt");

                for (int i = 8; i < 16; i++) {
                Element ele=doc.select("td.temp > span.value.m_temp.c").get(i); 
                Element ele2=doc.select("td.clicon > img").get(i); // 8 - 15
                Element ele3=doc.select("td.cltext").get(i); // 8 - 15
                Element ele4=doc.select("dl.wind > dt").get(i); // 8 - 15
                Element ele6=doc.select("div.wicon.hum").first(); // 8 - 15
                Element ele7=doc.select("ul.moon.moon5 > li").get(1); // 8 - 15
                Element ele8=doc.select("ul.moon.moon5 > li").get(1); // 8 - 15
                //System.out.println(ele4.text());
                if (ele4.text().toString().equals("Š")) {
                        vejas.println("##1");
                }
                if (ele4.text().toString().equals("P")) {
                    vejas.println("##2");
            }
                if (ele4.text().toString().equals("R")) {
                    vejas.println("##3");
            }
                if (ele4.text().toString().equals("V")) {
                    vejas.println("##4");
            }
                if (ele4.text().toString().equals("ŠR")) {
                    vejas.println("##5");
            }
                if (ele4.text().toString().equals("ŠV")) {
                    vejas.println("##6");
            }
                if (ele4.text().toString().equals("PV")) {
                    vejas.println("##7");
            }
                if (ele4.text().toString().equals("PR")) {
                    vejas.println("##8");
            }
                Element ele5=doc.select("dl.wind > dd > span.value.m_wind.ms").get(i); // 8 - 15
                temp.println(ele.text());

                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.png")) {
                    pav.println("##9");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c1.png")) {
                    pav.println("##10");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c2.png")) {
                    pav.println("##10");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c3.png")) {
                    pav.println("##10");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c4.png")) {
                    pav.println("##11");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c1.r1.png")) {
                    pav.println("##12");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c1.r2.png")) {
                    pav.println("##12");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c1.r3.png")) {
                    pav.println("##12");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c1.r4.png")) {
                    pav.println("##12");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c2.r1.png")) {
                    pav.println("##12");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c2.r2.png")) {
                    pav.println("##12");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c2.r3.png")) {
                    pav.println("##12");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c2.r4.png")) {
                    pav.println("##12");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c3.r1.png")) {
                    pav.println("##12");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c3.r2.png")) {
                    pav.println("##12");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c3.r3.png")) {
                    pav.println("##12");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c3.r4.png")) {
                    pav.println("##12");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c4.r1.png")) {
                    pav.println("##13");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c4.r2.png")) {
                    pav.println("##13");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c4.r3.png")) {
                    pav.println("##13");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c4.r4.png")) {
                    pav.println("##13");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c1.st.png")) {
                    pav.println("##14");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c2.st.png")) {
                    pav.println("##14");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c3.st.png")) {
                    pav.println("##14");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c4.st.png")) {
                    pav.println("##14");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c1.r1.st.png")) {
                    pav.println("##15");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c1.r2.st.png")) {
                    pav.println("##15");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c1.r3.st.png")) {
                    pav.println("##15");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c1.r4.st.png")) {
                    pav.println("##15");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c2.r1.st.png")) {
                    pav.println("##15");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c2.r2.st.png")) {
                    pav.println("##15");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c2.r3.st.png")) {
                    pav.println("##15");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c2.r4.st.png")) {
                    pav.println("##15");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c3.r1.st.png")) {
                    pav.println("##15");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c3.r2.st.png")) {
                    pav.println("##15");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c3.r3.st.png")) {
                    pav.println("##15");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c3.r4.st.png")) {
                    pav.println("##15");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c4.r1.st.png")) {
                    pav.println("##15");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c4.r2.st.png")) {
                    pav.println("##15");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c4.r2.st.png")) {
                    pav.println("##15");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c4.r3.st.png")) {
                    pav.println("##15");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c4.r4.st.png")) {
                    pav.println("##15");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c1.s1.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c1.s2.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c1.s3.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c1.s4.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c2.s1.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c2.s2.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c2.s3.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c2.s4.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c3.s1.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c3.s2.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c3.s3.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c3.s4.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c4.s1.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c4.s2.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c4.s3.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("d.sun.c4.s4.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.png")) {
                    pav.println("##17");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c1.png")) {
                    pav.println("##18");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c2.png")) {
                    pav.println("##18");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c3.png")) {
                    pav.println("##18");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c4.png")) {
                    pav.println("##11");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c1.r1.png")) {
                    pav.println("##19");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c1.r2.png")) {
                    pav.println("##19");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c1.r3.png")) {
                    pav.println("##19");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c1.r4.png")) {
                    pav.println("##19");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c2.r1.png")) {
                    pav.println("##19");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c2.r2.png")) {
                    pav.println("##19");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c2.r3.png")) {
                    pav.println("##19");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c2.r4.png")) {
                    pav.println("##19");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c3.r1.png")) {
                    pav.println("##19");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c3.r2.png")) {
                    pav.println("##19");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c3.r3.png")) {
                    pav.println("##19");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c3.r4.png")) {
                    pav.println("##19");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c4.r1.png")) {
                    pav.println("##13");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c4.r2.png")) {
                    pav.println("##13");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c4.r3.png")) {
                    pav.println("##13");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c4.r4.png")) {
                    pav.println("##13");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c1.st.png")) {
                    pav.println("##20");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c2.st.png")) {
                    pav.println("##20");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c3.st.png")) {
                    pav.println("##20");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c4.st.png")) {
                    pav.println("##14");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c1.r1.st.png")) {
                    pav.println("##21");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c1.r2.st.png")) {
                    pav.println("##21");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c1.r3.st.png")) {
                    pav.println("##21");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c1.r4.st.png")) {
                    pav.println("##21");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c2.r1.st.png")) {
                    pav.println("##21");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c2.r2.st.png")) {
                    pav.println("##21");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c2.r3.st.png")) {
                    pav.println("##21");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c2.r4.st.png")) {
                    pav.println("##21");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c3.r1.st.png")) {
                    pav.println("##21");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c3.r2.st.png")) {
                    pav.println("##21");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c3.r3.st.png")) {
                    pav.println("##21");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c3.r4.st.png")) {
                    pav.println("##21");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c4.r1.st.png")) {
                    pav.println("##15");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c4.r2.st.png")) {
                    pav.println("##15");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c4.r3.st.png")) {
                    pav.println("##15");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c4.r4.st.png")) {
                    pav.println("##15");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c1.s1.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c1.s2.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c1.s3.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c1.s4.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c2.s1.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c2.s2.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c2.s3.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c2.s4.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c3.s1.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c3.s2.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c3.s3.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c3.s4.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c4.s1.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c4.s2.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c4.s3.png")) {
                    pav.println("##16");
            }
                if (ele2.attr("src").substring(ele2.attr("src").lastIndexOf("/") + 1).trim().toString().equals("n.moon.c4.s4.png")) {
                    pav.println("##16");
            }
                if (ele8.text().toString().equals("Jaunatis")) {
                    menulis.println("##22");
            }
                if (ele8.text().toString().equals("Priešpilnis")) {
                    menulis.println("##23");
            }
                if (ele8.text().toString().equals("Pilnatis")) {
                    menulis.println("##24");
            }
                if (ele8.text().toString().equals("Delčia")) {
                    menulis.println("##25");
            }
                atmosfera.println(ele3.text());
                greitis.println(ele5.text() + " m/s");
                dregnumas.println(ele6.text().substring(0, 4));
                faze.println(ele7.text());
                    }
                temp.close();   
                pav.close();
                atmosfera.close();
                vejas.close();
                greitis.close();
                dregnumas.close();
                faze.close();
                menulis.close();
                    }
            }
    });
}
}

1 个答案:

答案 0 :(得分:0)

您的代码中的一个问题是您没有在Swings EDT(事件调度线程)中启动/显示您的框架。标准代码如下所示

java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new MyJFrame().setVisible(true);
        }
    });

第二:对于你的JFrame,你应该实现一个单独的类来避免这个主/帧构造混乱。

第三:运行代码时有没有例外?你怎么知道你的代码没有运行?你调试了吗?