jtabbedpane

java actionlistener on a tab

对着背影说爱祢 提交于 2019-12-02 02:13:59
问题 Is it possible to put an actionlistener on a tab in swing? If it is please could you post a small example? 回答1: The only way to do that is to add a javax.swing.event.ChangeListener to the JTabbedPane itself. You might have to keep track of the selected tab vs. previously selected tab depending on what you are doing with the state change... 来源: https://stackoverflow.com/questions/4443559/java-actionlistener-on-a-tab

Size issues with JTabbedPane and fixed height content

旧街凉风 提交于 2019-12-01 23:56:12
While writing this question I have been able to find a way to get it to behave the way I wanted. Based on this , I am still posting the question as other people might face similar issues. I have the following issues with the sizing of a JTabbedPane used for content that stretches horizontally but has a fixed height. Both options for setTabLayoutPolicy() seem to alter the height of the content and won’t consistently display it at its preferred or minimum height. With the default WRAP_TAB_LAYOUT , the preferred size of the tab pane does not take into account whether the tabs are actually stacked

Fire stateChanged event on JTabbedPane

我们两清 提交于 2019-12-01 23:18:07
I have JTabbedPane with fade animation, which is performed when user clicks tabs. To handle animation I override stateChanged method. public class AnimatedJTabbedPane extends JTabbedPane implements ChangeListener, TimingTarget{ /** * */ private static final long serialVersionUID = 1L; protected BufferedImage previousTabImage; protected BufferedImage bufferImage; protected BufferedImage nextTabImage; protected boolean animationStarted = false; protected boolean paintPreviousImage = false; protected boolean leftToRightIndex = false; protected float fraction = 0.0f; protected Animator animator;

MouseEvents for a JTabbedPane Tab component are not bleeding through

瘦欲@ 提交于 2019-12-01 21:19:55
I have a JTabbedPane with a custom tab component. That component contains a JLabel (To display the tab title) and a JButton (A close button). When I change the text in the JLabel the JLabel stops receiving mouse events and I can no longer select that tab when I click directly on the label instead if I click around the label then I can select the tab. Any ideas? A snippet of the code: class ShellPanelTabComponent extends JPanel implements ActionListener{ private ShellPanel panel; private JLabel label; public ShellPanelTabComponent(final ShellPanel panel){ super(new FlowLayout(FlowLayout.LEFT, 0

Closeable JTabbedPane - alignment of the close button

会有一股神秘感。 提交于 2019-12-01 17:06:06
I have implemented my own closeable JTabbedPane (essentially following advice from here - by extending JTabbedPane and overriding some methods and calling setTabComponentAt(...)). It works perfectly except one thing - when there are too many tabs to fit on one row (when there are 2 or more rows of tabs), the cross button/icon is not aligned to the right of the tab but it remains next to the tab title, which looks ugly. I've tried the demo from Java tutorials and it suffers from the same problem. What I want is that the cross button/icon is always aligned to the very right, but the text is

JTabbedPane: Components before and after the tabs themselves

蹲街弑〆低调 提交于 2019-12-01 14:56:46
This is similar to the question How to build a Google-chrome tabs and menubar interface in Java Swing? (I want to accomplish the same), but more to the point: How do I put components in front and behind the tabs in a JTabbedPane? I've already come up with the buttons-idea myself, but I'd rather have a JTabbedPane, since that is really what it is, but decorated with a button or icons on the sides. I've seen that the laf-widget project from Kirill does something like it (the magnifying-glass icon to the left of the tabs) for several LaFs. However, I must admit that I'm not yet well enough versed

JTabbedPane: tab placement set to LEFT but icons are not aligned

こ雲淡風輕ζ 提交于 2019-12-01 14:38:06
I have a JTabbedPane with tab placement set to LEFT. The problem is that icons in each tab are not vertically aligned with one another. Consider this picture: As you can see the icon of "Editar Protocolo" (second tab) is not perfectly aligned with the icon of "Distribuir Protocolo" (first tab) and this also happen with the other tabs. I want all icons be vertically aligned to the left. This is the code I'm using to set tab components: ... jtabbedPane.setTabComponentAt(1, configurarJtabbedPane("Editar Protocolo", iconEditarProtocolo)); ... public JLabel configurarJtabbedPane(String title,

JTabbedPane: Components before and after the tabs themselves

守給你的承諾、 提交于 2019-12-01 13:21:45
问题 This is similar to the question How to build a Google-chrome tabs and menubar interface in Java Swing? (I want to accomplish the same), but more to the point: How do I put components in front and behind the tabs in a JTabbedPane? I've already come up with the buttons-idea myself, but I'd rather have a JTabbedPane, since that is really what it is, but decorated with a button or icons on the sides. I've seen that the laf-widget project from Kirill does something like it (the magnifying-glass

Colorize a tab in a JTabbedPane using java swing

痴心易碎 提交于 2019-12-01 10:57:34
I am trying to change the background color of my tabs in a JTabbedPane . I tried JTabbedPane.setBackgroudAt(0, Color.GRAY) and JTabbedPane.setBackgroud(Color.GRAY) and the foreground too, but nothing happens. I changed the background of the panel inside the tab, still nothing. Edit 1: I'm using UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); if this can help with the solution Edit 2: Link to a example, https://www.dropbox.com/s/0krn9vikvkq46mz/JavaApplication4.rar mKorbel most of method for JTabbedPane is protected in the API, and not accesible from Swing

JTabbedPane: avoid automatic re-ordering tabs if stacked / Nimbus

旧城冷巷雨未停 提交于 2019-12-01 08:56:41
a JTabbedPane is just what I need for my purpose. I have very limited horizontal space, so my Tabs get stacked, which is perfectly ok. But the default behaviour is that if user clicks on a Tab, the * Tabs get re-sorted so that the active Tab becomes the lower-mos *t. What looks very intuitive and logical in theory, is a nightmare in practical use, because the users loose track of "which was which". Its just simply plain confusing, I am told again and again. I guess it should be possible to override some method of the UI to avoid this behaviour (and I dont care whether this would be physically