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

13
LINES

< > BotCompany Repo | #1015363 // jWiderScrollPane - includes space for vertical scrollbar on pack()

JavaX fragment (include)

1  
static JScrollPane jWiderScrollPane(final JComponent c) {
2  
  ret swing(func -> JScrollPane { ret new JScrollPane(c) {
3  
    public Dimension getPreferredSize() {
4  
      Component view = getViewport().getView();
5  
      if (view == null) ret super.getPreferredSize();
6  
      int pref_height = view.getPreferredSize().height;
7  
      setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
8  
      Dimension dim = new(super.getPreferredSize().width + getHorizontalScrollBar().getSize().width, pref_height);
9  
      setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
10  
      ret dim;
11  
    }
12  
  }; });
13  
}

Author comment

Began life as a copy of #1015089

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: #1015363
Snippet name: jWiderScrollPane - includes space for vertical scrollbar on pack()
Eternal ID of this version: #1015363/1
Text MD5: c60888706ca36f0f8d16b77946df25c1
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-13 13:21:41
Source code size: 624 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 347 / 393
Referenced in: [show references]