jtabbedpane

JScrollPane inside JPanel inside a JTabbedPane is not scrolling

对着背影说爱祢 提交于 2020-01-05 12:00:04
问题 I have this JPanel called CatalogPane, which is of size 800 by 600, which is inside a JTabbedPane inside a JFrame called BookFrame. So inside the CatalogPane, I created a JPanel called bookDisplay which displays a list of books and their details. I want it to be of size 780 by 900, leaving 20px for the scrollbar and taller than the frame so that it can scroll. Then I created a panel of size 800 by 400 because I need to leave some extra space at the bottom for other fields. I tried creating a

JTabbedPane why is there extra padding only when I have multiple tabs? (code and picture)

主宰稳场 提交于 2020-01-04 04:12:06
问题 I have a JTabbed pane, which has a varying number of tabs. When the number of tabs is greater than 4, I get extra spacing/padding at the bottom of each tab panel. The picture below shows this (on the left you see the extra spacing, on the right you see no extra spacing). Here is the exact code I used to get those pictures: import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JOptionPane;

Groovy SwingBuilder : controlling the style of the tabs titles in JTabbedPane

被刻印的时光 ゝ 提交于 2020-01-03 02:48:11
问题 I can't find a way (is there any ?) to format the style of tabs titles in a JTabbedPane. I can change the background color of the tab panes (see below), but can't find a way to style the titles of the tabs; I would like to have them bold or red or be able to define the tabs width, for instance, like I could format the style of the labels in the first panel. Here's the code, mostly inspired by tim_yates (Groovy SwingBuilder : using a scrollpanel to show a list of panels) : import groovy.swing

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

不羁岁月 提交于 2019-12-30 13:51:27
问题 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

Colorize a tab in a JTabbedPane using java swing

喜欢而已 提交于 2019-12-30 11:00:16
问题 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

JMenu work on single tab

こ雲淡風輕ζ 提交于 2019-12-25 17:47:06
问题 I have a JMenuBar and I have a JTabbedPane , when I create multiple tabs the JMenuBar does it on all the tabs, e.g. I open a file it opens the same file in each tab. However I only want it to open a file on the current tab. I have added a ChangeListener so It know what tab its in however it does not seem help even though it works. tabbedPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { System.out.println("Tab=" + tabbedPane.getSelectedIndex()); } });

JTabbedPane in Windows L&F with unremovable border

泄露秘密 提交于 2019-12-25 08:17:42
问题 I'm writing a Swing program using JTabbedPane (containing a JScrollPane) and the Windows look and feel. When the JTabbedPane renders with Windows L&F, it places a two pixel white line to the left, and a one pixel white line on the bottom of the Component (see attached image). Is there a way to remove this? Adding (or removing) a border only places one around the outside of the lines. I've looked at writing my own UI for this particular component, but I'm not sure where to start exactly (let

Tabs with equal (constant) width in JTabbedPane

此生再无相见时 提交于 2019-12-24 08:59:22
问题 I'm trying to get a JTabbedPane where all tabs (the actual tabs, not the components) have the same width (either the minimum width needed for the widest label or a constant width). I've tried to override BasicTabbedPaneUI.getTabBounds(int tabIndex, Rectangle dest) , but apparently this method isn't used by the painting methods of BasicTabbedPaneUI , instead it uses a rects array to determine the tabs size. My next approach would be to override JTabbedPane.insertTab(String title, Icon icon,

Bringing tab to front in JTabbedPane

妖精的绣舞 提交于 2019-12-24 06:24:35
问题 When I use setSelectedComponent or setSelectedIndex on a JTabbedPane object, the panel always comes up in my UI. However, sometimes the tab associated with the panel remains hidden. In other words, the tab does not scroll to a visible portion of the tabbed pane. How can I fix this? I have tried the cheesy select one index, then select desired index, as well as several other more elegant things, but arrrrgh!! Help me if you can. Thanks, Todd 回答1: I think your call is not done on EDT. Wrap it

JTabbedPane track previous tab selection

让人想犯罪 __ 提交于 2019-12-24 01:54:28
问题 I have a class that extends BasicTabbedPaneUI and does some paint component overriding. I want to be able to add a addMouseListener to the class I use it in to check when the user selects a tab the current tab index and the previous tab index. NOTE: The user is able to navigate to tabs via the keyboard and not just clicking on a tab and I want to be able to make sure the previous index tracks this. So in the example below preIndex would equal the previous index regardless to whether the user