- Where Developers Learn, Share, & Build Careers
It's difficult to reproduce my issue, but I hope someone can give me a hint here How is it solved?
I received a Here is the code: It looks like: Clicking the first cell to follow the given link in the string Must be qualified and removed from the display text. The second cell had no link in the text and therefore it should not be clickable However, in this case, both cells are not clickable and if I store the string value and it < Code> isEnabled () method, I think that is the only condition that has seen me this behavior. I know that a provider example for each type of cell is reused, but for some reason the rollover renderer does not properly reconfigure this provider in this case. Am I doing something wrong here? After playing some games: You might hit on this issue - all our instances always click Actually, it is brittle to keep the cell related state in the provider, because it can be said often and for other cells The rollovers renderer's API is not really rich enough: the system Depends on the renderer which is configured before a click (So that "old" situation still does), is not sufficient for your use case: -) You may want to consider filing a bug report in swing x issue tracker, so we do not forget to look into it. Thank you. To play with the snippet, it basically shows which methods can be overridden in a custom provider (but not solving the problem - rollover always excluding a user-irrelevant call Enabled): ComponentProvider & lt; JLabel & gt; is written which creates a clickable cell decorated with an icon if there is a URL in the string if no URL is found in the string value, then there is no icon set for the label. And the cell should not be clickable
Public class ExternalLinkProvider ExponentProvider Expands & lt; JLabel & gt; Rollover renderer {private string url = null; Applies; @ Override Protected Zero Format (Selconent Reference) {} @ Override Protected Zero Configuration (Cell Content Reference) {If (context.getValue (Example String)} {String stringValue = (string) context.getValue (); WwwLink Link = NewWwwLink (stringValue); // Set a link icon if it has a valid URL. If (link.isValid ()) {rendererComponent.setIcon (ExternalLink.WWW_LINK_ICON); Url = link.getUrl (); } Else {rendererComponent.setIcon (null); Url = null; } RendererComponent.setText (link.getString ()); }} @ Override Protected JLab BuildRenderer Companent () {Return New Generator Label (); } @ Override Public Boolean enabled () {Return URL! = Null; } @ Override Public Wide Doecic () {if (url! = Null) {// Follow URL}}}
Expands the Public Class ExternalLinkProvider Applying LabelProvider RolloverRenderer {Private URL url = null; / ** * Override * / @ Override Protected to Check for Valid URLs * Zero Config Contents (Selcontext Reference) {url = ConvertVolueUule (Reference.Gate Value); Super.configureContent (reference); } Private URL ConvertVaultUul (Object Result) {If (! (Result of string!) Blank return; Url = null; Try {url = new URL (result.To string ()); } Catch (exception e) {// TODO: handle exception} return url; } Get @ Override Protected Icon ValueAsIcon (SelconTest Reference) {return url! = Null? XTestUtils.loadDefaultIcon (): Zero; } / ** * Conditional enable is not strongly supported. Really returning * Probably is not an option because the cursor has changed ... * / @ Override public boolean is enabled () {back true; // url! = Null; } @ Override Public Wide Doecic () {follow (url! = Null) {// url System.out.println ("Clicking"); }}}
Comments
Post a Comment