Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

69
LINES

< > BotCompany Repo | #1017723 // Swing Freeze Bug with certain characters

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (1491L/11K).

1  
!7
2  
3  
// https://bugs.openjdk.java.net/browse/JDK-8183385
4  
5  
static String s0 = "Hello World";
6  
// (truncated) contents of jdk-headers-1.6.0/include/ibm/zos/jawt_md.h file encoding=IBM500/EBCDIC, read with UTF8
7  
8  
static String s1 = "a\\\u0015@\\@~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\u0015@\\@@\ufffd\ufffd\ufffd@\u00d6\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0015@\\@@\ufffd\ufffd\ufffd@\u25a4\ufffd\ufffd\ufffd@\u0501\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0015@\\\u0015@\\@@\ufffd\ufffd\ufffd@\ufffd\ufffd\ufffdk@\u0441\ufffd\ufffdM\ufffd\ufffd]@\u3143\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd@\u0144\ufffd\ufffd\ufffd\ufffd\ufffdk@\ufffd\ufffd\u0015@\\@@M\ufffd]@\u00d6\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd@\ufffd\ufffd\ufffd@\u00d6\ufffd\ufffdK@\ufffd\ufffd\ufffd\ufffdk@\ufffd\ufffd\ufffd\ufffdK@\ufffd\ufffd\ufffd@\u0649\ufffd\ufffd\ufffd\ufffd@\u0645\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0015@\\\u0015@\\";
9  
10  
p {
11  
  swing { new main().go(); }
12  
}
13  
14  
void go() {
15  
  JFrame frame = new JFrame("BugRepro");
16  
  frame.setBounds(100, 100, 800, 600);
17  
  frame.setContentPane(foo());
18  
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
19  
  frame.setVisible(true);
20  
}
21  
22  
JCheckBox c;
23  
24  
JPanel foo() {
25  
  JPanel panel = new JPanel(new BorderLayout());
26  
  JButton b;
27  
  final JTextArea area = new JTextArea();
28  
  JPanel p = new JPanel(new FlowLayout());
29  
  panel.add(p, BorderLayout.NORTH);
30  
  p.add(b = new JButton("click me"));
31  
  p.add(c = new JCheckBox("include strange chars", true));
32  
  panel.add(new JLabel("Hello"), BorderLayout.SOUTH);
33  
  panel.add(new JScrollPane(area), BorderLayout.CENTER);
34  
  
35  
  // need to set a new Document b/c setText() sets the text of the old document.
36  
  b.addActionListener(actionListener { area.setDocument(makeDoc()); });
37  
  return panel;
38  
}
39  
40  
Document makeDoc() {
41  
Document doc = new PlainDocument();
42  
try {
43  
doc.insertString(0, makeString(), new SimpleAttributeSet());
44  
} catch (BadLocationException e) {
45  
throw new Error(e);
46  
}
47  
return doc;
48  
}
49  
50  
String makeString() {
51  
int MAX = 1000;
52  
53  
StringBuilder buf = new StringBuilder();
54  
extracted(MAX, buf);
55  
System.out.println("Including strange chars: " + c.isSelected());
56  
if (c.isSelected()) {
57  
buf.append(s1); // XXX This line slows down the rendering noticeably since it contains strange chars
58  
}
59  
extracted(MAX, buf);
60  
61  
return buf.toString();
62  
}
63  
64  
static void extracted(int MAX, StringBuilder buf) {
65  
for (int i = 0; i < MAX; i++) {
66  
buf.append(s0);
67  
buf.append("\n");
68  
}
69  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1017723
Snippet name: Swing Freeze Bug with certain characters
Eternal ID of this version: #1017723/5
Text MD5: f65a56690fef26976c5c10e5bc7caced
Transpilation MD5: b85bef3a93f5544abbdfc04e58f001fb
Author: stefan
Category: javax / gui
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-08-04 18:23:29
Source code size: 2540 bytes / 69 lines
Pitched / IR pitched: No / No
Views / Downloads: 384 / 1066
Version history: 4 change(s)
Referenced in: [show references]