Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
So I am doing a tic tac toe game for my school project and requirements are that the player can choose the width and height. So I started making this game with JButtons but my problem is how can I make it so that my buttons would construct a rectangle at the center of my frame based on the user's inputs. What would be the best approach to do this? I've gotten to the point where I add the correct amount of buttons to the frame but I have no idea what layout/layouts should I use to make the "gameboard" that is constructed from multiple JButtons appear as a rectangle to the center of the frame.
You can use GridLayout. See here for example.
Following are some other useful examples/links:
javatpoint
tutorialspoint
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I would like to create "god rays" effect/lighting on a 3D shape. If I have a Box, I would like to have a light source behind it that will create "god rays" around it. Below, is an image I found showing the idea (imagine the window as an opaque box and the rays coming around all sides):
I tried setting a PointLight source, but all lights illuminate "solid" objects, so you can't see the effect around them. My guess would be to fill the area around the shape with some sort of air-like, partially transparent material, that engulfs the shape; and that the light can reflect from.
How would I go about creating "god rays?
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Assignment Instructions
I'm not sure what this means or what it is asking me to do, I've been programming with Java for only a few months and this seems really difficult with my limited knowledge.
From what I can tell, your assignment is to draw graphics on a panel using the required methods. The graphics can be of any color or size. Once you have done that, you are to make 3 copies of that panel which will leave you with 4 of the same panel. Then you are to put those 4 panels onto another panel and make a copy of that panel 3 times. This in reality should leave you with 16 of the original panels placed into a 4x4 grid or 4 big panels placed in a 2x2 grid. I would still recommend asking your instructor for help though, incase I am incorrect.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have one task from my lecture which is Java. Lecturer ask us to draw a custom chess game which is something similar with the below picture. I was thinking from past few days but are not able to get at all.
Instruction :
Sorry, if I am asking question wrongly. I am expecting some ideas and any references for in able to do this.
we can write a code for you , but instead step to start will help you more to learn.
There can be many ways to write this one of is this.
Steps to start
Create a JFrame.
Set layout to border layout
Create a JPanel -> set panel at the center of jframe
Set panel layout to grid layout of 11 x 11
Create jable objects in for loop and add in Jpanel components.
Control background color of jlabel to form a structure shown in image.
For pawn, knight,you can use jlabel images
Build you logic to move or change jlabel to acive your requirement
Update and correction are invited
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Also, is the paintComponent() method used to paint a widget or a panel?
Panel : Abstract base class for all panels, which are widgets that can contain other widgets. The hierarchy of Class Panel is Here.
Widget :The base class for the majority of user-interface objects. Widget adds support for receiving events from the browser and being added directly to panels. Read more about Widget Here.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
1
I have gone through the code on Java documentation for Swing look and feel, but I could not find much about how to modify the default look of JButtons.
I want to have rounded/curved corners for JButtons in Swing.
Is there a way to achieve this?
What functions and values should I use?
I have used the statement below:
generateButton.setBorder(new RoundedBorder(20));
The code for RoundedBorder I found in Stack Overflow question Rounded Swing JButton using Java:
I do get a black rounded border outline around the original button. MY button has orange background. But it doesn't remove the orange area outside the rounded corners. Also I do not want the black border.
How should I go about this?
You can easily use a Java Swing theme like Nimbus.
Or check out Stack Overflow question Make a button round.