java - What is the correct way of getting the default JLabel dimensions? -


in order solve problem working on, need find out default height of jlabel. using dummy approach:

jlabel label = new jlabel(); dimension dim = label.getpreferredsize(); 

is there way default height without instantiating jlabel?

i need find out default height of jlabel. using dummy approach:

jlabel label = new jlabel(); dimension dim = label.getpreferredsize(); 
  • is possible have accept done layoutmanager, there 2 options

    1. swing/awt gui visible on screen

    2. after jframe.pack() called

  • (i don't suggest, wroting complete answer) possible getpreferredsize of jcomponents using/invoke

    1. nulllayout using insets

    2. revalidate() , repaint() in visible swing/awt gui

is there way default height without instantiating jlabel?

  • without incorectly settting setsize, setpreferredsize, setbounds override getpreferredsize

Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -