How to change the font in the grid GXT3 - java

Sorry for the simple question, how to change the font in the grid?

If you are talking about the text which might be displayed in one of your columns, you can do this easily with cells. When you set up your ColumnModel class, you can pass a custom cell to one of the columns. Then, with html and css, you can style up the column per your needs.
If you want to change the column headers, then you can simply pass some SafeHtml to that column's ColumnConfig.setHeader(SafeHtml) method. Again, this would be done when you set up your ColumnModel. This let's you style up the header however you wish.
If you do use images or css, I highly suggest using the ClientBundle and CSSResource classes.

Related

Change color of natTable rows based on an RGB value stored in the ModelObject

I am trying to change the color of the rows in my NatTable based on an RGB value stored in my Model Object. I have found information on how to set custom styles in my NatTable, but these all seem to use predefined labels, not ones based on dynamic values.
//add custom cell label to cells that contain value AAA in column 2
CellOverrideLabelAccumulator cellLabelAccumulator
= new CellOverrideLabelAccumulator(gridLayer.getBodyDataProvider());
cellLabelAccumulator.registerOverride("AAA", 2, CELL_LABEL);
// Register label accumulator with the data layer
bodyDataLayer.setConfigLabelAccumulator(cellLabelAccumulator);
CELL_LABEL is a string that links to a prebuilt label.
The styling concept in NatTable is based on the mechanism you already found. You attach labels to cells (typically for some special conditions) and register styles for that labels. This way NatTable achieves separation of styling and content.
As your approach is to keep styling information and data in one model object, you need to find a way to get that into NatTable.
Basically you need to register a label to represent your model object somehow. And then register a style for that label that contains the background color information of your model object.

Make String look like url in TableModel

Hello im making a program and using TableModel. I have 6 column filed with string's. I want the sixth column string make it look like URL. When i mean look like URL , i mean turn it into blue and be underlined. Is it possible to do that?
You need to write custom TableCellRenderer for your jtable. See this link.This may be helpful for you.
Sun had a very good tutorial (http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#modelchange) on cerating jtable. just go through it before you start. hope this tutorial will help you.
But below is my suggestion.
("<html><b><u>link</u></html>");
<html><b>bold</b></html>
a similar kind of thing
However, I wouldn't recommend altering the data in your model just to effect display. Instead I would create a custom cell renderer which accomplishes this effect and set it on the table. You could either wrap your text in the HTML or manually set font color and style properties on the renderer to mimic html.
Now even if you were to include the url in the html you still can't click on it. There is no component in the table. You don't really want to go into edit mode when clicking on a url. You just want to open that link. To accomplish this you would add a mouse listener to the table itself. When you receive a click event, you would then programatically determine which cell it was over, go back to your model and get the url, and finally use other Java API calls to open that url.
I'm pretty sure you can simply create a string containing
<html>...</html>
and it will work. Just code your link inside the html tags as you would in html. You'll just have to add extra code if you want it to appear blue. I think:
<font color='blue'>
would do it

GWT TextColumn in CellTable with multiple lines

I'd like to display informations about a book in a CellTable in GWT. For example its content.
How can i create a TextColumn that displays that much text. Multiple lines or a scrollbar is what i'm looking for.
Thanks in advance
If your content is plain text, you can put it in TextColumn. It will wrap within a cell, unless some CSS prevents wrapping.
If you want to set a limit on how high a cell can be, add a CSS rule to this table:
.myTable tr {
max-height: 100px;
}
If you have formatted text, you will need to create your own Cell by extending AbstractCell:
https://developers.google.com/web-toolkit/doc/latest/DevGuideUiCustomCells

Create a properties frame in Java

I am trying to make a properties frame just like the one in netBeans (or Visual Studio). My problem is that I don't know exactly how to design it. First I thought I'll make it with JTable (2 columns, multiple rows) but then I realised that on the second column I will have different types of values (booleans, String, color choosers, etc.), but I think that JTable allows only 1 type of data to be placed in a column.
I would like someone to tell me "JTable allows multiple data types on the same column" and show me how to do it, or tell me a different approach to the problem.
You can perfectly tell a JTable to have a column that contains Object, this way you will be able to put whatever ou want in.
BUT.
You'll then have to implement a very good TableCellRenderer/TableCellEditor pair in order to display whatever the cell contains.
Another option would be to use a Grid or GridBag layout inside of a JScrollPane, then dynamically populate the cells of the grid with different editors depending on the data type of the property.
If you can use external libraries, the JGoodies FormLayout is really suited to create such dialogs. Just take a look at the screenshots in their demo.
There is also a rather good PDF available containing with some examples and explanations.

how to obtain excel-like JTable headers

I would like to create a JTable whose global layout would look somewhat like excel's.
To get this result I used the Groupable Header's code from crionics.com, but as you can see components of the header are not aligned vertically.
Moreover, I would like to be able to write multi line text in the rows of the documents where it's needed, but I am not able to get both multi line cells, multi line header cells, and groupable columns to work at the same time.
Look into the JIDE Grids. If you are working for commercial project, it's cheaper to buy these kind of things than write them yourself.

Categories