How can I add image in list of itextpdf? - itext

this is my simple code below, I want to add a image to my list, but it doesn't work, and what i should do if I want add image with the String "item 2" have the same list, anybody has some advice? thanks so much!
Image image = Image.getInstance("xx.jpg");
List unorderedList = new List(List.UNORDERED);
unorderedList.add(new ListItem("Item 1"));
unorderedList.add(new ListItem("Item 2"));
unorderedList.add(image);
document.add(unorderedList);

I have done it ! because class ListItem extens class Paragraph, so we can write
Paragraph a = new ListItem(); a.add(image); unorderedList.add(a);
Then the image can be added in List.

Related

How do i set the scrollbar in JScrollPane to the top? Using borderlayout. the bar always scroll to the bottom of my content.

//created a JScrollPane and when i run it the scrollbars will automatically go to the most bottom of my textarea, but i need it to be on top.
thank you in advance! =)
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(22, 86, 262, 57);
content.add(scrollPane);
//the text area used
JTextArea txtrTryingTryingTrying = new JTextArea();
scrollPane.setViewportView(txtrTryingTryingTrying);
txtrTryingTryingTrying.setText("-------");
I've been trying as well, and found a solution.
There is a useful method called: setCaretPosition(int)
After you use
component.setText("Text here");
You must use
component.setCaretPosition(0); //0 will set it to the top
In your case, you must add setCaretPosition() after setText
JTextArea txtrTryingTryingTrying = new JTextArea();
scrollPane.setViewportView(txtrTryingTryingTrying);
txtrTryingTryingTrying.setText("-------");
txtrTryingTryingTrying.setCaretPosition(0);

SmartGWT expanding Tree till a child node

I have created a tree using the following code. Is there a way to expand the tree till a particular child node from the code?
TreeGrid treeGrid = new TreeGrid();
Tree tree = new Tree();
tree.setRoot(new TreeNode("root", new TreeNode("File",
new TreeNode("FileChild")), new TreeNode("Edit", new TreeNode(
"EditChild", new TreeNode("EditGrandChild"))), new TreeNode(
"Window")));
treeGrid.setData(tree);
treeGrid.draw();
I want to display the "EditGrandChild" node when the tree is rendered. How do i do that?
Thanks
I used to open some parts of a treegrid depending on the result of a search and I used this bits of code
TreeNode[] tabNode = leTree.getParents(t);
leTree.openFolders(tabNode);
Hope it could help...

Google Maps V3 Resize

I'm new to gwt-maps-3.8.0 v3, if i try to display maps in multiple windows, it is not displaying fully, instead, it shows half of the map in window. Please check my code, and tell me whether anything is missing..
public class MapTest extends HorizontalPanel {
GoogleMap map;
VerticalPanel mapVp = new VerticalPanel();
public MapTest(){
mapVp.setSize(String.valueOf(BodyPanel.bodyWidth - 505),
String.valueOf(BodyPanel.bodyHeight + 5));
LatLng myLatLng = LatLng.create(30.440099, 36.843498);
MapOptions myOptions = MapOptions.create();
myOptions.setZoom(5);
myOptions.setCenter(myLatLng);
myOptions.setMapTypeId(MapTypeId.TERRAIN);
myOptions.setMapTypeControl(true);
map = GoogleMap.create(mapVp.getElement(), myOptions);
add(mapVp)
}
}
TabItem tabItem = new TabItem("MapTest");
tabItem.add(new MapTest());
This shows the full map... When i do the same code and add that in another tab, it reduces the map size.. Trying to resolve this, pls help...
i.e, Again initializing the tabitem and trying to add the same page in other tab as
tabItem = new TabItem("MapTest");
tabItem.add(new MapTest());
I solved this by adding a Delay in loading maps using GWT Timer.. Referred Joomla Solution and implemented in GWT...
Here is link

Label on HeaderIcon in HeaderControls

I want to put a label next to an icon so user can better understand what is this clickable icon for.
This icon appear in the HeaderControl of a com.smartgwt.client.widgets.Window
String promptNewThing = "Add some thing";
String imgNewThingText = "../servlet/servletOperation?cmd=Icon&time=" + System.currentTimeMillis() + "&text=" + promptNewThing;
HeaderIcon iconNewThing = new HeaderIcon("buttons/new.png");
HeaderIcon iconNewThingLabel = new HeaderIcon(imgNewThingText);
newThing = new HeaderControl(iconNewThing, clickHandlerNewThing);
newThing.setPrompt(promptNewThing);
newThingLabel = new HeaderControl(iconNewThingLabel, clickHandlerNewThing);
newThingLabel.setPrompt(promptNewThing);
setHeaderControls(HeaderControls.HEADER_LABEL, NewThing, NewThingLabel, HeaderControls.MINIMIZE_BUTTON, HeaderControls.MAXIMIZE_BUTTON, HeaderControls.CLOSE_BUTTON);
For information : In this code, Servlet URL return an image made from the text promptNewThing
But iconNewThingLabel is an Icon which has the width of an Icon, too small.
The result of this code :
The small white square we can see between first Icon is newThingLabel.
Is there a way to add a label at the right of an HeaderIcon ?
For example I would to have something like :
Hello Manu I have done the same thing as you have done. The only change is instead of adding HeaderIcon (iconNewThingLabel in your case - if it's representing the text), I have used a com.smartgwt.client.widgets.Label & added that as a headerControl. Code snippet is as follows:
Label label = new Label("test header");
setHeaderControls(HeaderControls.HEADER_LABEL, NewThing, label, HeaderControls.MINIMIZE_BUTTON, HeaderControls.MAXIMIZE_BUTTON, HeaderControls.CLOSE_BUTTON);
Let me know if this helps you.

GWT - Can you nest FormPanels inside FormPanels?

I'm trying to nest a FormPanel inside another FormPanel. It seems that any field in the nested panel is never rendered.
This screenshot is produced by the code below it:
TabItem tabItem = new TabItem("Tab Item");
FormPanel formPanel = new FormPanel();
formPanel.setHeading("Form Panel");
formPanel.setFrame(true);
TextField textField = new TextField();
textField.setFieldLabel("Text Field");
FormPanel nestedPanel = new FormPanel();
nestedPanel.setHeading("Nested Panel");
TextField nestedField = new TextField();
nestedField.setFieldLabel("Nested Field");
nestedPanel.add(nestedField);
TextField anotherField = new TextField();
anotherField.setFieldLabel("Another Field");
formPanel.add(textField);
formPanel.add(nestedPanel);
formPanel.add(anotherField);
tabItem.add(formPanel);
tabPanel.add(tabItem);
Can anyone explain why the nested field does not show in the nested panel?
I've also tried using a CaptionPanel instead of a FormPanel as the nested panel, but the caption panel does not show the field label.
Any suggestions as to how I can get this to work would be most welcome. Thank you :)
As Jason mentioned, <form> cannot be nested. The GXT FormPanel draws a form as part of how it works, so consider drawing this layout in another way.
To emulate the appearance of the FormPanel, there are two basic steps.
To get the header, border, create a ContentPanel, and add the content to that
To get the GXT 2 layout of drawing the field labels, use a FormLayout in the content panel.
This will look something like this (from your example)
//...
ContentPanel nestedPanel = new ContentPanel(new FormLayout();
nestedPanel.setHeading("Nested Panel");
TextField nestedField = new TextField();
nestedField.setFieldLabel("Nested Field");
nestedPanel.add(nestedField);
//...
The outer field will still manage any binding, and the nested field will look as if they were in a FormPanel. If not using other features of the FormPanel, it may in general make more sense to use a ContentPanel (or LayoutContainer, if you don't want the border/header) with a FormLayout.