import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ProgressBar;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import java.net.*;
import java.nio.charset.Charset;
public class GUIController implements Initializable {
Socket socket;
@FXML
private Button connectServer;
@FXML
private TextArea inCon;
@FXML
private CheckBox scan;
@FXML
private ProgressBar progress;
@FXML
private TextField commandOut;
@FXML
private Button recv;
@FXML
private TextField D2;
@FXML
private TextField D1;
@FXML
private TextField Add;
@FXML
private Button disconnector;
@FXML
private ProgressBar progressFile;
@FXML
private TextField bytes;
BufferedReader in;
PrintWriter out;
boolean connect;
@Override
public void initialize(URL url, ResourceBundle rb) {
recv.setDisable(true);
connectServer.setOnAction(event -> {
new Thread(new Runnable(){
public void run(){
if(scan.isSelected()){msgCon("Сканирование запускаеться");
String[] are = D1.getText().toString().split("\\.");
String[] are1 = D2.getText().toString().split("\\.");
msgCon("Сканирование запущено");connectServer.setDisable(true);
for(int i = Integer.parseInt(are[2]);i <= Integer.parseInt(are1[2]);i++){
for(int u = 1;u <= 255;u++){
if(new String(are[0]+are[1]).equalsIgnoreCase(are1[0]+are1[1])){
String add = are[0]+"."+are[1]+"."+i+"."+u;
msgCon("Проверка адреса : "+add);
try {
connect(add);
add = null;are = null;are1 = null;break;
} catch (IOException ex) {msgCon("Адрес неверен.");msgCon("/clear/");}
}else{msgCon("Напишите диапозон с одинаковыми первыми и вторыми значениями.");}
}
}
}
else{try {
progress.setProgress(0.2);connectServer.setDisable(true);
connect(Add.getText().toString());
} catch (IOException ex) {msgCon("Ошибка подключения или сервер ненайден.");connectServer.setDisable(false);progress.setProgress(0);}}}
}).start();
});
disconnector.setOnAction(event ->{
disconnect(socket);
});
recv.setOnAction(event ->{ try{
String msg = commandOut.getText().toString();
if(msg != null){out.println(msg);out.flush();commandOut.setText("");}}catch(Exception e){msgCon("Сообщение не отправлено.");msgCon("Проверте соединение.");}
});
}
public void connect(String add) throws IOException{
connect = false;
msgCon("Подключение к серверу.");
Socket socket = new Socket();
socket.connect(new InetSocketAddress(add,6988),50);
if(!socket.isClosed()&&socket != null){ in = new BufferedReader(new InputStreamReader(socket.getInputStream(),Charset.forName("UTF-8")));
out = new PrintWriter(socket.getOutputStream());
msgCon("Проверка сервера");
progress.setProgress(0.4);
out.println("258963");out.flush();
Thread opo = new Thread(new Runnable(){
@Override
public void run() {
try{String opon = in.readLine();
if(opon.equalsIgnoreCase("369852")){connect = true;msgCon("Проверка пройдена.");}
}catch(IOException e){msgCon("При проверке произошла ошибка.");}
}});
opo.start();
try{Thread.sleep(2000);}catch(Exception e){}
progress.setProgress(0.6);
opo.interrupt();
if(connect){msgCon("Запуск всех инструментов для работы.");connector(socket);}else{msgCon("Сервер был ненайден или не прошёл проверку.");disconnect(socket);}
}
}
Thread opos;
public void connector(Socket sock){
try {socket = sock;sock.setSoTimeout(0);progress.setProgress(0.8);} catch (SocketException ex) {}
new Thread(new Runnable(){
@Override
public void run() {
opos = Thread.currentThread();
recv.setDisable(false);
while(true){
try{String msg = in.readLine();
if(msg!=null){msgCon(msg);progress.setProgress(0);}
}catch(IOException e){msgCon("Ошибка в приёме сообщения,отключаемся.");disconnect(sock);break;}
}}
}).start();
}
public void disconnect(Socket sock){
if(sock!=null&&!sock.isClosed()){try{sock.close();}catch(IOException e){}}
connectServer.setDisable(false);
recv.setDisable(true);
in = null;
out = null;
msgCon("Отключены от сервера.");
progress.setProgress(0);
}
public void msgCon(String msg){
if(msg.equalsIgnoreCase("/clear/")){inCon.setText("");}
inCon.setText(msg+"\n"+inCon.getText());
}
}
Не могу понять в чём ошибка пробовал различные способы менял структуру нечего не помогает,после моих попыток я смог только задержать ошибку не сразу появляется. Ошибка:
Exception in thread "Thread-4" java.lang.NullPointerException
at clientcontrol.GUIController$1.run(GUIController.java:76)
at java.lang.Thread.run(Thread.java:748)
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at com.sun.javafx.text.PrismTextLayout.addTextRun(PrismTextLayout.java:755)
at com.sun.javafx.text.GlyphLayout.addTextRun(GlyphLayout.java:140)
at com.sun.javafx.text.GlyphLayout.breakRuns(GlyphLayout.java:210)
at com.sun.javafx.text.PrismTextLayout.buildRuns(PrismTextLayout.java:770)
at com.sun.javafx.text.PrismTextLayout.layout(PrismTextLayout.java:1021)
at com.sun.javafx.text.PrismTextLayout.ensureLayout(PrismTextLayout.java:223)
at com.sun.javafx.text.PrismTextLayout.getBounds(PrismTextLayout.java:246)
at javafx.scene.text.Text.getLogicalBounds(Text.java:358)
at javafx.scene.text.Text.impl_computeGeomBounds(Text.java:1168)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.recomputeBounds(Parent.java:1524)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.updateCachedBounds(Parent.java:1596)
at javafx.scene.Parent.recomputeBounds(Parent.java:1535)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.recomputeBounds(Parent.java:1524)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.recomputeBounds(Parent.java:1524)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.computeLocalBounds(Node.java:3595)
at javafx.scene.Node.updateLocalBounds(Node.java:3625)
at javafx.scene.Node.getLocalBounds(Node.java:3486)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.updateCachedBounds(Parent.java:1596)
at javafx.scene.Parent.recomputeBounds(Parent.java:1535)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.recomputeBounds(Parent.java:1524)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.updateCachedBounds(Parent.java:1596)
at javafx.scene.Parent.recomputeBounds(Parent.java:1535)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.impl_intersectsBounds(Node.java:5015)
at javafx.scene.layout.Region.impl_pickNodeLocal(Region.java:2931)
at javafx.scene.Node.impl_pickNode(Node.java:4914)
at javafx.scene.Scene$MouseHandler.pickNode(Scene.java:3899)
at javafx.scene.Scene$MouseHandler.access$1600(Scene.java:3485)
at javafx.scene.Scene.pick(Scene.java:1942)
at javafx.scene.Scene.access$6700(Scene.java:159)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3799)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:394)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$353(GlassViewEventHandler.java:432)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:431)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)
Exception in thread "JavaFX Application Thread" java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(ArrayList.java:422)
at java.util.ArrayList.get(ArrayList.java:435)
at com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:89)
at com.sun.javafx.collections.VetoableListDecorator.get(VetoableListDecorator.java:306)
at javafx.scene.Parent.updateCachedBounds(Parent.java:1591)
at javafx.scene.Parent.recomputeBounds(Parent.java:1535)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Node.updateBounds(Node.java:559)
at javafx.scene.Parent.updateBounds(Parent.java:1719)
at javafx.scene.Parent.updateBounds(Parent.java:1717)
at javafx.scene.Parent.updateBounds(Parent.java:1717)
at javafx.scene.Parent.updateBounds(Parent.java:1717)
at javafx.scene.Parent.updateBounds(Parent.java:1717)
at javafx.scene.Parent.updateBounds(Parent.java:1717)
at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2404)
at com.sun.javafx.tk.Toolkit.lambda$runPulse$29(Toolkit.java:398)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:397)
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:424)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:518)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:498)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:491)
at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$403(QuantumToolkit.java:319)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)
Exception in thread "JavaFX Application Thread" java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(ArrayList.java:422)
at java.util.ArrayList.get(ArrayList.java:435)
at com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:89)
at com.sun.javafx.collections.VetoableListDecorator.get(VetoableListDecorator.java:306)
at javafx.scene.Parent.updateCachedBounds(Parent.java:1591)
at javafx.scene.Parent.recomputeBounds(Parent.java:1535)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Node.updateBounds(Node.java:559)
at javafx.scene.Parent.updateBounds(Parent.java:1719)
at javafx.scene.Parent.updateBounds(Parent.java:1717)
at javafx.scene.Parent.updateBounds(Parent.java:1717)
at javafx.scene.Parent.updateBounds(Parent.java:1717)
at javafx.scene.Parent.updateBounds(Parent.java:1717)
at javafx.scene.Parent.updateBounds(Parent.java:1717)
at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2404)
at com.sun.javafx.tk.Toolkit.lambda$runPulse$29(Toolkit.java:398)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:397)
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:424)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:518)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:498)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:491)
at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$403(QuantumToolkit.java:319)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)
Exception in thread "JavaFX Application Thread" java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(ArrayList.java:422)
at java.util.ArrayList.get(ArrayList.java:435)
at com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:89)
at com.sun.javafx.collections.VetoableListDecorator.get(VetoableListDecorator.java:306)
at javafx.scene.Parent.updateCachedBounds(Parent.java:1591)
at javafx.scene.Parent.recomputeBounds(Parent.java:1535)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Node.updateBounds(Node.java:559)
at javafx.scene.Parent.updateBounds(Parent.java:1719)
at javafx.scene.Parent.updateBounds(Parent.java:1717)
at javafx.scene.Parent.updateBounds(Parent.java:1717)
at javafx.scene.Parent.updateBounds(Parent.java:1717)
at javafx.scene.Parent.updateBounds(Parent.java:1717)
at javafx.scene.Parent.updateBounds(Parent.java:1717)
at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2404)
at com.sun.javafx.tk.Toolkit.lambda$runPulse$29(Toolkit.java:398)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:397)
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:424)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:518)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:498)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:491)
at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$403(QuantumToolkit.java:319)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)
Это не все ошибки но они там повторяются.
Подключаю кwar приложению JPA
Есть приложение с таблицей Не обновляется БД в андроид приложении, необходимо по нажатию кнопки менять размер шрифтаВ activity_main
При вызове метода await() класса ChannelFuture после отправки сообщения клиенту, выбрасывается исключение: