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

81
LINES

< > BotCompany Repo | #1009902 // Zoomed Swing [dev.]

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

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

1  
!7
2  
3  
import javax.swing.plaf.LayerUI;
4  
5  
static class ZoomUI extends LayerUI<JComponent> {
6  
  double zoom = 1.5;
7  
  
8  
  public void paint(Graphics g, JComponent c) {
9  
      Graphics2D g2 = (Graphics2D) g.create();
10  
      g2.scale(zoom, zoom);
11  
      super.paint(g2, c);
12  
      g2.dispose();
13  
  }
14  
15  
  public void installUI(JComponent c) {
16  
      super.installUI(c);
17  
      JLayer jlayer = (JLayer)c;
18  
      jlayer.setLayerEventMask(
19  
              AWTEvent.MOUSE_EVENT_MASK | AWTEvent.ACTION_EVENT_MASK |
20  
                      AWTEvent.MOUSE_MOTION_EVENT_MASK
21  
      );
22  
  }
23  
24  
  @Override
25  
  public void uninstallUI(JComponent c) {
26  
      JLayer jlayer = (JLayer)c;
27  
      jlayer.setLayerEventMask(0);
28  
      super.uninstallUI(c);
29  
  }
30  
  
31  
  protected void processMouseEvent(MouseEvent e, JLayer l) {
32  
    /*l.getView().dispatchEvent(new MouseEvent(e.getComponent(),
33  
      e.getID(),
34  
      e.getWhen(),
35  
      e.getModifiers(),
36  
      iround(e.getX()/zoom),
37  
      iround(e.getY()/zoom),
38  
      e.getXOnScreen(),
39  
      e.getYOnScreen(),
40  
      e.getClickCount(),
41  
      e.isPopupTrigger(),
42  
      e.getButton()));
43  
    e.consume();*/
44  
  }
45  
46  
  protected void processMouseMotionEvent(MouseEvent e, JLayer l) {
47  
    processMouseEvent(e, l);
48  
  }
49  
}
50  
51  
p-substance {
52  
  LayerUI<JComponent> layerUI = new ZoomUI;
53  
  JPanel panel = createPanel();
54  
  JLayer<JComponent> jlayer = new JLayer<JComponent>(panel, layerUI);
55  
  centerFrame(setFrameSize(showFrame(jlayer), 300, 200));
56  
}
57  
 
58  
static JPanel createPanel() {
59  
  JPanel p = new JPanel();
60  
61  
  ButtonGroup entreeGroup = new ButtonGroup();
62  
  JRadioButton radioButton;
63  
  p.add(radioButton = new JRadioButton("Beef", true));
64  
  entreeGroup.add(radioButton);
65  
  p.add(radioButton = new JRadioButton("Chicken"));
66  
  entreeGroup.add(radioButton);
67  
  p.add(radioButton = new JRadioButton("Vegetable"));
68  
  entreeGroup.add(radioButton);
69  
70  
  p.add(new JCheckBox("Ketchup"));
71  
  p.add(new JCheckBox("Mustard"));
72  
  p.add(new JCheckBox("Pickles"));
73  
74  
  p.add(new JLabel("Special requests:"));
75  
  p.add(new JTextField(20));
76  
77  
  JButton orderButton = new JButton("Place Order");
78  
  p.add(orderButton);
79  
80  
  return p;
81  
}

Author comment

Began life as a copy of #1009901

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: #1009902
Snippet name: Zoomed Swing [dev.]
Eternal ID of this version: #1009902/5
Text MD5: 96f01f4898e9f867b04efaffe8280ded
Transpilation MD5: 5d809906a82b68475bee1cc253c77b9c
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 00:33:52
Source code size: 2166 bytes / 81 lines
Pitched / IR pitched: No / No
Views / Downloads: 656 / 1563
Version history: 4 change(s)
Referenced in: [show references]