# ToolWindows: main focus component, and resizing

**URL:** <https://platform.jetbrains.com/t/toolwindows-main-focus-component-and-resizing/1262>\
**Category:** IntelliJ Platform\
**Created:** [April 7, 2025, 7:10pm UTC](https://platform.jetbrains.com/t/toolwindows-main-focus-component-and-resizing/1262 "2025-04-07T19:10:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeremibg](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@jeremibg](https://platform.jetbrains.com/u/jeremibg)\
**Post date:** [April 7, 2025, 7:10pm UTC](https://platform.jetbrains.com/t/toolwindows-main-focus-component-and-resizing/1262/1 "2025-04-07T19:10:20Z")

</div>

# Question 1

I noticed that when I open my ToolWindow, it focuses on the first focusable component of the JPanel that it contains.  
Is there a way to control which JComponent gets the focus?  
My JPanel has a dropdown select, and then a text field. I want the text field to be the one that gets focused.

# Question 2

Regarding resizing my ToolWindow which is on the right-side of the IDE, for some reason:

- When enlarging it, it appropriately gets my JPanel and its content to expand and take up more space
- But when shrinking it, the JPanel doesn’t appear to become smaller: instead all components get their right-side cropped

Any ideas what might be causing this?

---

<div class="post-metadata">

**Author:** ![yann.cebron](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/yann.cebron/32/15_2.png) [@yann.cebron](https://platform.jetbrains.com/u/yann.cebron)\
**Post date:** [April 8, 2025, 7:28am UTC](https://platform.jetbrains.com/t/toolwindows-main-focus-component-and-resizing/1262/2 "2025-04-08T07:28:46Z")

</div>

1. `com.intellij.ui.content.Content#setPreferredFocusableComponent`
2. What else would you expect?

---

<div class="post-metadata">

**Author:** ![jeremibg](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@jeremibg](https://platform.jetbrains.com/u/jeremibg)\
**Post date:** [April 8, 2025, 10:18pm UTC](https://platform.jetbrains.com/t/toolwindows-main-focus-component-and-resizing/1262/3 "2025-04-08T22:18:47Z")

</div>

> [@yann.cebron](#):
>
> com.intellij.ui.content.Content#setPreferredFocusableComponent

This worked great, thanks!

> [@yann.cebron](#):
>
> What else would you expect?

The content expands properly when the toolwindow grows in size.  
I’d expect the content to shrink back down properly when the toolwindow reduces in size.

---

<div class="post-metadata">

**Author:** ![yann.cebron](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/yann.cebron/32/15_2.png) [@yann.cebron](https://platform.jetbrains.com/u/yann.cebron)\
**Post date:** [April 9, 2025, 7:29am UTC](https://platform.jetbrains.com/t/toolwindows-main-focus-component-and-resizing/1262/4 "2025-04-09T07:29:19Z")

</div>

AFAIU that would depend on the LayoutManager and its settings for your main panel.
