1

Which components, containers or layouts should I use to have left hand side click-able folder structure as shown in the picture? Is it possible to do it with Swing?

left hand side = place which marked as favorite.

As an second question, how can I put search icon in the jtextField like shown in the search place, top-right-hand-side?

enter image description here

Hevan
  • 157
  • 1
  • 15
  • I have tried to put JPanel then put Jtree on it, but formed windows does not look like as in picture. – Hevan Aug 24 '14 at 17:19
  • 1
    see this http://codereview.stackexchange.com/questions/4446/file-browser-gui – blackbishop Aug 24 '14 at 17:34
  • @blackbishop As I said, I donot want tree representation. I want what favorite section graphically has. Your link totally based on tree representation. – Hevan Aug 24 '14 at 18:07

2 Answers2

0

I have found how to hack JtextField with icon and search key. In this website, it tells how to put icon on text field.

Hevan
  • 157
  • 1
  • 15
  • I took a quick look at the link you provided for the icon text field and I don't like that the `setMargin()` method is used in the `paintComponent()` method. A painting method should be for painting only and should not change a property of the component. Changing a property can result in an infinite loop since the component automatically tries to repaint itself whenever a property is changed. – camickr Aug 24 '14 at 19:12
0

You would probably use a JList or JTable to display the folder names. Read the appropriate section from the Swing tutorial on How to use Lists and How to Use Tables for more information. You would need to create a custom renderer to display both the icon and the text. Then you can add a ListSelectionListener to handle the selection of a specific folder.

Also for the icon in the text field you could check out ComponentBorder or Text Prompt for possible solutions.

camickr
  • 321,443
  • 19
  • 166
  • 288