I wanna hide this little white-thing on the JTable - java

The picture shows a thin (1 pixel?) white margin (marked in blue) inside the border of a JTable.
How can the margin be eliminated, or the colour be changed?
I have tried:
Changing the JTable
Changing the ScrollPane
I set both to opaque without success.
Thanks for help.

The sides there are simply the border set by whatever JComponent its contained in. Remove the border (or change it to a line border for instance) and that style will go away. :)

Related

JScrollPane: Blinker(cursor) is covered by the border

I am working on my own little text editor. Files can be edited in a JScrollPane, now if a line of text is longer than the window, you can scroll to the right as it is ment to be. But when the Blinker(or whatever it's called) is at the very end of the line, it's not visible because it seems to be covered by the border.
//the JTextArea is inside the JScrollPane of course
Border scrollPaneBorder = new LineBorder(interfaceColor, 8, true);
Border textAreaBorder = new LineBorder(backgroundColor, 4, true);
Setting both borders to 0 won't change anything. Has anyone got a way to deal with this problem?
The most elegant solution in my opinion is the one in Notepad++. There it somehow puts some space between the text and the border as soon as you get close to the border. But I don't know how/if this is possible in java.
Whatever solution, thanks for the help guys.
From the documentation of setMargin:
Sets margin space between the text component's border and its text. The text component's default Border object will use this value to create the proper margin. However, if a non-default border is set on the text component, it is that Border object's responsibility to create the appropriate margin space (else this property will effectively be ignored).
It’s a bit strange that Swing’s text component will move the cursor up to a location that is covered by the painted Border if there is no margin, but it explains why the problem occurs when you set a custom Border but not with the default border as the default value for the margin property is non-zero.
You can create a custom border that reads the margin property and implements an unpainted inner region of that size or, if you don’t need support for different values for the margin property, you can just combine your border with an empty border to get a similar effect (of a hardcoded margin space):
Border textAreaBorder=BorderFactory.createCompoundBorder(
BorderFactory.createLineBorder(backgroundColor, 4, true),
BorderFactory.createEmptyBorder(2, 2, 2, 2)
);

Customize column header of a JTable

I am using a JTable to display data with custom TableCellRenderer.
Everything works fine despite there appears a small "area" in the right upper corner when having a vertical scrollbar. I want to render that area transparent, is this possible?
I want to render that area transparent, is this possible?
Not really sure what you mean. That area is rendered transparent. All you see is the background of the scrollpane.
However you can place your own component in that area if you wish. Check out the section from the Swing tutorial on Providing Custom Decorations for a JScrollPane.
The example shows how to add a custom component to the top/right of the scrollpane using:
pictureScrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, new Corner());

JBorder doesn't display right

I have an application that uses a JLabel and a JPanel. These components have a MatteBorder. When the components are created, the border is the default. When I click on the components, I set the border to a different thickness to make a select appearance. The problem comes when I want to unselect and I set the border to another thickness. This time the border is not modified and looks the same.
I'm not seeing what the problem is, because the first modification of the border thickness works fine.
Although this might be a hacky approach, try to repaint() the view, sometimes it just glitches.
I read this:
http://docs.oracle.com/javase/tutorial/uiswing/components/border.html
when working on my program.

Draw a Jpanel's border without resizing content (Java)

I have a column of JPanel instances that has content in it, that when it is clicked, the selected Panel is set to have a border (in order to distinguish it), and only 1 at a time has the border.
The problem is that when it sets the border, it sets the outer section of the panel to the border, and shrinks the content inside. Although it seems minor it is not very professional, and I would much rather have it add more like an overlay, where the content will not shrink.
I am thinking maybe there is some method of graphics that will let me do this? I haven't been able to find any way of doing this.
Start by setting all the components to have a EmptyBorder set to a single pixel inset.
When you select a panel, simply set the newly selected panel's border as you are (presumably using a LineBorder) and the set the previously selected panel's border to the single pixel EmptyBorder.
If you're clever, you could get away with a single instance of EmptyBorder ;)

Scrolling issues with a TextArea in LWUIT

I have a TextArea in LWUIT that I am having an issue manipulating. I have the following two issues:
Even though I call setIsScrollVisible(true), I do not seem to have a
scrollbar and cannot scroll when the output goes below the visible
area of the container.
How do I tell the TextArea to automatically scroll to the bottom
programmatically?
My code for initializing the TextArea looks like this:
myTextArea = new TextArea(20, Display.getInstance().getDisplayWidth());
myTextArea.setEditable(false);
myTextArea.setEnabled(true);
myTextArea.setIsScrollVisible(true);
myTextArea.setGrowByContent(false);
System.out.println(myTextArea.isScrollableY());
isScrollableY() returns true. Any ideas? Is there something I am missing? There doesn't seem to be anything visible in the API that lets me explicitly enable or disable scrolling. Thanks in advance for any assistance on this.
The width of the text area is in columns NOT pixels as you have in your code.
Setting the scroll to visible won't cause it to appear since LWUIT scrollbars are always "as needed" which means a scrollbar will only appear when necessary, setting this value to false would just hide the scrollbar regardless of necessity.
To have the text area grab the entire width just place it within a box layout Y container/form and the layout manager will stretch it on the X axis.
You can use scrollRectToVisible() to scroll the text area to the bottom or alternatively you can derive text area and use setScrollY(int) with the appropriate value (see the source code of text area for how this is used to scroll the text area.
Try a simple textArea.setFocusable(false). This worked for me.

Categories

Resources