I developed a small desktop application in Java. At some position in my UI I drag and drop a JLabel from Palette to JFrame. Later-on i remove its text by right click -> Edit Text. I did this because i am populating this label dynamically using setText() method. Now i need to reposition this Label, for this i first have to select that label and then drag n drop it to new location. But i am unable to do so because there is no text in that label and hence its not visible :(
Is there any way through which i select this label?
The easiest way is add a few spaces to a label instead of an empty string. You may also put a label inside a panel with layout like Flow or Grid (where you can set margin) and drag the panel instead. If you're using layout like Free Design, Absolute or Null, you may also manually rescale the label (selecting it through Inspector view).
Related
I just want to drag and drop them like in Netbeans.
is there any way to get functionality of Netbeans or Eclipse in IDEA?
I had the same problem and I have solved it. You need to create a new row before dragging any new elements. In the left side you will see small green boxes for each row. Right click on the last row's green box and then choose "Insert row after this". Then you can drag and drop any new elements into your newly created row.
You can drag and drop components and alter on which part of the layout they appear. You might need to split a column if you want the component on only the half of a parent.
See: https://www.jetbrains.com/idea/help/placing-gui-components-on-a-form.html
But to set some minimum size or set if a component should grow, you need to look into properties panel of a selected component (on the left).
See: https://www.jetbrains.com/idea/help/setting-component-properties.html
I have a j tree in the left side of the window, I want to make every node in it have a different content when clicking on it. but with in the same window.
(example: same as what we have in our computers, downloads, documents, pictures, ...etc )
I want to know how its done.
And I would like to display a document with a long text and some pictures in some of the nodes, I want to know the best way of doing that.
Place a JPanel that uses a CardLayout in the center of your window. Then add each node's content to that panel. CardLayout shows only one of its children at a time, and will always have a preferred size that accommodates all of the children, both visible and invisible.
Display long text using a JTextArea (if it's all in the same font), a JEditorPane (if it's predefined HTML that you are packaging with your application), or a JTextPane (if the text is dynamic, and has images and/or uses multiple fonts). All of those should have setEditable(false) called on them, and should be placed in a JScrollPane.
Is the above question possible? The effect I'm trying to achieve is similar to how MS Word displays "Document- Microsoft Word (Technical Preview)" in this picture link: http://img.blogsolute.com/ms-word-2010.png, but with a colored background.
You can set the title of any frame you create by passing the title string to the constructor of the JFrame. You can't, however, add any controls to the 'decoration' portion of the frame - i.e., the title bar.
What you probably can do, however, is create an undecorated frame, and manually add the decoration using customised Border objects. This effectively allows you to put any controls you like around the outside, and the root pane will happily work inside it.
Why do you need JLabel for that? You can use setTitle("") for this purpose
JTable Header contains Image and on top of that image I want to place 3 buttons in a single header. My requirement is to Create a "Play List" table in which user can add their favourite songs.
So in the header I want to put a "Play List" title and "+" button to insert new playlists and "Export" and "Import" buttons.
How I can do that? Thanks in Advance.
I doubt(1) this use-case actually calls for cramming extra components into a JTable header. E.G. Take the UI of DukeBox.
We can see the play list on the left (a JTable) with a Filter text field and Random check-box above it, and the Enqueue & History buttons below.
This was created with a nested layout. The 'outer layout' is BorderLayout, that panel has the table in the CENTER, and nested panels in the NORTH & SOUTH. The NORTH panel has another BorderLayout, while the SOUTH uses a GridLayout.
If using a nested layout does not give you some ideas, I suggest you post a drawing or better, ASCII art, of the UI as it should appear at the smallest size, as well as a representation of it when it is resized (where is the extra width/height assigned?).
1) I have that suspicion every time I hear words to the effect "Wouldn't it be great if we had a component that..?". Of course, there are some classic counter-examples where the standard widget tool-kit seems lacking (e.g. a date picker or switch list), but these are common components to which a name can be put. If the person asking cannot put a 'catchy name' to the custom component, there is a good chance they are over (or under) thinking the matter.
I want to create chat window with textarea and textbox in lwuit. Textarea must capable to show smiley and coloring text. I have used HtmlComponent of lwuit and facing problem in scrollbar. As text content grows in size, whole screen scroll including textbox. I want only content of textarea to be scrolled.
How to solve it?
well, you can forbid scrolling for the whole form using
Form.setScrollable(false).
Then you just set your HTMLcomponent scrollable "true" with the same method and finally put these two components (TextArea and HTMLComponent) to a different cosntraints (e.g. TextArea in BorderLayout.NORTH and HTMLComponent in BorderLayout.CENTER)