Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring forum!

Elya Matsunomi

+ Follow
since Jan 23, 2019
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Elya Matsunomi

I examined the code earlier and found out that I just need to assign weights to my textarea and set the fill mode of textarea's constraints to GridBagConstraints.BOTH to achieve the result that I wanted.

6 hours ago
Thanks for this. This is a nice solution. Could you explain to me how this codes work

mainPanelLayout.rowWeights = new double[]{ 0.0, 0.0, 0.0, 0.1, 0.0 };
mainPanelLayout.rowHeights = new int[]{ 7, 7, 7, 20, 7 };
mainPanelLayout.columnWeights = new double[]{ 0.0, 1.0, 0.0 };
mainPanelLayout.columnWidths = new int[]{ 7, 300, 7 };

I presume these codes override row and column wildth and height.However, this looks like an advance way to adjust width and height. The javadoc regarding this fields is lacking in details.
17 hours ago
So, I have a panel with GridBagLayout  and I want a Jlabel to be placed on top of JTextArea. The problem is, if I put jlabel on top or bottom of jtextarea, the jtextarea will shrink. I tried to put jbutton instead of jlabel and the jtextarea wasn't shrinking. Here are some illustrations:

with jbutton

with jlabel

Code snippet

Is there a solution for this problem? or should I just use other layouts?
1 day ago

Tim Moores wrote:Are you supposed to code zip (de)compression yourself? If not, the package has classes that can do it for you.

Thanks for this! I didn't have any idea that java has this package. I thought I needed to create my own zip package.
Although, I wanna try to code compression algorithm by hand someday in the future.
Now, decompressing .rar files is the main problem. I'll let others do that functionality, It seems hard to do since winrar
is a proprietary software.
6 days ago
I have a project that needs to compress and decompress files. However, I don't know where to start learning compression algorithms.
The project requires compressing files in .zip format and decompress .zip and .rar files.
I would like to ask for some resources about compression algorithms.
1 week ago

putting the main thread in edt(Event Dispatch Thread)

This is a typo, it should be: putting the while loop in the main thread in edt.

2 years ago
So, was testing different screen sizes for my game. The best screen size that I tested was the exclusive full screen mode in java API. But, I want to implement a SFS(Simulated Full Screen) and windowed mode in my game in case the client doesn't support exclusive full screen mode. The problem is, when I use a windowed or SFS my images get jittery when moving on the screen. In windowed and SFS I cap my game fps(Frame Per Second) to 60, In exclusive full screen mode I just run the update and draw methods without capping the fps because from what I've observed, it looks like java automatically caps my game fps to 60. When my game is running in exclusive full screen mode the images move smoothly as silk. However, In other screen mode, the images jitter when moving.

Question #1: How do I make my game run smooth in windowed and SFS mode? I tried various attempts like putting the main thread in edt(Event Dispatch Thread) and the problem still persist.

Question #2: Why my fps is capped at 60 fps when using exclusive full screen mode? I assume that's because my monitor rate is 60hertz or my graphics card display mode sets to 60hertz(1360 by 768,True Color (32 bit), 60 hertz). I tried to change the graphics card display mode to 1024 by 768 True Color (32 bit), 75 hertz and the fps is still capped to 60.

Question #3: when I run my game to other machine like a machine that's faster than mine e.g. a monitor with refresh rate of 144hz and a graphics card with display mode higher than my graphics card, does java still cap my game fps to 60 in that machine?

I hope someone could help me on this.

Here's the reference I used in Exclusive Full Screen Mode:

Here is my test code

2 years ago
I found another simple fix to this bug. Just reorder the codes in the paint() method

From this:

To this:

So, I draw the sub and main object first then draw the status information.

And this is the result:

I assume the reason why this bug happens is because paint() is slower than the timer. So, the timer updates the objects transform values in the program and paint() draws the transformation of objects. In my assumption, timer is faster than paint(), so, the timer might update the objects transform values while paint() is still drawing the objects. So, the transform values in Graphics2D gets scrambled and produces unexpected result.  
2 years ago
I fixed it, sort of. I don't know if I fix this bug for good, but what I did to fix the bug was to create another BufferedImage for the main object. So, Sub objects group has their own bufferedimage and the main object has its own bufferedimage. As of now, my image didn't flip/shear, but I'm not really sure if the bug on my program is fixed because this bug can appear abrupt and random. I don't know the cause of this bug but base on my assumption, a graphic transformation may mess up if there's too much transform operation happening in the graphic.
2 years ago
is there any suggestion why this bug happens? I hope someone can help me on this as this bug is very challenging to fix for me because this bug randomly happens. I'll try to find a way to solve this and post my solution if I fix it.
2 years ago
In the early seconds when I launched my program everything was fine but as time went by, my main Object(the animal(pokemon) in the screenshot) got this kind of strange bug where the object image sheared/flipped for no reason. I have this program that rotates 25 sub objects(gray blob in the screenshot) and a main object that can be move and rotated by the user.

Here's my screenshot:

started to launch

After 90 seconds(approx.)

When I removed the rotate code of sub objects, I didn't get the bug.

sub objects no rotation

Here's my transform code on my main and sub objects

I already commented the rotate code

I tried to change this to paintComponent and the problem still persisted.

2 years ago
I fixed it. First, I observed that the rotation increment in keylistener was slower than the rotation increment in the timer. So, I created a boolean flag that sets to true if the key is pressed and false if the key is released. Then, I do the rotation of the first image in the timer. If the boolean flag is true, then the first image rotates as long as the boolean flag is true and stop if false. I only apply my solution on the right rotation, though, it can be easily applied on the left rotation. This solution is not that elegant though. Is there another alternative to this solution like a mathematical formula that produces the same result?

2 years ago
Is there a way to make the rotation of an image smooth when controlling with keys in keyboard?

In this code, there are two images rotating on the screen. The first image can be rotated by pressing the "D" and "A" key while the second image is automatically rotated. In this example, the second image is smoothly rotating while the first image has a jerky feel to its rotation.

Any help/insights would be appreciated.
2 years ago
I fixed it, forgot to paint the background

2 years ago
I am trying to rotate an image in a loop, but when I do the image multiplies on the screen and stacks up on each other.



How do I rotate my image without multiplying?

2 years ago