rubiks_cube | rubik 's cube that runs in your terminal | Command Line Interface library
kandi X-RAY | rubiks_cube Summary
kandi X-RAY | rubiks_cube Summary
A rubik's cube that runs in your terminal!.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of rubiks_cube
rubiks_cube Key Features
rubiks_cube Examples and Code Snippets
Community Discussions
Trending Discussions on rubiks_cube
QUESTION
When I use getHeight() and getWidth() from my main, right after frame.pack(), I get the true height/width value. But when I use them in my other class, it doesn't work. I already tried to organize my main differently (because many suggested it in other similar questions) and it ended up getting a bit messy and nothing changed.
...ANSWER
Answered 2019-Dec-26 at 19:36In main(), you are getting the width/height of green, which is a JPanel whose size you have specified.
In paintCube, you are getting the width/height of the paintCube that has been added to green. It is laid out by the default layout manager of JPanel, which is a FlowLayout, since you did not specify a layout manager. You did not specify a size for that component, so its size is zero.
Change the layout manager of green, etc., to BorderLayout and add the paintCube to it using BorderLayout.CENTER, so it will expand to the size of the parent (green).
BTW, you should follow Java convention and name your class PaintCube, not paintCube.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install rubiks_cube
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page