Problem with JTree custom renderer when editing
I have a JTree which uses a custom renderer to display my own icons for different types of nodes. The problem I am having is when I setEditable to true and then attept to edit a node the icon switches back to the default icon, as soon as I am done editing it goes back.
What I am doing wrong?
Here is my rendererer
public class DeviceTreeRenderer extends DefaultTreeCellRenderer implements GuiConstants {
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
JLabel returnValue = (JLabel)super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
if (value != null) {
returnValue.setToolTipText(value.toString());
if (value instanceof Device) {
returnValue.setIcon(TREE_DEVICE);
if (!((Device)value).isAlive()) {
returnValue.setEnabled(false);
else if (value instanceof GuiPanelGroup) {
if (expanded) {
returnValue.setIcon(TREE_PANEL_GROUP_OPEN);
else {
returnValue.setIcon(TREE_PANEL_GROUP_CLOSED);
else if (value instanceof GuiPanel && ((GuiPanel)value).isDirty()) {
returnValue.setIcon(TREE_PANEL_DIRTY);
return returnValue;
}Here is my editor:
public class WwpJTreeCellEditor extends DefaultTreeCellEditor implements GuiConstants {
private WwpJTree tree;
* Creates a new WwpJTreeCellEditor.
* @param tree The WwpJTree to associate with this editor.
public WwpJTreeCellEditor(WwpJTree tree) {
super(tree, (DefaultTreeCellRenderer)tree.getCellRenderer());
this.tree = tree;
* Overrides the default isCellEditable so that we check the isEditable() method
* of the WwpJTreeNodes.
* @param e An EventObject.
public boolean isCellEditable(EventObject e) {
boolean returnValue = super.isCellEditable(e);
if (returnValue) {
WwpJTreeNode node = this.tree.getSelectedNode();
if (node == null || !node.isEditable() || node.isDragging()) {
returnValue = false;
return returnValue;
}In my JTree I make these calls:
super.setCellRenderer(new DeviceTreeRenderer());
super.setCellEditor(new WwpJTreeCellEditor(this));
super.setEditable(true);
Similar Messages
-
Hello I have encounted a problem with Photoshop. Normally when you start a new documant, you are given the options to have A4, A3, ect page set ups. These inbuilt page set ups seem to have disapeared, does anyone please know how to fix this? Many thanks Ben [email protected]
Hello Trevor
Thanks for your message. You can custom set pages but there are no preset of page sizes like A4, A3, ect. I cannot click the size preference, nothing comes up
Ben -
i have a problem with xcode programming app when i lunch to it it asking me to enter my password and when i enter it the program show that it is wrong but am 100% sure it's wright so please help me with this issue thanks
That's not very intuitive
Check your mail server setup (mail>preferences>accounts>) choose your MobileMe account and select Outgoing Mail Server (SMTP) dropdown box, select Edit SMTP server list, verify that each instance of the me server has a password, if there are more than one and you only have one account then delete the one without a password. -
When I turn my computer on (Windows 7) I receive a message that Apple wants to make a change to the hardware. I click on yes but nothing happens. The change has something to do with Apple "push". I recently had a problem with"push" on iTunes when I tried to sync my iPod Touch. I have latest software for iTunes and iPod. Can anyone tell me what to do to get this change to install?
ptford wrote:
When I turn my computer on (Windows 7) I receive a message that Apple wants to make a change to the hardware
Since hardware cannot be changed with software, perhaps you would be so kind as to post the exact wording of the message? -
i have some problem with my computer because when i turn it up, the screen turns in a blue colour and the sound doesn't work and in this way i can't hear anything
Will u help me or not?
-
I have Windows 7 and just recently experienced a problem with itunes freezing up when I clicked on the "apps" tab which shows the apps that are loaded on my phone. Everything else in the itunes software seems to be working okay. The problem is in the part where you sync the newly purchased apps. The apps will all be blank that are downloaded and that part of the software crashes itunes or freezes up. I can get out of itunes okay after the freeze up, but it just stops me from syncing anything that I have newly added. If anyone has had this problem before or knows someone that has, please let me know how I can fix it. I have uninstalled and reloaded itunes 4 or 5 times, but the problem is still there. I might add that I have been using itunes and purchasing apps for 2 to 3 years without any problems. HELP.
You would get better response from the iTunes community forum.
Have a nice day! -
I have a problem with two PDF's when trying to open them through a link on a web page. The two PDF's open fine with Adobe on my own PC and on the server I have copied it to but when they are opened through a link on a web page (pointing to the server where the PDFs open fine) I get an error 'There was an error processing a page. Invalid function resource' The other one just doesn't open at all. Can anyone help with this please?
Hello,
Are the pdf linked correctly in the website? Is this a public website? If yes, please post the link here.
~Deepak -
Ive used compressor and then tried to put it in dvdsp put its not working. I am having problems with the audio or when i burn it , i cant play the dvd? any help would be appreciated
I suspect you are attempting to burn an HD DVD, which will not play on a DVD player...
But if you provide more details such as the settings you are applying in Compressor, then we would be able to provide you more accurate information.
How are you adding the files to Compressor?
In FCP, what are your footage properties (command-9) and sequence settings (command-0) -
Anyone having problems with Elements organiser 13 when try to import photos from Mac photos which was an upgrade from Iphotos on 9th April 2015. Before when I was using Iphotos all was ok...
hi I have been trying to do this, but PE13 comes up with a fail message saying that file types are not supported, am only trying to import jpeg files so can't understand this. So far have been unable to use PE13 at all, any ideas anyone please!
-
Im have a problem with my adobe id when i try to covert pdf files.
Im have a problem with my adobe id when i try to covert pdf files.
I think your question should go in the ExportPDF forum,
http://forums.adobe.com/community/exportpdf -
Problems with JTable custom cell renderers
Hi All,
I'm having a bit of a problem writing a custom renderer for a JTable.
What seems to be happening is that the changes I apply in the renderer to the component are applied to ALL cells.
All I want to do is have a different background color for certain cells....
Ive derived from DefaultTableCellRenderer, so Im using its getTableCellRendererComponent to do most of the work.
So, Ive got something like this:
private class DirtyCacheRenderer extends DefaultTableCellRenderer
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column)
// Modifies 'this'
super.getTableCellRendererComponent(table,value,isSelected,hasFocus,row,column);
// If the row/column is 'dirty' (I.e - if I want 2 color it diferently)
if(((EditableTableModel)table.getModel()).isDirty(row,column))
// The column is dirty. Set the color accordingly:
super.setBackground(DIRTY_COLOR);
return this;
}The effect is that as soon as ONE cell gets its color set above, all of the cells do!
Please help, its driving me mad!!!
DI tried this and it worked. Tell me if it is OK for you.
import javax.swing.table.TableCellRenderer;
import java.awt.Color;
import java.awt.Component;
import javax.swing.JTable;
import javax.swing.JLabel;
public class testRenderer implements TableCellRenderer {
JLabel cell = new JLabel();
Color dirty = new Color(100,100,100);
Color clear = new Color(0,0,0);
public testRenderer() {
cell.setOpaque(true);
public Component getTableCellRendererComponent(JTable table,Object value,
boolean isSelected,boolean hasFocus, int row, int column) {
cell.setText(value.toString());
// The column is dirty. Set the color
if (row == column) {
cell.setBackground(dirty);
} else {
cell.setBackground(table.getBackground());
return cell;
} -
hi, i have problem with my apple id when i want purchase app even free one, asked me for complete my card informations... but i don't want to use debit card because already i have gift card and charge it in my id... please help me.
when i unchek the card information it was show me an error!Though you are being asked for card details it doesn't necessarily mean that the card will be charged for the purchase (unless you want to gift content). Have you tried entering your card's details to confirm the account ? You should then be able to remove it.
From http://support.apple.com/kb/HT5582 :
When making purchases, content credits are used first, followed by Gift Certificate, iTunes Card, or Allowance Account credits; your credit card or PayPal account is then charged for any remaining balance
Is it a new account ? If it is then unless a new account is created by following the instructions on this page (the instructions won't work with existing accounts) : http://support.apple.com/kb/HT2534
then you will need to enter card details (debit cards are no longer accepted in all countries) before the account can be used to download any item from the store. -
I have a problem with elements 8. When ever I start a new project, the program searches for the old, latest used filmmaterial, I have used before. That means, if I use a different DVD, it take so much time, until the program starts. So how can I stopp the automatically uploading of old material?
ThanksYou have 2 unreachable statements in this method.
public static int eval(String s2, String op, String s3) {
return lookup(s2);
return lookup(op);
return lookup(s3);
} You're missing a } at the end of this method:
public static int lookup(String s) {
for(int k = 0; k < symbols.length; k++){
String symbol = symbols[k];
if(s.equals(symbol))
return k;
}You have some loose } and ; at the end of the file:
public static void main(String args[])
commandline();
} -
IS ANY ONE HAVING PROBLEM WITH LIGHTROOM CC BRUSH WHEN THE GPU IS TURN ON
F. McLion wrote:
Update your graphic card driver to the latest version.
btw.: Rule number 2 - Do not use all caps - Netiquette Wiki
And for a very practical reason from your point of view: using all caps looks like SHOUTING, and people will concentrate more on the SHOUTING than on answering your question. Some will just ignore you for this reason.
If updated drivers don't fix the problem, perhaps you can tell us what is the "PROBLEM WITH LIGHTROOM CC BRUSH WHEN THE GPU IS TURN ON" that you are having. -
My daughter's older Ipod Touch is having a problem with images becoming pixilated when taken from an e-mail and placed into her camera roll. ( She wants to put on Instagram ) Any help?
I think that may be a consequence of the email provider she is using. Some services (AOL is one example) inspect and modify email attachments, particularly photos, resulting in reduced resolution compared to the email that was sent.
The iPod does not do this. The resolution of the picture in the email she receives will be identical to what is imported.
Maybe you are looking for
-
How do I use credit on my iTunes account towards purchases in an app I have?
How do I use credit I have in my ITunes account toward purchases in an App I have?
-
Hi I'm facing the following problem while viewing the JNDI tree. I had configured two servers ejbServer,ejbServer1 both clustered, i can able to start both the servers, but in the JNDI tree when i click ejbServ
-
Imac Intel - Sleeping display (only imac screen )
I Get a Imac 2008 Alu , And I use it like a media center with a videoprojector ( videoprojector is the second screen) All works well , but As the Imac Screen is very very Bright , I want to Sleep the display of the Imac , but get the Second display O
-
How to Change Date Format according to the Locale/Country of Portal User
Hi, In a webdynpro applicaiton, how to chage the Date Format according to the Locale/Country of Portal User. Consider for INDIA: mm/dd/yyyy Consider for UK: yyyy/mm/dd So when i select the date from the Date Picker[input ui element bound to date con
-
Hi guys, The requirement is to analyze the removal of a cube (an overview cube), can u guys tell me the precaution and steps to take like archival, performance if any and the functions this is doin has to be replaced by detail cube. thanks, your help