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

72
LINES

< > BotCompany Repo | #1009901 // Blurry Swing [OK]

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

Download Jar. Uses 3874K of libraries. Click here for Pure Java version (2686L/19K).

!7

import javax.swing.plaf.LayerUI;

sclass BlurLayerUI extends LayerUI<JComponent> {
  BufferedImage mOffscreenImage;
  BufferedImageOp mOperation;

  *() {
    float ninth = 1.0f / 9.0f;
    float[] blurKernel = {
      ninth, ninth, ninth,
      ninth, ninth, ninth,
      ninth, ninth, ninth
    };
    mOperation = new ConvolveOp(new Kernel(3, 3, blurKernel), ConvolveOp.EDGE_NO_OP, null);
  }

  public void paint(Graphics g, JComponent c) {
    int w = c.getWidth();
    int h = c.getHeight();
    if (w == 0 || h == 0) ret;

    // Only create the offscreen image if the one we have
    // is the wrong size.
    if (mOffscreenImage == null ||
            mOffscreenImage.getWidth() != w ||
            mOffscreenImage.getHeight() != h) {
      mOffscreenImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    }

    Graphics2D ig2 = mOffscreenImage.createGraphics();
    ig2.setClip(g.getClip());
    super.paint(ig2, c);
    ig2.dispose();

    ((Graphics2D) g).drawImage(mOffscreenImage, mOperation, 0, 0);
  }
}

p-substance {
  LayerUI<JComponent> layerUI = new BlurLayerUI();
  JPanel panel = createPanel();
  JLayer<JComponent> jlayer = new JLayer<JComponent>(panel, layerUI);
  centerFrame(setFrameSize(showFrame("Myopia", jlayer), 300, 200));
  hideConsole();
}
 
static JPanel createPanel() {
  JPanel p = new JPanel();

  ButtonGroup entreeGroup = new ButtonGroup();
  JRadioButton radioButton;
  p.add(radioButton = new JRadioButton("Beef", true));
  entreeGroup.add(radioButton);
  p.add(radioButton = new JRadioButton("Chicken"));
  entreeGroup.add(radioButton);
  p.add(radioButton = new JRadioButton("Vegetable"));
  entreeGroup.add(radioButton);

  p.add(new JCheckBox("Ketchup"));
  p.add(new JCheckBox("Mustard"));
  p.add(new JCheckBox("Pickles"));

  p.add(new JLabel("Special requests:"));
  p.add(new JTextField(20));

  JButton orderButton = new JButton("Place Order");
  p.add(orderButton);

  return p;
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1009901
Snippet name: Blurry Swing [OK]
Eternal ID of this version: #1009901/4
Text MD5: be504e215dbbc90b9e91eba2978675bb
Transpilation MD5: 55e4e016cdc25f7b85bc0c56125be586
Author: stefan
Category: javax / gui
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-08-24 04:06:51
Source code size: 2020 bytes / 72 lines
Pitched / IR pitched: No / No
Views / Downloads: 459 / 923
Version history: 3 change(s)
Referenced in: [show references]