jtabbedpane

Setting tab title colors on JTabbedPanes

有些话、适合烂在心里 提交于 2019-12-08 03:59:53
问题 On a JTabbedPane, how do you set the color of the tab titles for both the selected and unselected states? 回答1: It seems like what you want are the setForegroundAt and setBackgroundAt methods in JTabbedPane . 回答2: I want to change the colors for all of them and let Swing handle knowing which tab is currently selected. That wouuld be a LAF implementation. You can check out UIManager Defaults. For the Metal LAF it looks like background selected/unselected can be controlled but I don't see

Jtabbedpane using multiple classes

三世轮回 提交于 2019-12-08 02:53:26
问题 I'm fairly new to java and am creating a windowbuilder program. I am wondering if it is possible when using Jtabbedpane and switching between the tabs in the program window if i can use an actionlistener to get the contents from a separate class. For example, i have a program with two tabs and two classes, the first tab will have the code from one class and the second tab from the second class. Thanks 回答1: If you want to separate your code which creates GUI, to multiple classes, you could use

Change tab name

ⅰ亾dé卋堺 提交于 2019-12-07 18:51:29
问题 I would like to change tab name by clicking on "Rename" item from a popup menu by adding an ActionPerformed, and type directly on tab the new name. I have found this jTabbedPane.setTitleAt(count, "string here"); but it is not what I want, this just set the string passed as argument. Thanks 回答1: By adding JPopupMenu is possible to determine index and getTitleAt() from JTabbedPane import java.awt.*; import javax.swing.*; import javax.swing.event.*; public class TabPopupDemo extends JFrame {

Setting tab title colors on JTabbedPanes

▼魔方 西西 提交于 2019-12-07 08:43:24
On a JTabbedPane, how do you set the color of the tab titles for both the selected and unselected states? It seems like what you want are the setForegroundAt and setBackgroundAt methods in JTabbedPane . I want to change the colors for all of them and let Swing handle knowing which tab is currently selected. That wouuld be a LAF implementation. You can check out UIManager Defaults . For the Metal LAF it looks like background selected/unselected can be controlled but I don't see anything for the foreground font color. So I would say you would need to add a ChangeListener to the tabbed pane. Then

Change tab name

☆樱花仙子☆ 提交于 2019-12-06 12:54:13
I would like to change tab name by clicking on "Rename" item from a popup menu by adding an ActionPerformed, and type directly on tab the new name. I have found this jTabbedPane.setTitleAt(count, "string here"); but it is not what I want, this just set the string passed as argument. Thanks By adding JPopupMenu is possible to determine index and getTitleAt() from JTabbedPane import java.awt.*; import javax.swing.*; import javax.swing.event.*; public class TabPopupDemo extends JFrame { private static final long serialVersionUID = 1L; private JLabel jLabel1; private JLabel jLabel2; private

Jtabbedpane using multiple classes

血红的双手。 提交于 2019-12-06 11:18:56
I'm fairly new to java and am creating a windowbuilder program. I am wondering if it is possible when using Jtabbedpane and switching between the tabs in the program window if i can use an actionlistener to get the contents from a separate class. For example, i have a program with two tabs and two classes, the first tab will have the code from one class and the second tab from the second class. Thanks If you want to separate your code which creates GUI, to multiple classes, you could use this aproach: This would be your main class which will contain JTabbedPane : import javax.swing.JFrame;

How to handle the height of the tab title in JTabbedPane

时光毁灭记忆、已成空白 提交于 2019-12-06 07:33:39
问题 I am preparing a window with some horizontal tabs using JTabbedPane, Tabs And window are prepared properly. Now I need to setup these tabs in level basis, based on my requirement (My logic returns integer value based on that I need to setup levels ). Levels look like : Can you please advise? 回答1: Just the sight of screenshot: import java.awt.*; import java.awt.event.*; import javax.swing.*; public class TabHeightTest { public JComponent makeUI() { JTabbedPane tabbedPane = new JTabbedPane(

Nimbus L&F missing divider at JTabbedPane set to scroll

旧街凉风 提交于 2019-12-06 05:11:01
问题 I am missing the blue horizontal divider between the tabs and the content in a Nimbus L&F TabbedPane set to SCROLL (other L&Fs (default & windows) provide those). As you can see the problem is limited to new JTabbedPane(JTabbedPane.TOP, JTabbedPane.SCROLL_TAB_LAYOUT) (top of the picture) while the default with WRAP does not show this behaviour (bottom of the picture). It should be possible to change something like this by overriding parts of the NimbusDefaults.class . Here is an excerpt: /

Vertical orientation of JTabbedPane titles when the the tab placement is set to LEFT

落花浮王杯 提交于 2019-12-06 04:09:01
问题 As you can see from the image below, the Java text is horizontal. What I would like to do is get a vertical orientation of the JTabbedPane Titles. While googling, I found that the only way is to add extra library. But I was wondering if this can be done without any extra library? I would like for Title1 and Title2 to be vertically oriented and not horizontally 回答1: you have to use Html syntax, for any changes to the disabled Tab too tabbedPane.addTab("<html>T<br>i<br>t<br>t<br>l<br>e<br>1<

Forbid tab change in a JTabbedPane

可紊 提交于 2019-12-06 00:48:53
问题 I'm trying to prevent the user from changing a tab when the current tab is not valid. So when he clicks on a tab, I want to check if the current one is "valid", and if not, stay on the current tab. I tried to use a VetoableChangeListener which didn't work, the code never goes inside the vetoableChange method: jTabbedPane.addVetoableChangeListener(new VetoableChangeListener() { @Override public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException { if (!isCurrentTabValid()