JTabbed Pane close icon help
Hi
I am trying to create a close icon on my JTabbedPane tabs, so i wrote an closeiconTab class extedning Icon and implements MouseListener, whenever a click is observered, i kill the a tab.
But this method gives me an arrayoutofbound exception error, after debuggin, i realize my implemention goes against the single thread rule for swings. Anyone know a way around this ???
I've tried this
public void mouseClicked( MouseEvent e )
if( _bounds.contains( e.getX(), e.getY() ) )
SwingUtilities.invokeLater(new Runnable() {
public void run() {
_parentTabbedPane.remove( _tabbedComponent );
}but it still doesnt work
does the mouse click call the listener? If so, just call the remove method without the SwingUtilities method part.
Similar Messages
-
Help with disabling close icon of last opened tab in JTabbedPane
Hello
Would someone help me out ? I have 3 tabs opened in a JTabbedPane, each with close icon "X". I am looking for a way to tell my program: if the user closes 2 tabs and only 1 remain, disable the close icon "X" of the last opened tab so that the user is unable to close the last tab. I have searched the forum, most I have run into are how to create the close icon. Would someone give me some insight into how to go about doing this? or if you have come across a forum that discusses this, do please post the link. Also, I am using java 1.6.
Thanks very much in advanceOn each close, look how many tabs are remaining open in the JTabbedPane (getTabCount).
If there is only one left, set its close button to invisible. Something like this:
if (pane.getTabCount() == 1) {
TabCloseButton tcb = (TabCloseButton) pane.getTabComponentAt(0);
tcb.getBtClose().setVisible(false);
} -
Please help. My facebook app will not open on my iphone 4. I deleted it,numerous times and downloaded it again. It uploads, but when you click on the icon, it flickers then closes.
Help.Then the next step would be to restore your phone. My advice is that prior to restoring you import your photos and videos to your computer and back up your contacts (by syncing them with iCloud or to a supported program on your computer using iTunes) as a number of users report losing these when restoring their device.
-
hello...
How can I put an Icon into the JTABBED PANE?
So every TAB will have its own Icon?
I believe JBuilder 4.0 do that.
Thank you.Read http://java.sun.com/docs/books/tutorial/uiswing/components/tabbedpane.html
tabbedPane.addTab("Title", image, panel, "Tooltip"); -
I trying to add print Icon in Thread Pane or Message Pane can you help?
I trying to add print Icon in Thread Pane or Message Pane can you help?
You have shown us Firefox.
How does that relate to doing it in Thunderbird? -
How to handle the "cancel" button and "close" icon of a popup ?
Hi,
I have a popup with "cancel button" and "close icon"(on the top right corner of the popup), I want the same operations to be performed on clicking of any of these two components.
Is there a way to handle such situation ?
I read about 2 cases to look into this but they didn't work too well for me.
1. I read about the "popcancellistener" but that listener is called whenever the popup closes, so suppose I have an "ok button" on the popup to create a record, after the record is created, the popup closes and goes into the "popcancellistener", now the question is "how do we know if it came there because of the 'ok button' or 'some other event'".
2. I even checked the "DialogListener", now I'm able to distinguish between the 'OK' and 'CANCEL' button in the dialoglistener using the "Dialog.Outcome.ok/cancel", but when a user clicks on the close icon, we do not enter the "DialogListener" at all, so in this case "how do we handle the close icon click event"
Do let me know if you need any more information from my side.
Thanks for the help in advance.The following mechanism responds to any of the following events: <Esc> key, Close icon ('x'), Cancel button
JavaScript part:
function popupClosedListener(event){
var source = event.getSource();
var popupId = source.getClientId();
var params = {};
params['popupId'] = popupId;
var type = "serverPopupClosed";
var immediate = true;
AdfCustomEvent.queue(source, type, params, immediate);
}JSF part:
<af:popup ....>
<af:clientListener method="popupClosedListener"
type="popupClosed"/>
<af:serverListener type="serverPopupClosed"
method="#{myBean.serverPopupClosedMetod}"/>
</af:popup>Finally, Java part:
public void serverPopupClosedMetod(ClientEvent event){
} -
Itunes 10.5.3 lost my Apple TV icon: Help!
itunes 10.5.3 lost my Apple TV icon: Help!
This happened to us and through much trial and error, this is what we did to fix it:
Go to iTunes ----> Preferences -------> Apple TV and see if your Apple TV is listed as streaming from there. Remove the Apple TV. Close iTunes. Open iTunes. Your Apple TV should now show under devices and ask you to set it up. Enter the code and set it up with your iTunes. That worked for us. Good luck! -
X JPanels in a JTabbed pane.
I'm wondering if anyone can help.
I have an application consisting of a JTabbed pane, within this there should be 'x' JPanels. Each JPanel has 3 RadioButtons and 5 Text fields. I need to be able to refer to each radio button and text field as RB0 - RBx and TF0 - TFx.
It is obviously easy enough to do this for just 3 or even 20 (despite a lot of coding), however, my problem is getting a variable number (x) of Panels with respective variable numbers of TF and radio buttons.
Simply I need to produce an array of panels, radiobuttons and textfields....
anyone anyideas?another way of looking at it is to think how can I make 5 of exactly the same panel (just with different names) in the same tabbed frame in just one bit of code that is called 5 times - or x in this case.
-
hello,
i have a problem with event KEY-EXIT
this event doesn't include the CLOSE icon (right top of all windows)
and users can exit without execute the code in KEY-EXIT event
in fact KEY-EXIT is trigger only by the icon exit in the tool bar
How can I trigger my code on system CLOSE icon????
Thanks for your help
@Rosagio
I work under designer 9i who generate forms 9iKEY-EXIT triggers fires only when the "Key" associated with the trigger is pressed or DO_KEY('EXIT_FORM') is executed.
You can use the WHEN-WINDOW-CLOSED trigger on your window and after you finish the standard processing you have (or not) issue a DO_KEY('EXIT_FORM'); this will simulate the EXIT key bein pressed.
Tony -
JCombobox on a jtabbed pane, AND Choice on jtabbed pane problems
I have a Choice on a jtabbed pane, on a panel that isn't showing when the jtabbed pane is made visible. The Choice on the hidden pane is "bleeding" through to the first tabbed panel. help!
If I click on the second tabbed panel (where the Choice is), and then click on the first tabbed panel, the Choice becomes hidden like it is supposed to.
AND, I have a JComboBox on a JTabbedPane, it works for the most part, but when you click on it, the scrollbox underneath it doesn't appear! Instead, a grey box appears below it. Help!I was having similar problems when I was working with JFrames, Anything not covered by a piece of GUI would show other parts of my program (like the progress bar or buttons and stuff).
Anyway, it went away when I used the setBackground() method. My guess is that using this forces the container to be opaque or something. Anyway, it worked for me, maybe it will work for you also.
Steve -
Jtabbed pane is listening to the keyboard, how do i stop?
hello
this is probobly a simple Swing problem. i have a j3d canvas inside a tabbed pane with other info on other panes. i need the keyboard to listen on the canvas so i can move around the j3d world, but the left and right are being detected by the jtabbed pane, but i didnt add any listen to those. how can i stop this behavior from occuring? its very annoying.
i appreciate any help you can lend..The reason it is responding to keyboard events is becuase it has the focus. Request focus on the component in the tab, and the tabbed pane should stop responding. If that doesn't work, try this:
JTabbedPane tabbed = new JTabbedPane();
KeyStroke[] keys = tabbed.getRegisteredKeyStrokes();
for (int i=0; i<keys.length; i++) {
int code = keys.getKeyCode();
if (code == KeyEvent.VK_LEFT || code == KeyEvent.VK_RIGHT) {
tabbed.unregisterKeyboardAction(keys[i]); -
Jtabbed pane problem + flags printout
Hi,
I am having difficulty displaying a JTabbedPane which is contained by a dialog. When I display the Dialog for the first time the Tabbed displays perfectly - anytime after that it disappears.
I found this really strange so I put in some printout statements for the JTabbed pane here's what I got
When it displays the prinout for the JTabbed pane is ............................
extCellTabbedPane
rnh.adj.cellhandovermgt.gui.refactor.ExtCellTabbedPane[,0,0,0x0,invalid,layout=javax.swi
ng.plaf.basic.BasicTabbedPaneUI$TabbedPaneLayout,alignmentX=null,alignmentY=null
,border=,flags=0,maximumSize=,minimumSize=,preferredSize=,haveRegistered=false,t
abPlacement=TOP]
When it does n't display the prinout for the JTabbedPane is
rnh.adjcellhandovermgt.gui.refactor.ExtCellTabbedPane[,0,67,193x45,inv
alid,layout=javax.swing.plaf.basic.BasicTabbedPaneUI$TabbedPaneLayout,alignmentX
=null,alignmentY=null,border=,flags=16,maximumSize=,minimumSize=,preferredSize=,
haveRegistered=false,tabPlacement=TOP]
What I am interested in is the meaning of the parameter flags. In one case it is 0 and in one case it is 16? What does this parameter mean? Where I can get some information on this as I think this will tell me what is happening to the JTabbedPane.
Thank you in Advance
AlexThe flags item reflect the flags value in JComponent
class. It represents several status
of the component:
REQUEST_FOCUS_DISABLE
IS_DOUBLE_BUFFERED
ANCESTOR_USING_BUFFER
IS_PAINTING_TITLE
HAS_FOCUS
IS_OPAQUE
As my understand about your problem, this may be no
help for you to locate the error
As the message you post, you might use a third
implementation of JTabbedPane, so the
problem might be in the implementation. I
have used JTabbedPane often with no error
like you say :)
Hope this Helps!Thanks for your help here - I would like more information if possible i.e. a numerical mapping for each property - do you know where I could get this. I don't really understand what you mean about the Third implementation. Do you mean simply extend the JTabbedPane? Thisis what I do but I don't really know what part to change to stop it disappearing. Thanks once again. Anymore help would be greatly appreciated. -
JTabbed pane customize title on selection
Hi all
i want to change the title font when a tab is selected.I add a ChangeListener to my JTabbed pane to intercept tab selection and to change font via html.
I have some proble ex:
if i click on tab4, it correctly change font but the tab2 take the title of the tab1 and so on.
This is the code
ChangeListener changeListener = new ChangeListener()
public void stateChanged(ChangeEvent changeEvent)
JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.
getSource();
int index = sourceTabbedPane.getSelectedIndex();
for (int i = 0; i < sourceTabbedPane.getTabCount(); i++)
if (i == index)
sourceTabbedPane.setTitleAt(i,
"<html><b>" + sourceTabbedPane.getTitleAt(i) + "</html>");
else
String desc = sourceTabbedPane.
getTitleAt(i).replaceAll("<html>", "").
replaceAll("<b>", "").replaceAll("</html>", "");
sourceTabbedPane.setTitleAt(i, desc);
System.out.println("***********************");
for (int i = 0; i < sourceTabbedPane.getTabCount(); i++)
System.out.println(sourceTabbedPane.getTitleAt(i));
};The last system.out show me the correct tirtle, only the selected with html but on screen i see some mixed title.Where i'm wrong?I hope can you help me:
public static void main(String[] arg)
JTabbedPane jTabbedPane = new JTabbedPane();
jTabbedPane.addTab("Tab1", new JPanel());
jTabbedPane.addTab("Tab2", new JPanel());
jTabbedPane.addTab("Tab3", new JPanel());
jTabbedPane.addTab("Tab4", new JPanel());
jTabbedPane.addTab("Tab5", new JPanel());
jTabbedPane.addTab("Tab6", new JPanel());
jTabbedPane.addTab("Tab7", new JPanel());
jTabbedPane.addTab("Tab8", new JPanel());
ChangeListener changeListener = new ChangeListener()
public void stateChanged(ChangeEvent changeEvent)
JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.
getSource();
int index = sourceTabbedPane.getSelectedIndex();
for (int i = 0; i < sourceTabbedPane.getTabCount(); i++)
if (i == index)
sourceTabbedPane.setTitleAt(i,
"<html><b>" + sourceTabbedPane.getTitleAt(i) + "</html>");
else
String desc = sourceTabbedPane.getTitleAt(i).replaceAll(
"<html>", "").
replaceAll("<b>", "").replaceAll("</html>", "");
sourceTabbedPane.setTitleAt(i, desc);
System.out.println("***********************");
for (int i = 0; i < sourceTabbedPane.getTabCount(); i++)
System.out.println(sourceTabbedPane.getTitleAt(i));
jTabbedPane.addChangeListener(changeListener);
JDialog dialog = new JDialog(new JFrame(),true);
dialog.getContentPane().add(jTabbedPane);
dialog.setPreferredSize(new Dimension(300,300));
dialog.setSize(new Dimension(300,300));
dialog.setVisible(true);
} -
Close icon display for a Tab(ShowdetailItem)
Hi,
I am using the PanelTab with multiple ShowDetailItems. I am giving the close icon provision for the showdetail item. But the close icon is coming only in mouse over.
I need to display the close always(ShowDetailItem).
Reg,
Brahma BThere is a tutorial for JScrollPane:
http://java.sun.com/docs/books/tutorial/uiswing/components/scrollpane.html
It came to my mind that JSplitPane is not using JScrollPane for the two components you add. So perhaps the solution would be to "wrap" both your components to their own JScrollPane before you add them to the split pane.
Then for those scroll panes I would probably use:
JScrollPane.setColumnHeaderView(myXCloseButtonInAPanel)
or
JScrollPane.setCorner(upperRightCorner, myXCloseButton)
I don't know if that will work, or how it will look like now that you use the scroll pane's scrollbars instead of the split pane's scroll bar. You have to experiment with it. The scroll pane's should be able to resize themself to fit in the split panes areas when you move the divider, and maybe that's not so easy to do. Otherwise you will end up with both a scrollbar from the split pane and a scroll bar from the scroll pane.. yuck.
Maybe someone else has a better solution? -
Setting Close icon (X) for a container
Hi,
I just want to know whether it is possible to set close icon (X) for a panel or any other component. Here close icon mean the one which we see on the top right cornet of a IE window.
Thanks in advance.
SapnaThere is a tutorial for JScrollPane:
http://java.sun.com/docs/books/tutorial/uiswing/components/scrollpane.html
It came to my mind that JSplitPane is not using JScrollPane for the two components you add. So perhaps the solution would be to "wrap" both your components to their own JScrollPane before you add them to the split pane.
Then for those scroll panes I would probably use:
JScrollPane.setColumnHeaderView(myXCloseButtonInAPanel)
or
JScrollPane.setCorner(upperRightCorner, myXCloseButton)
I don't know if that will work, or how it will look like now that you use the scroll pane's scrollbars instead of the split pane's scroll bar. You have to experiment with it. The scroll pane's should be able to resize themself to fit in the split panes areas when you move the divider, and maybe that's not so easy to do. Otherwise you will end up with both a scrollbar from the split pane and a scroll bar from the scroll pane.. yuck.
Maybe someone else has a better solution?
Maybe you are looking for
-
External Hard Drive - Lacie D2 Quadra, Iomega Mac Companion or MiniMax??
I'm looking for suggestions on a 2TB FW800 external hard drive for my iMac (Mid 2010). I understand the quality/reputation of the Lacie products, but I am intrigued by the Iomega Mac Companion and Iomega Minimax. The companion and minimax look almo
-
Hi, I need some help. Different Java plug-in versions make a real mess. I have an applet and if I want that applet to work under 1.3, I put version 1,3,0,0. Let's complicate the task. What about 1.3.1-03, 1.3.1_04? How about these 1.3.1_02-b02, 1.3.1
-
How to Use Step with Filters in Eclipse
Hello, everyone! I have a question. How do I keep myself from accessing methods outside my own class? See, when I use the debug feature of Eclipse, (I am using Eclipse 3.0), and start debugging, I often "Step Into" methods of classes like String.clas
-
Is there a way to spellcheck another language than English in Pages? I upgraded to Lion and my old MS Office is no longer compatible. Thanks lion...
-
How to set a cell editable at runtime for jtable
Hi evry body i need to set a cell as editable during runtime and set some value for the cell and make it non editable after setting value how can i do it? urgent help appreciated regards anil