jwill / lanterna

Automatically exported from code.google.com/p/lanterna
GNU Lesser General Public License v3.0
0 stars 0 forks source link

jFrame.setResizable(false) causes drawing artifacts #95

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm trying to disable the resize button, and set some other stuff on the 
Lanterna JFrame. Here's my code:
    this.terminal = new SwingTerminal(width, height);       
    this.terminal.setCursorVisible(false);

    this.screen = TerminalFacade.createScreen(this.terminal);
    this.screen.startScreen();

    JFrame frame = this.terminal.getJFrame();       
    frame.setTitle("Freedom: An arena-battle roguelike");
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    //frame.setResizable(false);

When I leave that line commented out, everything appears normal (except I can 
resize, obviously). When I uncomment it, I get an extra row of green "X" 
letters on the right-hand side of my screen.

Is there a fix for this? I tried setting resizable elsewhere, but it makes no 
difference.

See attachment; the big red dots are me counting that there are (correctly) 80 
tiles wide (as I expected). The 81th shouldn't exist.

Original issue reported on code.google.com by alibhai....@gmail.com on 6 Dec 2013 at 10:47

Attachments:

GoogleCodeExporter commented 9 years ago
Taking a look...

Original comment by mab...@gmail.com on 8 Dec 2013 at 9:17

GoogleCodeExporter commented 9 years ago
I've written a testcase for this but I can't reproduce it on Linux. Will try on 
Windows when I get a chance.

Original comment by mab...@gmail.com on 8 Dec 2013 at 9:24

GoogleCodeExporter commented 9 years ago
If it doesn't reproduce, the same caveat as last time: reproduces in my GitHub 
repository: https://github.com/deengames/Freedom

There's a commented-out line in RgbConsoleScreen.java: 
//frame.setResizable(false);

Original comment by alibhai....@gmail.com on 8 Dec 2013 at 12:29

GoogleCodeExporter commented 9 years ago
Any updates on this?

Original comment by alibhai....@gmail.com on 23 Dec 2013 at 10:34

GoogleCodeExporter commented 9 years ago
See issue 94

Original comment by mab...@gmail.com on 16 Feb 2014 at 7:13

GoogleCodeExporter commented 9 years ago
I figured out something awesome: this only affects Lanterna on Windows. When I 
do this, my Ubuntu VM runs my app fine -- no artifacts.

There's also another problem on Windows, probably related: my first 
drawing/flushing of the screen disappears instantly.

Original comment by alibhai....@gmail.com on 9 Jun 2014 at 7:28

GoogleCodeExporter commented 9 years ago
I was finally able to reproduce this on Windows, including the initial flash 
you mention. Will try to figure it out...

Original comment by mab...@gmail.com on 18 Jun 2014 at 1:26

GoogleCodeExporter commented 9 years ago
Great, I'm glad you could repro it. Sorry I wasn't able to help you much with 
that.

Original comment by alibhai....@gmail.com on 18 Jun 2014 at 1:38

GoogleCodeExporter commented 9 years ago
Ok, so, Windows will expand the content area of the window slightly when making 
it non-resizable, which gives Lanterna the extra column. Just add this after 
your setResizable(true):
frame.pack();

That fixes it for me.

Original comment by mab...@gmail.com on 18 Jun 2014 at 1:54

GoogleCodeExporter commented 9 years ago
Next one, the flashing, is most likely related to that you are mixing 
operations on the Terminal interface of the SwingTerminal with operations on 
the Screen. When the size bug above is fixed though, the flash seems to go 
away. I see some artifact when closing the window, didn't look into that.

I understand you're hitting the Terminal just because you want full RGB support 
which Screen doesn't support in 2.1.X? In that case, you might have no other 
choice, but remember that whenever you put any text on the screen by going to 
the Terminal interface directly, any active Screen object has no idea of what 
you just did so the .refresh() call will very likely cause artifacts. So just 
be careful.

3.0 has fixed all of these issues with colors in Screens, so that should 
hopefully simplify this greatly.

Original comment by mab...@gmail.com on 18 Jun 2014 at 1:58

GoogleCodeExporter commented 9 years ago
Ok, thanks for closing. I'll reopen these after the 3.0 release if there's 
still a problem.

Original comment by alibhai....@gmail.com on 18 Jun 2014 at 4:42