How to switch the right side of the Jsplite between blank/JTabbedPane - java

I have a Jsplitpane where on the left side I show a list and on the right side there is JTabbedPane. If I click on a list item, then the JTabbedPane will update the info. Everything works good.
Now my question is, when no list item is clicked on ( so basically when you run it first time), then I want to to replace the JTabbedPane with empty panel (blank right side). I tried to do setVisibility to be off on the JtabbedPane but then the divider is pushed all the way to the right. Is there a quick way to just make this JtabbedPane blank and then somehow make it appear later on. Here are screenshots to better explain the situation:
Fully functional window
What I want when no item is clicked
What happens if no item is clicked

Related

New screen-tabs after user signs in

In GUI NetBeans I have JFrame with a JTabbedPane. There are 3 tabs on the top, each one for a different user. Each tab has JPanel where user have to enter password. After the password is verified I got rid of the other two tabs by asking tabbed pane to remove other two tabs by a method `remove(), since once the user is signed in other two users tabs are not relevant anymore.
Now I'm left with only one tab, however after a user had signed in I want that user to see new tabs - panels, while removing the previous tabs I don't know how to put this into code since I don't know where I should create the new screen with tabbed pane that will become visible to the user.
I tried to add another JTabbedPane, to a frame alongside the first tabbed pane, and make it not visible until user is verified, while the first tabbed pane is removed, however in a NetBeans design window the new pane is on top of the first one so I cant add components to a new tab pane.
I know Im not doing it in the correct way. Can somebody give me advice on how to code solution for getting new tab screen for the user who has signed in?

make tab keyboard button jump from right to left

CASE:
create jpanel
add a few textbox horizontally
set panel to setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)
PROBLEM:
when running, focus on one textbox and press tab button , the focus will jump from left to right , how do i make it jump from right to left?
FOLLOW UP:
say I want one component to be skipped, I can catch the on focus event for this component, but can i issue an automated additional tab click to jump to the next component ?
Thanks a lot for any help.
Check out FocusTraversalPolicy.
Here's an example.

Java Open a JFrame relative to the position of a button (menu like behaviour)

I am trying to implement expand functionality like in below example, however instead of a menu I am using a JFrame which contains more sophisticated GUI elements.
The problem I run into is that if I move the parent window which contains the button below which the frame should appear, I can not adjust my custom JFrame to open each time relative to the position of that button
initially I simply used
myCustomFrame.setLocation(myButton.getX(), (myButton.getY() + 73));
but this obviously doesn't work if I change move the parent window
After that I tried
myCustomFrame.setLocationRelativeTo(myButton);
but in this case it appears at the top of the button... I adjust the position for a particular case, but this is not a solution.
So I am trying to get the same behavior as menus have, such that the position of the JFrame is automatically adjusted.
Does anyone have any suggestions?
Have you considered using myButton.getLocationOnScreen()? That way no matter where you move the jFrame containing the button you will always get the Point of your button measured from the top left corner of the screen.
You could alter your original method something like this:
myCustomFrame.setLocation(myButton.getLocationOnScreen().x, (myButton.getLocationOnScreen().y + 73));

Java JComboBox control scrollbar position?

I'm working on a simple java program (using NetBeans' swing GUI builder). You're supposed to select a randomly placed item from the JComboBox as fast as you can, then it will tell you your time and save it (keeping statistics and whatnot).
Problem is, once you select an item and go back to find a different item (in a new random position in the JComboBox), the scrollbar seems to have remembered it's previous position.
Since this game is supposed to be competitive, it wouldn't really be fair for the scrollbar to be in the previous player's position.
Is there any way to set the position of the scrollbar in a JComboBox?
P.S. it's a vertical scrollbar. Also, I did try to find the answer online, but couldn't find it after over two hours of searching. Any help appreciated!
Select the first item so the scrollbar goes back to the top, then set the selection to -1.
comboBox.setSelectedIndex(0);
comboBox.setSelectedIndex(-1);

How do I get a button to align to the right in MigLayout

I am adding a button to a panel using Miglayout, and try what I might, I cannot get it to go to the right end of the panel. It insists on going flush left. Oddly, the demo is kind of short on such on a example (it only shows it in the context of other buttons on the same panel.
I have a panel like this:
dialog
->complex display retrieved from another class
OK Button here.
Except that it always insists on putting it like this:
dialog
->complex display retrieved from another class
OK Button here.
OK, I got the answer to this (finally). When adding the panel that contains the button add the component constraint of "gapbefore push." I had been trying that, but only on the button itself, not the panel.
panel.add(button, "skip(the amount of cells you have), al 100%")

Categories