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

32
LINES

< > BotCompany Repo | #1004311 // Graphical Diff [Swing Frame with two texts and diff]

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

Uses 3874K of libraries. Click here for Pure Java version (9012L/62K/198K).

!7

sS text1, text2;
static JTextArea a, b, d;
static JCheckBox trim;
static JFrame frame;

p-awt {
  // change to pretty L&F if we're the main program
  if (isMainProgram()) substance();
  
  frame = showFrame(centerAndSouth(hgrid(
    withTitle("Text A (-)", a = new JTextArea(text1)),
    withTitle("Diff", withMargin(wrap(d = new JTextArea))),
    withTitle("Text B (+)", b = new JTextArea(text2))),
    centeredLine(trim = new JCheckBox("Ignore Indent", true))));
  trim.setToolTipText("Also ignores empty lines");
  setFrameWidth(frame, 800);

  update();    
  onUpdate(ll(a, b, trim), "update");
}

svoid update {
  d.setText(unidiff(preprocess(a.getText()), preprocess(b.getText())));
}

sS preprocess(S s) {
  if (isChecked(trim))
    s = fullTrim(s);
  ret s;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1004311
Snippet name: Graphical Diff [Swing Frame with two texts and diff]
Eternal ID of this version: #1004311/5
Text MD5: 848d1c88fce4b28b4bd0ffe7369f58a6
Transpilation MD5: 55e308b0b09c070e99a22b49de244a70
Author: stefan
Category: javax / gui
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-10-19 16:38:13
Source code size: 803 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 543 / 1041
Version history: 4 change(s)
Referenced in: [show references]