These methods are not popped up while creating the object (ctrl spacebar
). Do I have to add any other package for this to work??
CodePudding user response:
Do I have to add any other package for this to work?
No. They are methods inherited from parent classes that should not be used by programmers. Instead, layout managers should use them.
Edit
I'd thought this was to do with component size and location within a frame. It was only after looking more closely at the (horrible(1)) pictures of the screen I realised they were methods related to a JFrame
, which changes the answer slightly.
setSize(..)
should be not used, butpack()
should. The former is no better than a guess, while the latter (called after components are added via layouts) will produce the correct size).setLocation(..)
is also less than optimal.setLocationRelativeTo(null)
will center a packed frame on-screen, whilesetLocationByPlatform(true)
(which I prefer) will place the app. in the position (determined by the OS) for the 'next' application (usually they will be stacked and offset slightly).
Coming back to the (1) note above:
- Don't take pictures of a computer screen. All OS offer the ability to create a screenshot of either the current screen or the current app. In Windows that would be Print Screen for the entire screen or Alt Print Screen for the focused app.
CodePudding user response:
Your question is about eclipse's content assist, right? If so, then please look at Window -> Preferences -> Java -> Appearance -> Type Filters. If there java.awt.* is selected, then methods of Component like setSize and setLocation are not shown.