Comments (4)
How does terminal.dispose(null)
crash? Can you post the stack trace?
from text-io.
Sorry. not crashing. I meant the JFrame was disposed before I can save up some objects.
So I'm hoping not to dispose the JFrame.
But if I set the keepRunning to false, the beryx console would just halt and no longer work.
So my question is how can I make the console work again without disposing/rebuilding the whole JFrame ?
from text-io.
I'm not sure if it helps, but try to replace this line with:
((MarsTerminal)InteractiveTerm.getTextIO().getTextTerminal()).getFrame().setVisible(false);
from text-io.
My first objective is to find out how to exit the text-io properly.
In my case in a class called MarsTerminal
that extends SwingTextTerminal
, I attach a listener to the top-right corner exit button to ask for confirmation if I want to exit as follows :
private void configureMainMenu() {
frame = getFrame();
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent event) {
// Save simulation and UI configuration when window is closed.
int reply = JOptionPane.showConfirmDialog(null, "Are you sure you want to quit?", "Exit", JOptionPane.YES_NO_OPTION);
if (reply == JOptionPane.YES_OPTION) {
printf("Exiting the Simulation..." + System.lineSeparator());
Simulation sim = Simulation.instance();
sim.endSimulation();
sim.getSimExecutor().shutdownNow();
if (sim.getMasterClock() != null)
sim.getMasterClock().exitProgram();
logger.info("Exiting the Simulation.");
InteractiveTerm.setKeepRunning(false);
System.exit(0);
frame.setVisible(false);
dispose(null);
}
}
});
When I choose the Yes
button to quit, I have the following stacktrace :
java.lang.RuntimeException: read interrupted
at org.beryx.textio.swing.SwingTextTerminal.read(SwingTextTerminal.java:378)
at org.beryx.textio.InputReader.readWithPrompt(InputReader.java:437)
at org.beryx.textio.InputReader.lambda$read$3(InputReader.java:382)
at org.beryx.textio.TextTerminal.applyWithPropertiesConfigurator(TextTerminal.java:243)
at org.beryx.textio.InputReader.executeWithTerminal(InputReader.java:461)
at org.beryx.textio.InputReader.read(InputReader.java:380)
at org.beryx.textio.InputReader.read(InputReader.java:368)
at org.mars.sim.console.SwingHandler$Task.run(SwingHandler.java:188)
at org.mars.sim.console.SwingHandler.executeOneTask(SwingHandler.java:345)
at org.mars.sim.console.InteractiveTerm.selectMode(InteractiveTerm.java:165)
at org.mars.sim.console.InteractiveTerm.startModeSelection(InteractiveTerm.java:136)
at org.mars_sim.main.MarsProject.handleNewSimulation(MarsProject.java:418)
at org.mars_sim.main.MarsProject.initializeSimulation(MarsProject.java:191)
at org.mars_sim.main.MarsProject$SimulationTask.run(MarsProject.java:164)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.InterruptedException
at java.base/java.lang.Object.wait(Native Method)
at java.base/java.lang.Object.wait(Object.java:328)
at org.beryx.textio.swing.SwingTextTerminal.read(SwingTextTerminal.java:355)
... 18 more
from text-io.
Related Issues (20)
- Error Message Provider for EnumInputReader with Numbered Values HOT 2
- Disable Event Expansion for Strings Containing Exclamation Marks '!' HOT 1
- Timed Wait for Input HOT 1
- Multi-line paste use case HOT 1
- Jline 3 support HOT 2
- Specific Maven example for WebTextTerminal HOT 3
- Cookies on WebTextTerminal HOT 5
- How to use MockTextTerminal HOT 7
- Allow cumulative possible values and properties configurators
- MockTextTerminal strips out new lines
- How to print also to log? HOT 4
- Change error messages HOT 2
- Input masking doesn't work with SystemTextTerminal HOT 2
- 👀
- Print empty line/whitespace
- java.lang.UnsatisfiedLinkError: /root/wag_inst/tools/jre-linux/lib/libawt_xawt.so: libXrender.so.1: cannot open shared object file: No such file or directory
- How minimize console to system tray?
- Java 21 breaks the terminal font HOT 1
- How to change the prompt for a EnumInputReader?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from text-io.