Full table background color in swing - java

I'm building my Java application interface using a lot of Photoshop.
But after implementing a table it doesn't look pretty cool as you can see:
I would like to make the table as transparent as possible, so only letters are shown. I have setted all the colors to black.
Any solution?

JTable#setFillsViewportHeight would be the starting point.
Make sure that the background color of the JTable has been set accordingly

Related

Making a qustom EnumChatFormatting Color

Is there a way to make a custom color with EnumChatFormatting, with rgb or hsb? Because i got a gui where i can change the menu color with red(0-255), blue, green also. Now i got the problem to insert that values to EnumChatFormatting anyone got a solution?
It depends. So if you're making a forge mod, it's possible to set the color of your custom GUIs to whatever you want. The ChatFormatting enum is already used in minecrafts code, so you can't change that easily.

Is there always a natural "space" between cells in a table?

I created a table with "buttons" aligned onto my screen for my game I am using to learn libgdx. I want the buttons to squeeze together perfectly to form a seamless menu, however there seems to be a natural padding of 1 to 2 pixels between every cell.
Is there a way to remove that padding?
The code seems unnecessary but this is the contents of my table anyways:
table.add(buttonTyce).size(150,60).expandX().expandY().bottom().left().row();
table.add(buttonGrokk).size(150,60).bottom().left().row();
table.add(buttonCeleste).size(150,60).bottom().left().row();
table.add(buttonDaem).size(150,60).bottom().left().row();
table.add(buttonRisp).size(150,60).bottom().left().padBottom(80).row();
table.setFillParent(true);
stage.addActor(table);
Thank you for any help.
I don't think there is default space. Are you sure that the texture you are using for your buttons doesn't contain any transparent edges? Also, there's table.debug() (or something like that, check the docs) to draw lines around table cells for debugging such issues.

How to create a custom Java Swing GUI Component with a shape and gradient

I have to create a custom component on my JFrame, the Component will show the storage status of that user, the storage will be in percentage.
I need to create something like this:
I tried a custom JLabel to create a label and then coloring that label from left to right, but I was unable to create a cloud shape Label and then filling that label according to a variable value.
How should I do this and what is the best way to do it?
One time I thought I should use series of images to show the status of user storage.
Thanks!
I think you're going to need to use an image mask (examples here and here) if you are to replicate that cloud exactly.
The process will require 2 images:
The cloud outline (the blue parts)
An image mask is the shape of the cloud, probably black outside and white inside
Then your drawing process, which you'll have to do each time the % storage changes will be:
Create a new buffered image
Draw then green fill bar in the style you want (e.g. slanted as in this image)
Copy the image mask over this
Draw this new image to the screen, with the mask applied as described here
Draw the cloud outline image to screen
That's going to take an hour or so for you to put together, so I'm not going to do it for you. Have a go, and if you run in to problems (or don't understand anything I just described) then ask about that specifically.
You can use GlyphVector#getGlyphOutline() to get the shape of a Unicode character like ☁ \u2601 and fill it with a GradientPaint.
You can do that with a JLabel and a custom-implemented class derived from Icon.
doesn't this help? Java gradient label example
And if you understand (or can translate from) portuguese, there's also this discussion with a solution at the end

drawing layers using java graphics API

I'm doing a simulator project that tests several A* based algorithms and show how they work and their results.
The algorithms are all multi-agent and run on a grid map environment.
I used a JPanel for the grid which contains a two dimensional array of Cells where each Cell is a custom class that extends the Component class and use the paint method to draw the stuff i need inside each cell.
For the drawing inside the cell I use method such as Graphics.fillRect or Graphics.drawImage to fill each cell with a certain color or icon).
I'm using a special Icon for the start position and goal position of every agent on the grid.
My problem is that I want to be able to draw more than one item on the same cell.
For example I want to be able to show the path of one of the agents by painting the cells along the path in a special color and the path might go through a start position of a different agent, so I want to be able to fill the cell with the color and have an icon drawn on top.
In another example I want to be able to mix two colors using alpha blending.
If I use graphics.fillRect() with one color that has alpha and then use it again with a different color with alpha value it won't work since the last fillRect() will override the first call.
Is there a way I can achieve what I need using the same Cell Component I created or should I implement it differently?
Perhaps there is a better solution to this problem?
I would really appreciate any advice on this matter.
If you draw a rectangle with 50% alpha and then draw another one, the second one will override it instead of blending with it.
It depends on the mode. This convenient utility shows the result of blending different colors using the modes defined in AlphaComposite. The available source code may offer some insights for your project.
Addendum:
the stuff I was trying to composite was on the same Component.
The example cited does exactly this, as does this example. If AlphaComposite does not meet your requirements, you can always vary hue, saturation and/or value; this example composes a color table based on saturation.

how do I specify a transparent background colour on a draw2d Figure?

I'm writing an eclipse plugin, and I'm layering some simple figures (i.e. view elements) together to create diagrams.
A simple component looks like this
A simple component with rendering issues http://img115.yfrog.com/img115/4946/componentwithopacity.jpg
The drum icon on the right is part of a tiny widget drawer.
And the incomplete line underneath it is trying to represent multiplicity, but it's being blocked by the widget drawer.
I tried really hard to get a transparent background on the Figure, but the SWT colour class has no way to specify an alpha or transparent colour.
has anyone run into this problem before? How can I make my draw2d Figure background transparent so I can see stuff behind it.
This a small example of various other opacity related issues I've encountered. Solving this would fix a wide range of visual issues.
Any help is greatly appreciated.
CV
So IFigure.setOpaque(false) doesn't do it?
Simply set the alpha from 0 to 255 to your liking. See Graphics#setAlpha(int) during your paint event or see Shape - I think setAlpha(int) exists there too.

Categories

Resources