jtabbedpane

How to dispose a tabbed pane component completely from a JTabbedPane

纵然是瞬间 提交于 2021-01-27 19:08:01
问题 I have added a few tabs to a JTabbedPane. Each tab contains a JPanel. I now remove the tab by calling JTabbedPane.remove([tab index]). This removes the tab and everything is fine, except that when I profile the app, the JPanel added to the JTabbedPane does not get 'disposed' off and the reference is still present in the heap. After few 100 operations of adding the tab and closing it, the app goes Out of Memory. I analysed the heap dump using Eclipse MAT and I clicked on the Immediate

Change the background color behind the tabs of a JTabbedPane?

戏子无情 提交于 2020-05-16 02:01:52
问题 The problem is referred to in the question. I intend to change the color of the area marked with an 'X' in the image below but I don't know how to do it. I've tried to change the JTabbedPane background but it didn't work. I apologize in advance for any English mistakes I may have made. Minimal reproducible example public class MainClass { public static void main(String[] args) { JFrame frame = new JFrame("TabbedPane Error"); // creates 2. JFrame JTabbedPane tabbedPane = new JTabbedPane();

NetBeans: How to enable/disable specific tab in JTabedPane

时光总嘲笑我的痴心妄想 提交于 2020-03-13 04:09:51
问题 I am developing a small desktop application in Netbeans. on my UI i have a JTabbedPane having 3 tabs in it now i come across a situation where i need to temporarily disable 2nd and 3rd tab. How could i do that programatically. Rightnow i am using the following code but its not working: int n = jTabbedPane1.indexOfTab("Second Tab Name");// This line returns one as expected jTabbedPane1.getTabComponentAt(n).enable(false);// but i guess some un-expected thing happens here 回答1: I believe what you

JTabbedPane: show task progress in a tab

旧时模样 提交于 2020-01-26 17:20:19
问题 I have a simple Swing Java application that performs searches, and the results are shown in a new tab. While the search is running, I want to show a progress icon or animation in the title of the tab. I tried adding a gif icon, but it doesn't animate. Is there a reason why this isn't working? 回答1: The Swing tutorial about progress bars (and showing progress in general) is a very good place to start. It shows you how to perform long-lasting operations on a worker thread by using a SwingWorker

jFileChooser to save file of selected tab

馋奶兔 提交于 2020-01-25 19:19:53
问题 Ok so I have a text editor made that can so far create new files and open files using jFileChooser. What I am trying to do is get the saving of files to work. Everytime you add or open a few file it adds a new tab to the tabbedpane and the name will be either file 1 etc or the name of the file opened. When you click the save button the save dialog opens up int returnVal = fileChooser.showSaveDialog(this); I want the name on the tab to be inserted to the name of file field. Also how do I make

DragTabFrame closing inconsistently

扶醉桌前 提交于 2020-01-21 07:20:48
问题 The code below is supposed to work a little like the Multi-Document Interface (MDI) you might see in a browser like FF, IE or Chrome. It presents 'documents' (a black buffered image as spacer) in a tabbed pane such that they can be dragged from the pane into a new (or existing) window by user choice. But it has had issues with closing frames once they have no more tabs, as well as closing the JVM when there are no further visible windows. I think I fixed them by checking with a Timer in the

When i open file first time file is opened but if choose the second time same file not opened how to do it in java swing?

只谈情不闲聊 提交于 2020-01-17 04:35:10
问题 Firstly open file through open menuitem but when second time open i choose the same file it opened in new tab. my requirement it not opened in new tab and display the message file already exist. Here is my code, public class Open extends javax.swing.JFrame { JTextArea tx; int i=0; public Open() { initComponents(); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { tp = new javax.swing.JTabbedPane(); jMenuBar1 = new

Use mouse to scroll through tabs in JTabbedPane

不羁的心 提交于 2020-01-14 03:10:09
问题 I have a JTabbedPane in a scroll tab layout, so that all the tabs sit nicely on one row. Is there a way to allow the user to scroll through them with the mouse wheel, or is the only way to navigate the JTabbedPane.SCROLL_TAB_LAYOUT with the keyboard's and GUI's arrows and by clicking the tabs? 回答1: I did find an answer to this, after digging around Eclipse's autocomplete: use a MouseWheelListener for the JTabbedPane : JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.setTabLayoutPolicy

Java - Right Clicking JTabbledPane Tab

拟墨画扇 提交于 2020-01-10 05:38:06
问题 I have it working, however the popup menu appears when you right click anywhere inside the tab. I only would like it to appear when you right click the top of the tab (the name). I cannot figure out how to do this. Any help is appreciated. Thanks. 回答1: Try adding your popup to the custom component demonstrated in TabComponentsDemo. 来源: https://stackoverflow.com/questions/9220889/java-right-clicking-jtabbledpane-tab

JScrollPane inside JPanel inside a JTabbedPane is not scrolling

别来无恙 提交于 2020-01-05 12:00:13
问题 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