1
これは誰でも助けることができるならば、私は基本的に電子メールの可用性チェッカーを作るしようとしています完全なコードです。私が望むのは、可変リストをJlistに入れて、すべての電子メールを出力し、その電子メールがチェックされていればJListから削除することです。のJava - mainメソッド内の別のメソッドからのアクセス変数
class main{
public static void main(String[] args) throws InterruptedException {
gui.gui();
}
}
|
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
class tuna {
public static void tuna() throws InterruptedException, FileNotFoundException {
WebDriver driver = new ChromeDriver();
try (BufferedReader br = new BufferedReader(new FileReader("emails.txt"))) {
String line;
while ((line = br.readLine()) != null) {
driver.get("https://signup.live.com/signup?wa=wsignin1.0&rpsnv=12&ct=1465840004&rver=6.7.6643.0&wp=&wreply=https%3a%2f%2fwww.msn.com%2fen-us%2fhomepage%2fSecure%2fPassport%3fru%3dhttp%253a%252f%252fwww.msn.com%252f%253focid%253dmailsignout%2526pfr%253d1&id=1184&pcexp=True&bk=1465840005&uiflavor=web&uaid=dc151162984741948b8371ce3e0c865e&mkt=EN-US&lc=1033&lic=1");
WebElement Email = driver.findElement(By.id("MemberName"));
WebElement Refresher = driver.findElement(By.id("FirstName"));
WebElement TakenErrorMsg = driver.findElement(By.id("MemberNameError"));
Email.sendKeys(line);
Refresher.click();
Thread.sleep(650);
if (TakenErrorMsg.isDisplayed()) {
System.out.println(line + " is taken!");
} else {
System.out.println(line + " is not taken!");
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
|
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.FileNotFoundException;
public class gui extends JFrame {
public static void gui() {
JLabel label1 = new JLabel("Hotmail availability checker");
label1.setVisible(true);
label1.setSize(250, 250);
label1.setLocation(165, -100);
JLabel label2 = new JLabel("Emails unchecked");
label2.setVisible(true);
label2.setSize(250, 240);
label2.setLocation(40, -82);
JButton b1 = new JButton("Start");
b1.setSize(200,50);
b1.setLocation(140, 300);
b1.setVisible(true);
JScrollPane scrollPane = new JScrollPane();
final DefaultListModel emailsChecked = new DefaultListModel();
emailsChecked.addElement("AAA");
final JList list = new JList(emailsChecked);
list.setVisible(true);
list.setVisible(true);
list.setLocation(20,50);
list.setSize(150,200);
scrollPane.setViewportView(list);
JFrame frames = new JFrame();
frames.setTitle("Hotmail availability checker");
frames.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frames.setLayout(null);
frames.setVisible(true);
frames.setSize(500, 400);
frames.setLocationRelativeTo(null);
frames.add(b1);
frames.add(label1);
frames.add(list);
frames.add(label2);
frames.add(scrollPane);
b1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
tuna.tuna();
} catch (InterruptedException e1) {
e1.printStackTrace();
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
}
});
}
}
さてさて、フィードバックのためのおかげで、私は違っ何ができるか任意のアイデア?あまりにもこの作品を作る? –
@Macklinguyあなたの質問は非常に一般的であり、それは良い答えを提供することを本当に困難にします。あなたのコードが意図していることとあなたのコードの要件は何かについてもっと詳しく説明できますか?あなたは、バッファリーダーから行を読んでいるように私はあなたのコードで表示されるものと、それはあなたが後でそれらの行を必要とする場合、私はあなたが変数に格納することを示唆している、あなたの「他のjavaファイル」変数を変更したり、返却を持って見えますあなたのメインメソッドに、後で使用するためにその変数への参照を保持させます。 –
私が言ったように: "私は解決策として何を示唆するべきかわかりません"。始めに、あなたがしようとしているようなことは、私にとっては意味がありません。 –