Tree Cell Renderer settings for displaying complete text.

I have a tree model. It is of the form
abc (123.00)
-----def (456.00)
----------ghi (678.00)
But it is displayed like
abc (12...
-----def (45..
----------ghi (67..
I don't want the numbers in the end to be missing. It is a problem for the user to expand them everytime.
I am using, JTree and using my cell renderer, with following properties in
super.getTreeCellRendererComponent(tree, false, X, false, false, row, false);I did try to change it to
super.getTreeCellRendererComponent(tree, false, X, TRUE, false, row, false);but still no success.
My function toString() for tree elements looks like this
                 double u = "123.00";
                 String num = String.format("%.2f", u);
                 return getName() + " (" + num  + ")";Can you please suggest possible way around for this?

package abc;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.WindowConstants;
import javax.swing.JFrame;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeSelectionModel;
public class NewJPanel extends javax.swing.JPanel implements MouseListener {
     public static void main(String[] args) {
          JFrame frame = new JFrame();
          frame.getContentPane().add(new NewJPanel());
          frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
          frame.pack();
          frame.setVisible(true);
     JTree m_tree;
    private JScrollPane myPane;
    float multi = 1;
    DefaultTreeModel tree = new DefaultTreeModel(new ContainerNode("root"));
    DefaultMutableTreeNode parent = (DefaultMutableTreeNode)tree.getRoot();
     public NewJPanel() {
        super(new BorderLayout());
        String util = String.format("%.2f", 123456789012345679801234567980.00);
        util = "abc" + " (" + util  + ")";
            DefaultMutableTreeNode e = new DefaultMutableTreeNode(util);
            tree.insertNodeInto(e, parent, 0);
        m_tree = new JTree(tree);
        m_tree.setEditable(false);
        m_tree.setDragEnabled(false);
        m_tree.getSelectionModel().setSelectionMode(TreeSelectionModel.CONTIGUOUS_TREE_SELECTION);
        m_tree.setAutoscrolls(true);
        m_tree.setPreferredSize(new java.awt.Dimension(397, 297));
        myPane = new JScrollPane(m_tree);
        myPane.setAutoscrolls(true);
        myPane.getVerticalScrollBar().setAutoscrolls(true);
        add(myPane, BorderLayout.CENTER);
        m_tree.addMouseListener(this);
          initGUI();
     private void initGUI() {
          try {
               setPreferredSize(new Dimension(400, 300));
          } catch (Exception e) {
               e.printStackTrace();
     public void mouseClicked(MouseEvent e) {
          String util = String.format("%f", 6546464642345679801234567980.00 * multi);
        util = "abc" + " (" + util  + ")";
        DefaultMutableTreeNode child = (DefaultMutableTreeNode) parent.getChildAt(0);
        child.setUserObject(util);
        m_tree.repaint();
     public void mouseEntered(MouseEvent e) {}
     public void mouseExited(MouseEvent e) {}
     public void mousePressed(MouseEvent e) {}
     public void mouseReleased(MouseEvent e) {}
class ContainerNode extends DefaultMutableTreeNode
    private static final long serialVersionUID = 14;
    ContainerNode(String s)
    { super(s); }
}Executing this code... clicking in the panel, changes the number.
The new number is displayed as (65464646423456798000000000.000.......
My problem is nearly similar, except that in my code I am using, String.format("%.2f", 6546464642345679801234567980.00 * multi);
and still I get (65...)

Similar Messages

  • How to display multiple JComponents in a tree cell renderer

    I have an object in a tree cell renderer and want to display its members(three members) status in a JTree as checkboxes such that each node displays three checkboxex with member-names and a node name. i tried using a JPanel and adding three labels into this panel to be returned for the cell renderer but the GUI fails to paint the node componnents. However on clicking the node the component which isn't visible displays correctly. please Help me out

    Since you didn't provide any sample code, it's all about wild guesses on what your problem is. The following code shows the type of program you could have posted :import javax.swing.*;
    import javax.swing.tree.*;
    import java.awt.*;
    public class TestTree extends JPanel {
         private static class MyCell {
              String theCellName;
              boolean theFirstField;
              boolean theSecondField;
              boolean theThirdField;
              public MyCell(String aName, boolean firstField, boolean secondField, boolean thirdField) {
                   theCellName = aName;
                   theFirstField = firstField;
                   theSecondField = secondField;
                   theThirdField = thirdField;
         private static class MyTreeCellRenderer extends JPanel implements TreeCellRenderer {
              private JLabel theCellNameLabel;
              private JCheckBox theFirstCheckBox;
              private JCheckBox theSecondCheckBox;
              private JCheckBox theThirdCheckBox;
              private DefaultTreeCellRenderer theDelegate;
              public MyTreeCellRenderer() {
                   super(new GridLayout(4, 1));
                   theCellNameLabel = new JLabel();
                   add(theCellNameLabel);
                   theFirstCheckBox = new JCheckBox("firstField");
                   add(theFirstCheckBox);
                   theSecondCheckBox = new JCheckBox("secondField");
                   add(theSecondCheckBox);
                   theThirdCheckBox = new JCheckBox("thirdField");
                   add(theThirdCheckBox);
                   theDelegate = new DefaultTreeCellRenderer();
                   setOpaque(true);
              public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected,
                                                                       boolean expanded, boolean leaf, int row, boolean hasFocus) {
                   if (!(value instanceof DefaultMutableTreeNode)) {
                        return theDelegate.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
                   Object userObject = ((DefaultMutableTreeNode)value).getUserObject();
                   if (!(userObject instanceof MyCell)) {
                        return theDelegate.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
                   setBackground(tree.getBackground());
                   if (selected) {
                        setBorder(BorderFactory.createLineBorder(Color.BLUE, 2));
                   } else {
                        setBorder(BorderFactory.createLineBorder(getBackground(), 2));
                   MyCell cell = (MyCell)userObject;
                   theCellNameLabel.setText(cell.theCellName);
                   theFirstCheckBox.setSelected(cell.theFirstField);
                   theSecondCheckBox.setSelected(cell.theSecondField);
                   theThirdCheckBox.setSelected(cell.theThirdField);
                   return this;
              public Component add(Component comp) {
                   if (comp instanceof JComponent) {
                        ((JComponent)comp).setOpaque(false);
                   return super.add(comp);
         public TestTree() {
              super(new BorderLayout());
              JTree tree = new JTree(createModel());
              tree.setShowsRootHandles(true);
              tree.setCellRenderer(new MyTreeCellRenderer());
              add(new JScrollPane(tree), BorderLayout.CENTER);
         private static final TreeModel createModel() {
              DefaultMutableTreeNode root = new DefaultMutableTreeNode(new MyCell("root", true, true, true));
              DefaultMutableTreeNode child1 = new DefaultMutableTreeNode(new MyCell("child1", false, true, false));
              DefaultMutableTreeNode child2 = new DefaultMutableTreeNode(new MyCell("child2", false, false, true));
              root.add(child1);
              root.add(child2);
              return new DefaultTreeModel(root);
         public static void main(String[] args) {
              final JFrame frame = new JFrame("Test");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setContentPane(new TestTree());
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        frame.setSize(600, 400);
                        frame.show();
    }

  • Tree cell renderer shows (...) for long texts

    I know that the BasicTreeUI saves a cache but I don't know how to reset this cache, or if there is another solution
    Best regards
    Dekel

    My tree is inside jscrollpane.Ok, then I don't understand why your renderer truncates the displayed text.
    how can I set the jlabel prefered size to be in the
    exact width of the String ?AFAIK, this is the default behavior, i.e. you do not do anything.
    (I don't want to see a gap between the label and the end of the
    string when a node is selected)Uhm, I have no idea what "gap" you are talking about. I don't see any "gaps" when I select nodes in a JTree.

  • Flex SDK 3.4 Tree Item Renderer Root Folder displays Tooltip for Child

    I have a Flex Tree that uses a custom item renderer.  The item renderer extends Tree Item Renderer and I add my button in commit properties (since the data is dynamic) and I use update displaylist to move it to the right position.  I set the button to be visible on rollover and make the icon invisible. On rollout I reverse that logic.
    When I have my item renderer add the button, it causes only one problem and it seems to be under certain conditions:
    - Single root folder for the tree
    - Upon opening the tree, the root folder displays the tool tip for the last child in the tree
    Any idea why the tooltip comes up?
    public function AssetTreeItemRenderer ()
                super();
                addEventListener(MouseEvent.ROLL_OVER, onItemRollover);
                addEventListener(MouseEvent.ROLL_OUT, onItemRollout);
                addEventListener(ToolTipEvent.TOOL_TIP_SHOWN, toolTipShown);
                addEventListener(ToolTipEvent.TOOL_TIP_CREATE, onCreateToolTip);
            // OVERRIDEN FUNCTIONS
             * override createChildren
            override protected function commitProperties():void {
                super.commitProperties();
                if(data is IAsset) {
                    if(playBtn === null) {
                        playBtn = new Button();
                        playBtn.styleName = "previewPlayButton";
                        playBtn.toolTip = "Play";
                        playBtn.width = icon.width + 2;
                        playBtn.height = icon.height + 2;
                        playBtn.visible = false;
                        playBtn.addEventListener(MouseEvent.CLICK, onPlayBtnClick);
                        addChild(playBtn);
                } else {
                    if(playBtn !== null) {
                        removeChild(playBtn);
                        playBtn = null;
             * override updateDisplayList
             * @param Number unscaledWidth
             * @param Number unscaledHeight
            override protected function updateDisplayList(unscaledWidth:Number,
                                                          unscaledHeight:Number):void
                super.updateDisplayList(unscaledWidth, unscaledHeight);
                //Move our play button to the correct place
                if(super.data && playBtn !== null)
                    playBtn.x = icon.x;
                    playBtn.y = icon.y;

    You are not clearing tooltip if data is not IAsset

  • Tree Control Property Node for Accessing "Child Text" String Array

    When adding items to a tree control using the EditTreeItems invoke nodes, the inputs include "Child Tag", "Item Indent", "Child Only?", "Glyph Index", "Child Text", and "Left Cell String" as can be seen in this screenshot.
    There are property nodes for the tree control for accessing each of these elements, except for the "Child Text", which is an array of strings. It is possible to access this data as outlined in this forum post, but this method is somewhat involved and round about. 
    I suggest that a property for the Tree class be created to access the Child Text array directly.

     The work around only works if you do not have an empty string element some where in the middle.
    At lest could the "Active Celltring Property" read return an error when you have gone beyond the end of the array.

  • User settings for displaying numeric values

    Hi All,
             in transaction su01,the default settings are displayed as decimal notation: 1,234,567.89 what does this value mean??
    does it mean for all the values it will divide by 1000?????

    Hi Tilak,
    Plz find the below threads for your reference...
    Change in Decimal Points with comma
    Decimal Notation
    Regarding Decimal Notation
    Defualt Value of Requisitioner
    Again back to u all :)
    can not put decimal quantity in BOM quantity
    Also find the below search link...
    https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=defaultsettingsinSU01decimal+notation&adv=false&sortby=cm_rnd_rankvalue
    Assign points if this helps u...
    Regards,
    KK.

  • T-code for displaying PO text

    Is there any transaction by which we can display PO text (from material master) and material number collectively ?

    Hi,
    There is no tcode but you can try this. run tcode SE37 and execute funtion module READ_TEST. Input the following fields
    CLIENT                      "client number"
    ID                              BEST
    LANGUAGE               EN
    NAME                        "material number". may have prefix with zeros.
    OBJECT                     MATERIAL
    Cheers !

  • Tree Cell Renderer

    is there anyone who knows or can point me to some explanation
    on how to place a background image inside the tree??
    i'm trying to place different images for in behind the text
    and icons for each state, open and close.
    any info would be appreciated.
    thanks...

    You will need to specify an itemRenderer for your tree.
    Probably the easiest thing to do is to create an Actionscript
    itemRenderer that extends the current TreeItemRenderer. In your
    renderer, you can override the updateDisplayList function to allow
    for a background image depending on your data.
    Here is a skeleton of what your itemRenderer might look like:
    package
    import mx.controls.treeClasses.*;
    import mx.collections.*;
    public class MyTreeItemRenderer extends TreeItemRenderer
    public function MyTreeItemRenderer()
    super();
    override protected function
    updateDisplayList(unscaledWidth:Number,
    unscaledHeight:Number):void
    super.updateDisplayList(unscaledWidth, unscaledHeight);
    if(super.data)
    //Add your code here to add an image to the background of
    this item

  • Popup from ALV for displaying full text = problems!!!

    Dear all,
       I created an ALV to display data. In this ALV, I have a text column, which just show FIRST 30 characters of the original text.
      Now I want to double click on that field, and it will pop up a small window to show full text (the original text, unknown length).
    I made lots of references and I decided to use FM POPUP_WITH_TABLE because of some reasons:
    a)  the original text is retrieved from another FM READ_TEXT. After the call of READ_TEXT, the text will be stored into an internal table. Then, it can be passed to POPUP_WITH_TABLE without more modification.
    b) POPUP_WITH_TABLE can show the text more meaningfully. I mean, if the length of the text is greater than the length of the popup window, it <b>automatically break the line and displays the rest in the next line</b>. ( FM POPUP_TO_INFORM does NOT do that.)
    However, I've faced some <b>PROBLEMS</b> with FM POPUP_WITH_TABLE
    1) The popup window has 2 button OK and Cancel. <b>Is there any way just to display Cancel button?</b>
    2) If I click on Cancel or OK without choose any line on the popup window => It will raise an exception, called BREAK_OFF. In this case
    If the clicked button is CANCEL => it will close the popup
    If  the clicked button is OK => nothing happens. And I must click on CANCEL to close the popup.
    <b>I want to close the popup windown without raising any exceptions. How can I ?</b>
    3) When I enter many complex selection criteria on Selection Screen to limit the result, displaying ALV is good. But when I click on the text field to popup => the report cannot be manipulated. I have to kill the session in SM04.
    <b>What's wrong? </b>(because for single selection criteria, it works well.)
    Every body has any suggestions?
    Thank you in advance

    I solved it. I just use another list for pop-up event.
    Although it worked well now, I thought it was not a good solution.
    Thank you all of you.
    Best regards.

  • How to create a group/list of check box variables for display in text field, in appended format

    I need to identify a series of single-response checkbox variables and display the ones selected (as a group) in a text field in an appended (comma, space) format. Last week, you provided a great little script for a similar need using List Box (multiple response) variables. This time I need to know how to formally identify the checkbox variables and, I presume, use a similar script to display the results in a comma, space format.
    You've been of great help.
    Thanks

    Here's the script adapted to this situation. It assumes there are ten check boxes named cb1, cb1, cb2, ...cb10.
    // Custom Calculate script for text field
    (function () {
        // Initialize the string
        var v, s = "";
        // Loop through the check boxes to build up a string
        for (var i = 1; i < 11; i++) {
            // Get the value of the current check box
            v = getField("cb" + i).value;
            if (v !== "Off") {
                if (s) s += ", ";  // Add a comma and a space if needed
                s += v;  // Add the selected value
        // Set this field value to the string
        event.value = s;
    You'll have to change the field name and starting/ending numbers to match your form.

  • Tree Cell Renderer Highlight

    I have implemented a cutom renderer for my JTree that displays different icons for different types of data. However I cannot get the highlight color to work at all. Before using my custom renderer, the nodes would highlight when selected or being dragged over on and drag and drop operation. Now I cannot get this type of behavior. I attempted using the setBackground() method to set the color according to the "sel" flag that gets passed in to the getTreeCellRendererComponent method. Any advice would be appreciated.

    I have implemented a cutom renderer for my JTree that displays different icons for different types of data. However I cannot get the highlight color to work at all. Before using my custom renderer, the nodes would highlight when selected or being dragged over on and drag and drop operation. Now I cannot get this type of behavior. I attempted using the setBackground() method to set the color according to the "sel" flag that gets passed in to the getTreeCellRendererComponent method. Any advice would be appreciated.

  • Canon Pixma iP4200 - print settings for large black (text) cartridge?

    I would be glad of advice as to what settings to use so that my Canon Pixma iP4200 uses its separate (for text) black ink cartridge, as opposed to its 'photo' black cartridge.
    I have put screenshots of the options here:
    http://homepage.mac.com/gillylal/print
    Thank you very much for any advice.

    Hello Gillylal,
    Of the four settings listed, the best for text only printing is "Composite Document". Most of the time this will mean that black text will use the black cartidge, as opposed to using CMY to print a black equivalent. However, this can vary depending on the application and the colour value it sends to the printer for its text. PowerPoint can often send it's text data with an RGB value not quite equal to black. Therefore the printer can mix some of the other colours with the black, or use the CMY tanks to print a brownish 'black'.
    As for the lack of a text only option, well this is the grayscale setting. Regardless of the colour value, only the black cartridge will be used. And if the text does have some value other than black, it will look less solid as the printer does its best to make the colour look different by using the black cartridge.
    Hope this helps...

  • Best rendering settings for my specs?

    I have been digging around the internet and toying with the settings others have suggested for after effects, but not quite gotten what i want. I do have the secret options checked and purged the memory use from previews and whatnot.
    my machine has an i7 2600k oc'd to 4.4, 8 gb of ram and a geforce 560 ti...
    however i cant seem to get a render to work at all (or incredily slow) unless i have opengl render checked. and while that options isnt too bad, i'm not making much use of my comps power. At best i'm using all all 8 cores at about 15-20% and the gpu isnt seeing much more stress on it than that.
    any suggestings would be greatly appreciated 

    There is no way to enforce anything beyond a certain point. Rendering performance depends on what goes on in the project, what effects are used etc.. Slow disks will hamper footage I/O, temporal calculations will turn off MP rendering and make thing generally slower and encoding to specific formats wil ldo the same. So in short, you are looking for a simple answer that doesn't exist. in fact settings may need to be adjusted with every new project. Anyway, read this.
    Mylenium

  • Possible to lock *all* settings for a completed project?

    Hi
    Once a project is completed is it possble to lock all the project settings?

    I know that you can lock tracks, but that doesn't lock the parameters of things like "gain" plugins in the mixer settings. So I was wondering if there was a more general lock control option on everything
    I suppose you could freeze tracks? That would basically lock all of your plug in settings, although I'm not exactly sure what you're trying to achieve.

  • Forecasting and User Settings For Displaying Historical Values

    Hello,
    I am attempting to perform a forecast model.  After entering the selection criteria I get the message "Forecast includes only historical values as from P 01/2011 --> F1" .
    when I expand on the message I see
    Forecast includes only historical values as from P 01/2011 --> F1
         Message no. MA 559
    Diagnosis
         You want to carry out the forecast for the historical values from 04/2010 to 08/2011.  However, historical values prior to P
         01/2011 are zero.  The system response to this situation depends on the user.  The following responses are possible:
         1.  The entire historical period is included nonetheless.
         2.  Historical values before P 01/2011 are not included.
         The user setting that has been made for you corresponds to variant 2.
    Procedure
       You can change the historical values in the period from 04/2010 to 08/2011 manually, regardless of the user setting.  If
       variant 2 applies and zero values before P 01/2011 are then corrected, the historical period used by the forecast is extended
       to include this date or period.
    Questions
       1.  Where does the "user setting that has been make for you corresponds to variant 2" reside in SAP?  How can I see this? 
            What other variant values are available to me?  How would I change this value if I wanted to?  This seems to indicate that
            this is a user profile setting since it's dependent on the user????
       2.  I am ?assuming? that variant 2 means that "2.  Historical values before P 01/2011 are not included" is the choice, above,
            that is being made.  I ?assume? that variant 2 means that the forecast extends back as far in the selected period as there 
            is a value that is found that is not zero.  Is that correct?
    Any insight/help would be appreciated.
    Thanks!

    Hi Tilak,
    Plz find the below threads for your reference...
    Change in Decimal Points with comma
    Decimal Notation
    Regarding Decimal Notation
    Defualt Value of Requisitioner
    Again back to u all :)
    can not put decimal quantity in BOM quantity
    Also find the below search link...
    https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=defaultsettingsinSU01decimal+notation&adv=false&sortby=cm_rnd_rankvalue
    Assign points if this helps u...
    Regards,
    KK.

Maybe you are looking for

  • Once I sync my iPad to my Mac can we play the apps on my mac?

    I successfully sync'd my Ipad to my Mac laptop.  Now what was the point besides saving any music and apps that may potentially be deleted on the ipad? I thought since I purchased minecraft full version app on my son's ipad for him that I could sync i

  • TS3297 my itunes store isnt working any ideas?

    my itunes store isnt working any ideas i really need help i want to download apps and things like that i need it asap as i have my ipad ipod and i phone to put apps on thanks x

  • Handling large files for displaying within a JTextPane

    I have some (very) large trace files sometimes up to more than 100MB and I want to group the traces which are originally stored unordered into this trace file. When I tried to read in a just 16MB large trace file and used this command line option: -X

  • Adobe Photo Deluxe 2 won't load photo from scanner

    I have been using APD2 with my scanner and as stand-alone for a long time. Recently, it stopped accepting the scanner files - something about not recognizing the file type or extension. What can be done on this? Also after loading and editing a photo

  • Cannot pair iPhone with hands free car system

    I am having trouble with my Merecedes recognizing my iPhone. I paired it and the phone is "authorized" with the car, but when I try to connect the two, the screen for the phone flashes and then disappears saying "no phone". It worked fine with my Bla