Setting line color of JTree's

Hi,
I want to set the color of JTree's linestyle which areranch lines. what should i set to get the desired result. i set the linestyle by
tree.putClientProperty("JTree.lineStyle", "Angled");
How can i set the linecolor?
Thnaks,
Sato

I got it to work with this:
UIManager.put( "Tree.line", Color.black ); // for horizontal lines
UIManager.put( "Tree.hash", Color.black ); // for vertical lines

Similar Messages

  • Set different color for one JTree node

    hello,
    I managed to find how to set a color for Jtree nodes but the problem is that with my method all the nodes will b the same color whereas i'm looking to have nodes of different color depending on the situation.
    the method for setting all Jtree nodes the same color(other than black):
    tree.setCellRenderer(
    new DefaultTreeCellRenderer() {
       public Color getTextNonSelectionColor() {
         return Color.lightGray; } });I WANT TO CHOSSE EACH COLOR FOR EACH NODE
    help plz
    thanks

    You need to implement TreeCellRenderer interface
    public Component getTreeCellRendererComponent(JTree tree,
                                                  Object value,
                                                  boolean sel,
                                                  boolean expanded,
                                                  boolean leaf,
                                                  int row,
                                                  boolean hasFocus)You can know which node is rendering by check value argument. Please read DefaultTreeCellRenderer's code.

  • How to set dash line color(two colors)?

    hello all:
    Does anyone know how to set dash line color in java?
    I only know how to set line color with a single color.
    g2.setColor(Color.black);
    g2.setStroke(dashed);
    g2.draw(new Rectangle2D.Double(50, 50, 200,100));
    what I need to implement is two colors interleave on the dash line.
    so that dash line looks like this:
    ==== ====
    red white red white
    thank you for any comments.
    -Daniel.

    create 2 strokes, space them appropriately, draw the rectangle twice.

  • Changing line color on XY plot

    This should be something really simple. I simple created a property node, set the active plot, and set the plot.color. What happens to some plots is the points change to my specified color and other stays as my background plot color which is white. I cant seem to get the line color to change with the point color. There are ways I can change it at run time, by right click on the plot and going into properties and setting line color in that tab.
    What am I doing that I cant get this to work at runtime?
    I attached the plot, just ignore all the missing VIs you should be able to see the problem.
    Attachments:
    SteadyStatePlot1.vi ‏350 KB

    It works just fine here using LabVIEW 7.1. Could you do us a favor and make a mini demo, just containing the xy graph, some data for it, and the related property nodes to demonstrate your problem.
    Overall comment on your VI:
    Sorry, but I am absolutely horrified by your code. I cannot believe that you need all those property nodes, especially the signaling ones, they should be used very sparingly. (For example the FOR loops on top center and in the event called "clear all points" are just pumping hot air, repeating the same action and signaling (!!) every iteration.) It also just cannot be healthy if a single event calls tons of signaling properties, such as in the above mentioned event case. Then, in the timeout event, you are rewriting the plot la
    bels and names every 10 ms. Do they really change that often???
    Please let us help you in your overall program design. It will make a big difference in your future, more complex projects if certain common desing misconceptions are not propagated. I think entire sections of your program can be deleted without loss in functionality, the code can be stripped to <20% and the CPU usage can be reduce to <2% of the current situation. Just my wild guess.
    The above is well meaning criticism, so don't take it personal. I am much harsher looking at my own early code from 8 years ago. :-) Good luck!
    LabVIEW Champion . Do more with less code and in less time .

  • CR 9 - Need HELP Setting Line Graph colors in the Chart Expert

    Post Author: desselle
    CA Forum: Charts and Graphs
    Hello,
    I created a Crystal Report (CR) based off an existing Trend Analysis report. I have created a VB6 application that calls the .RPT file I created for the report in CR.  The VB6 app sets the report recordset via code that corresponds to the .TTX file, and the parameters .  The report contains a Line graph that plots five pieces of data.  The report & graph work good.  The Problem: CR determines the color of each line on the graph.  However, I need to set the color for each line to correspond to the colors used on our existing reports.  The users are accustom to a certain color representing a certain set of data on the existing reports.   I have tried everything I can think of and from all documentation I can find, and nothing changes the line colors.   I have tried all of the following:
    1.) From the Chart Expert, Option tab, I click the Format button next to Color and setup conditional color settings per each piece of data.   However, when I run the report these conditional color settings are not reflected on the CR graph.     I am using formula fields (based off database fields in the recordset) to produce the report.  However, I only see the database fields to use in the conditional color formatting screen and not the formula fields.    I thought this would possibly be the cause why the colors wonu2019t change on the CR, but I canu2019t find a way to make the formula fields show up in the list.
    2.)Also, I tried right clicking the individual lines of the graph and change the selected item color, but this didnu2019t change the color either.  I do this in Design mode and Preview mode and neither one changes the color of the lines on the graph.
    3.)I have also looked into the CR object model to see if I can change the line colors of the graph via code and it doesn't look like I am given this flexibility.
    Do you know what I am doing wrong here?   I just want to be able to set the color of each line on the CR graph to the color I want instead of using the default colors.  Are there some Hot Fixes that I need to apply to my copy of CR?
    Thanks

    Post Author: desselle
    CA Forum: Charts and Graphs
    Hello,
    I got the problem fixed w/ the line graph not making the data lines the same color on the report as on the frmPlot graph.   Compare the two screen shots below.   The problem was as follows:  When I created the graph (in the Chart Expert) the field u201CReadingDateu201D was not one of the Report Fields, and all the other fields were Report Fields (Reading, LowAlarm, UpperAlarm, LowerLimit, & UpperLimit). See the 3rd screen shot below.  ReadingDate does show up as a Report Field now but it wasnu2019t at first.   Originally, this field was only available in the Chart Expert as a recordset field.  When I changed this field to be a Report Field, the graph then allowed me to change the data series line colors.   This was not obvious at all.   From the beginning when I setup the graph and passed in the recordset from VB it graphed all of the data series fine.   The colors that the Chart Expert chose for each line just didnu2019t match what was on the frmPlot graph.   Anyway, it is working now.     I can at least say I learned (somethingu2019s to-do and somethingu2019s not to-do) a good bit about Crystal Reports in the process.
    Thanks

  • CR XI - Problem Setting Line Graph colors in the Chart Expert

    Post Author: desselle
    CA Forum: Charts and Graphs
    Hello,
    I created a Crystal Report (CR) of an existing Trend Analysis report. I have created a VB6 application that calls the .RPT file I created for the report in CR.  The VB6 app sets the report recordset via code that corrsponds to the .TTX file, and the parameters .  The report contains a Line graph that plots five pieces of data.  The report & graph work good.  CR determines the color of each line on the graph.  However, I need to set the color for each line to correspond to the colors used on our existing reports.  The users are accustom to a certain color representing a certain set of data on the existing reports.   I have tried everything I can think of and from all documentation I can find, and nothing changes the line colors.   I have tried all of the following:
    1.) From the Chart Expert, Option tab, I click the Format button next to Color and setup conditional color settings per each piece of data.   However, when I run the report these conditional color settings are not reflected on the CR graph.     I am using formula fields (based off database fields in the recordset) to produce the report.  However, I only see the database fields to use in the conditional color formatting screen and not the formula fields.    I thought this would possibly be the cause why the colors wonu2019t change on the CR, but I canu2019t find a way to make the formula fields show up in the list.
    2.)Also, I tried right clicking the individual lines of the graph and change the selected item color, but this didnu2019t change the color either.  I do this in Design mode and Preview mode and neither one changes the color of the lines on the graph.
    3.)I have also looked into the CR object model to see if I can change the line colors of the graph via code and it doesn't look like I am given this flexibility.
    Do you know what I am doing wrong here?   I just want to be able to set the color of each line on the CR graph to the color I want instead of using the default colors.
    Thanks,Steve

    Post Author: desselle
    CA Forum: Charts and Graphs
    Hello,
    I got the problem fixed w/ the line graph not making the data lines the same color on the report as on the frmPlot graph.   Compare the two screen shots below.   The problem was as follows:  When I created the graph (in the Chart Expert) the field u201CReadingDateu201D was not one of the Report Fields, and all the other fields were Report Fields (Reading, LowAlarm, UpperAlarm, LowerLimit, & UpperLimit). See the 3rd screen shot below.  ReadingDate does show up as a Report Field now but it wasnu2019t at first.   Originally, this field was only available in the Chart Expert as a recordset field.  When I changed this field to be a Report Field, the graph then allowed me to change the data series line colors.   This was not obvious at all.   From the beginning when I setup the graph and passed in the recordset from VB it graphed all of the data series fine.   The colors that the Chart Expert chose for each line just didnu2019t match what was on the frmPlot graph.   Anyway, it is working now.     I can at least say I learned (somethingu2019s to-do and somethingu2019s not to-do) a good bit about Crystal Reports in the process.
    Thanks

  • How do I set default colors for XY chart series (lines and legend)

    I am implementing a line chart and need to override the default (caspian style) colors for the line colors and the legend symbols. I'm not displaying the chart symbols themselves as that would make the chart look bad. I've been able to successfully set the default colors for the lines via the CSS below, but cannot find a way to do the same for the series symbols that appear in the chart legend. How do I do this? Thanks.
    .default-color0.chart-series-line {
      -fx-stroke: rgb(0, 102, 255);
    .default-color1.chart-series-line {
      -fx-stroke: rgb(0, 255, 102);
    ...Update:
    Figured it out. Need to do the following:
    .default-color0.chart-line-symbol {
      -fx-background-color: rgb(R, G, B);
    }Edited by: 998038 on May 16, 2013 4:09 PM

    Here is some css to customize the line and legend colors in a line chart.
    /** file: chart.css
        place in same directory as LineChartWithCustomColors.java */
    .default-color0.chart-series-line {
      -fx-stroke: rgb(0, 102, 255);
    .default-color1.chart-series-line {
      -fx-stroke: rgb(0, 255, 102);
    .default-color0.chart-line-symbol {
      -fx-background-color: rgb(0, 102, 255), white;
    .default-color1.chart-line-symbol {
      -fx-background-color: rgb(0, 255, 102), white;
    }And a test harness to try it:
    import javafx.application.Application;
    import javafx.event.*;
    import javafx.scene.Scene;
    import javafx.scene.chart.*;
    import javafx.scene.control.*;
    import javafx.scene.input.*;
    import javafx.stage.Stage;
    public class LineChartWithCustomColors extends Application {
        @Override public void start(final Stage stage) {
            stage.setTitle("Line Chart Sample");
            //defining the axes
            final NumberAxis xAxis = new NumberAxis();
            xAxis.setLabel("Number of Month");
            final NumberAxis yAxis = new NumberAxis();
            //creating the chart
            final LineChart<Number,Number> lineChart =
                    new LineChart<>(xAxis,yAxis);
            lineChart.setTitle("Stock Monitoring, 2010");
            lineChart.setCreateSymbols(false);
            //defining a series
            XYChart.Series series = new XYChart.Series();
            series.setName("My portfolio");
            //populating the series with data
            series.getData().setAll(
              new XYChart.Data(1, 23),
              new XYChart.Data(2, 14),
              new XYChart.Data(3, 15),
              new XYChart.Data(4, 24),
              new XYChart.Data(5, 34),
              new XYChart.Data(6, 36),
              new XYChart.Data(7, 22),
              new XYChart.Data(8, 45),
              new XYChart.Data(9, 43),
              new XYChart.Data(10, 17),
              new XYChart.Data(11, 29),
              new XYChart.Data(12, 25)
            lineChart.getData().add(series);
            //adding a context menu item to the chart
            final MenuItem resizeItem = new MenuItem("Resize");
            resizeItem.setOnAction(new EventHandler<ActionEvent>() {
              @Override public void handle(ActionEvent event) {
                System.out.println("Resize requested");
            final ContextMenu menu = new ContextMenu(
              resizeItem
            lineChart.setOnMouseClicked(new EventHandler<MouseEvent>() {
              @Override public void handle(MouseEvent event) {
                if (MouseButton.SECONDARY.equals(event.getButton())) {
                  menu.show(stage, event.getScreenX(), event.getScreenY());
            Scene scene =
              new Scene(
                lineChart,800,600
            stage.setScene(
              scene
            stage.show();
            scene.getStylesheets().add(
              getClass().getResource("chart.css").toExternalForm()
        public static void main(String[] args) {
            launch(args);
    }

  • How to set background color for a JFrame

    Hi,
    i am new to swing programming. I have created a JFrame called framehelp and i placed some labels in the frame.
    I have set the background color as yellow for the frame ie by setBackground(new java.awt.Color(255, 255, 204));
    But after compiling the program i am still getting the background color of frame as gray.
    How can i change the background color of frame as lightish yellow.
    I have used NETBEANS to generate this code and i am posting the code..
    Kindly help me
    Thanks in adavance
    public class framehelp extends javax.swing.JFrame {
        /** Creates new form framehelp */
        public framehelp() {
            initComponents();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        private void initComponents() {
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jLabel3 = new javax.swing.JLabel();
            jLabel4 = new javax.swing.JLabel();
            jLabel5 = new javax.swing.JLabel();
            jLabel6 = new javax.swing.JLabel();
            jLabel8 = new javax.swing.JLabel();
            jLabel9 = new javax.swing.JLabel();
            jLabel10 = new javax.swing.JLabel();
            jLabel11 = new javax.swing.JLabel();
            jLabel12 = new javax.swing.JLabel();
            jLabel13 = new javax.swing.JLabel();
            jLabel7 = new javax.swing.JLabel();
            jLabel14 = new javax.swing.JLabel();
            jLabel15 = new javax.swing.JLabel();
            jLabel16 = new javax.swing.JLabel();
            jLabel17 = new javax.swing.JLabel();
            jLabel18 = new javax.swing.JLabel();
            jLabel19 = new javax.swing.JLabel();
            jLabel20 = new javax.swing.JLabel();
            jLabel21 = new javax.swing.JLabel();
            jLabel22 = new javax.swing.JLabel();
            jLabel23 = new javax.swing.JLabel();
            jLabel24 = new javax.swing.JLabel();
            jLabel25 = new javax.swing.JLabel();
            jLabel26 = new javax.swing.JLabel();
            jLabel27 = new javax.swing.JLabel();
            jLabel28 = new javax.swing.JLabel();
            jLabel29 = new javax.swing.JLabel();
            jLabel30 = new javax.swing.JLabel();
            jLabel31 = new javax.swing.JLabel();
            jLabel32 = new javax.swing.JLabel();
            jLabel33 = new javax.swing.JLabel();
            getContentPane().setLayout(null);
            setBackground(new java.awt.Color(255, 255, 204));
            setForeground(new java.awt.Color(204, 204, 204));
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosing(java.awt.event.WindowEvent evt) {
                    exitForm(evt);
            jLabel1.setText("The CAME framework software measurement process evaluation is used to determine the Level of  measurement in the ITarea. This measurementprocess evaluation is ");
            getContentPane().add(jLabel1);
            jLabel1.setBounds(40, 50, 41, 16);
            jLabel2.setText("performed individually for software coomponents ie SoftwareProduct, SoftwareProcess and SoftwareResource.");
            getContentPane().add(jLabel2);
            jLabel2.setBounds(40, 70, 41, 16);
            jLabel3.setText("Below we describe the steps which will guide through the measurement process evaluation. There are two types of evaluation considerd here, General evaluation");
            getContentPane().add(jLabel3);
            jLabel3.setBounds(40, 100, 913, 16);
            jLabel4.setText("and Evaluation with respect to a standard. The measurement intensions considerd by varoius measurement standards will be used in our tool based method.  ");
            getContentPane().add(jLabel4);
            jLabel4.setBounds(40, 120, 893, 16);
            jLabel5.setText("Information about the measurement standards can be found at     www.iso.org ,    www.ieee.org.");
            getContentPane().add(jLabel5);
            jLabel5.setBounds(40, 140, 542, 16);
            jLabel6.setText("Steps to calculate the MetricsLevel");
            getContentPane().add(jLabel6);
            jLabel6.setBounds(40, 190, 199, 16);
            jLabel8.setText("2 )  The opened frame consists of several  metrics and measures, evaluation level buttons, result textfields and selection choice lists. To calculate");
            getContentPane().add(jLabel8);
            jLabel8.setBounds(70, 240, 41, 16);
            jLabel9.setText("general Metricslevel without any standard, select general from Measurement standard choice list. then select Both from scaleType choice list and finally select metrics ");
            getContentPane().add(jLabel9);
            jLabel9.setBounds(90, 260, 949, 16);
            jLabel10.setText(" and measures from the frame and press MetricsLevel Button. The metricslevel for the selected metrics will be displayed in textfield1.");
            getContentPane().add(jLabel10);
            jLabel10.setBounds(90, 280, 756, 16);
            jLabel11.setText("3 ) To determine MetricsLevel with respect to a standard select a standard from MeasurementStandard choice list, select Both from ScaleType choice list and finally ");
            getContentPane().add(jLabel11);
            jLabel11.setBounds(70, 300, 933, 16);
            jLabel12.setText("select darkened metrics and measures and press MetricsLevel Button. The Metrics Level for the selected Metrics and standard will be diplayed in textfield1.");
            getContentPane().add(jLabel12);
            jLabel12.setBounds(90, 320, 883, 16);
            jLabel13.setText("4 ) Repeat steps 1 2, 3  for ProcessMeasurementEvaluation and ResourceMeasurementEvaluation menu items from the select menu.");
            getContentPane().add(jLabel13);
            jLabel13.setBounds(70, 340, 751, 16);
            jLabel7.setText("1 ) Select ProductMeasurementEvaluation menu item from the select menu,a frame called CAME framework software product measurement evaluation will be opened. ");
            getContentPane().add(jLabel7);
            jLabel7.setBounds(70, 220, 946, 16);
            jLabel14.setText("Steps to calculate MeasurementLevel");
            getContentPane().add(jLabel14);
            jLabel14.setBounds(50, 390, 214, 16);
            jLabel15.setText("1 ) Select ProductMeasurementEvaluation menu item from the select menu,a frame called CAME framework software product measurement evaluation will be opened.");
            getContentPane().add(jLabel15);
            jLabel15.setBounds(80, 420, 943, 16);
            jLabel16.setText("2 ) The opened frame consists of several  metrics and measures, evaluation level buttons, result textfields and selection choice lists. To calculate");
            getContentPane().add(jLabel16);
            jLabel16.setBounds(80, 450, 822, 16);
            jLabel17.setText("general Measurementlevel without any standard, select general from Measurement standard choice list. then select Quantitative measures from scaleType choice list ");
            getContentPane().add(jLabel17);
            jLabel17.setBounds(100, 470, 943, 16);
            jLabel18.setText("and finally select metrics and measures from the frame and press MeasurementLevel Button. The MeasurementLevel for the selected metrics will be displayed in textfield2.");
            getContentPane().add(jLabel18);
            jLabel18.setBounds(100, 490, 973, 20);
            jLabel19.setText("3 ) To determine MeasurementLevel with respect to a standard select a standard from MeasurementStandard choice list, select Quantitative measures from ScaleType choice list");
            getContentPane().add(jLabel19);
            jLabel19.setBounds(80, 510, 1009, 16);
            jLabel20.setText("and finally select darkened metrics and measures and press MeasurementLevel Button. The MeasurementLevel  will be diplayed in textfield2.");
            getContentPane().add(jLabel20);
            jLabel20.setBounds(100, 530, 799, 16);
            jLabel21.setText("4 )Repeat steps 1 2, 3  for ProcessMeasurementEvaluation and ResourceMeasurementEvaluation menu items from the select menu.");
            getContentPane().add(jLabel21);
            jLabel21.setBounds(80, 550, 748, 16);
            jLabel22.setText("Steps to calculate MeasurementProcessLevel");
            getContentPane().add(jLabel22);
            jLabel22.setBounds(50, 600, 262, 16);
            jLabel23.setText("1 ) Select ProductMeasurementEvaluation menu item from the select menu,a frame called CAME framework software product measurement evaluation will be opened.");
            getContentPane().add(jLabel23);
            jLabel23.setBounds(80, 630, 943, 16);
            jLabel24.setText("2 )The opened frame consists of several  metrics and measures, evaluation level buttons, result textfields and selection choice lists. To calculate");
            getContentPane().add(jLabel24);
            jLabel24.setBounds(80, 650, 819, 16);
            jLabel25.setText("general MeasurementProcesslevel without any standard, select general from Measurement standard choice list. then select Quantitative measures from scaleType ");
            getContentPane().add(jLabel25);
            jLabel25.setBounds(100, 670, 930, 16);
            jLabel26.setText("choice list, enter migrated metrics if any in textfield  below migrated metrics label and finally select metrics measures from the frame and press ");
            getContentPane().add(jLabel26);
            jLabel26.setBounds(100, 690, 818, 16);
            jLabel27.setText("MeasurementProcessLevel Button. The MeasurementProcessLevel for the selected metrics will be displayed in textfield3.");
            getContentPane().add(jLabel27);
            jLabel27.setBounds(100, 710, 691, 16);
            jLabel28.setText("3 ) To determine MeasurementProcessLevel with respect to a standard select a standard from MeasurementStandard choice list, select Quantitative measures from ");
            getContentPane().add(jLabel28);
            jLabel28.setBounds(80, 740, 937, 16);
            jLabel29.setText("from ScaleType choice list, enter migrated metrics if any in textfield below migrated metrics and finally select darkened metrics and measures and press  ");
            getContentPane().add(jLabel29);
            jLabel29.setBounds(100, 760, 873, 16);
            jLabel30.setText("MeasurementProcessLevel Button. The MeasurementprocessLevel for the selected metrics will be displayed in textfield3");
            getContentPane().add(jLabel30);
            jLabel30.setBounds(100, 780, 687, 16);
            jLabel31.setText("4 ) Repeat steps 1,2,3 for ProcessMeasurementEvaluation and ResourceMeasurementEvaluation menuitems.");
            getContentPane().add(jLabel31);
            jLabel31.setBounds(80, 800, 618, 16);
            jLabel32.setText("Steps to calculate MeasuredSoftwareProcessLevl");
            getContentPane().add(jLabel32);
            jLabel32.setBounds(60, 830, 285, 16);
            jLabel33.setText("1 ) Follow the same steps as MetricsLevel calcualtion but select metrics and measures covered by CAME Tools only.");
            getContentPane().add(jLabel33);
            jLabel33.setBounds(90, 860, 657, 16);
            java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
            setBounds((screenSize.width-1100)/2, (screenSize.height-940)/2, 1100, 940);
        /** Exit the Application */
        private void exitForm(java.awt.event.WindowEvent evt) {
            System.exit(0);
         * @param args the command line arguments
        public static void main(String args[]) {
            new framehelp().show();
        // Variables declaration - do not modify
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel10;
        private javax.swing.JLabel jLabel11;
        private javax.swing.JLabel jLabel12;
        private javax.swing.JLabel jLabel13;
        private javax.swing.JLabel jLabel14;
        private javax.swing.JLabel jLabel15;
        private javax.swing.JLabel jLabel16;
        private javax.swing.JLabel jLabel17;
        private javax.swing.JLabel jLabel18;
        private javax.swing.JLabel jLabel19;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JLabel jLabel20;
        private javax.swing.JLabel jLabel21;
        private javax.swing.JLabel jLabel22;
        private javax.swing.JLabel jLabel23;
        private javax.swing.JLabel jLabel24;
        private javax.swing.JLabel jLabel25;
        private javax.swing.JLabel jLabel26;
        private javax.swing.JLabel jLabel27;
        private javax.swing.JLabel jLabel28;
        private javax.swing.JLabel jLabel29;
        private javax.swing.JLabel jLabel3;
        private javax.swing.JLabel jLabel30;
        private javax.swing.JLabel jLabel31;
        private javax.swing.JLabel jLabel32;
        private javax.swing.JLabel jLabel33;
        private javax.swing.JLabel jLabel4;
        private javax.swing.JLabel jLabel5;
        private javax.swing.JLabel jLabel6;
        private javax.swing.JLabel jLabel7;
        private javax.swing.JLabel jLabel8;
        private javax.swing.JLabel jLabel9;
        // End of variables declaration
    }

    1. When you post code, post a minimal example. Did we have to scroll through
    all those bloody labels.
    2. Can't say much for the quality of code NetBeans generates.
    3. To answer your question (sorry, I don't have an autographed copy of the photo):
    import java.awt.*;
    import java.net.*;
    import javax.swing.*;
    public class Example {
        public static void main(String[] args) throws MalformedURLException {
            final JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            Container cp = f.getContentPane();
            cp.setBackground(new Color(0xff, 0xff, 0xee));
            cp.add(new JLabel("set the color on the content pane, not the frame"), BorderLayout.SOUTH);
            URL url = new URL("http://today.java.net/jag/bio/JagHeadshot-small.jpg");
            cp.add(new JLabel(new ImageIcon(url)));
            f.pack();
            SwingUtilities.invokeLater(new Runnable(){
                public void run() {
                    f.setLocationRelativeTo(null);
                    f.setVisible(true);
    }

  • How to set background color in a docking container?

    Hi guys!
    Is it possible to set a background color for a docking container?
    I don't find any appropriate method to do that.
    Is there actually a way?

    Hi,
    Please refer the below program as a reference for Color using Docking Container Concept.
    REPORT zcuitest_alv_07.
    * Use of colours in ALV grid (cell, line and column)            *
    * Table
    TABLES : mara.
    * Type
    TYPES : BEGIN OF ty_mara,
              matnr         LIKE mara-matnr,
              matkl         LIKE mara-matkl,
              counter(4)    TYPE n,
              free_text(15) TYPE c,
              color_line(4) TYPE c,           " Line color
              color_cell    TYPE lvc_t_scol,  " Cell color
    END OF ty_mara.
    * Structures
    DATA  : wa_mara     TYPE ty_mara,
            wa_fieldcat TYPE lvc_s_fcat,
            is_layout   TYPE lvc_s_layo,
            wa_color    TYPE lvc_s_scol.
    * Internal table
    DATA : it_mara     TYPE STANDARD TABLE OF ty_mara,
           it_fieldcat TYPE STANDARD TABLE OF lvc_s_fcat,
           it_color    TYPE TABLE          OF lvc_s_scol.
    * Variables
    DATA : okcode LIKE sy-ucomm,
           w_alv_grid          TYPE REF TO cl_gui_alv_grid,
           w_docking_container TYPE REF TO cl_gui_docking_container.
    PARAMETERS : p_column AS CHECKBOX,
                 p_line   AS CHECKBOX,
                 p_cell   AS CHECKBOX.
    START-OF-SELECTION.
      PERFORM get_data.
    END-OF-SELECTION.
      PERFORM fill_catalog.
      PERFORM fill_layout.
      CALL SCREEN 2000.
    *&      Module  status_2000  OUTPUT
    *       text
    MODULE status_2000 OUTPUT.
      SET PF-STATUS '2000'.
    ENDMODULE.                 " status_2000  OUTPUT
    *&      Module  user_command_2000  INPUT
    *       text
    MODULE user_command_2000 INPUT.
      DATA : w_okcode LIKE sy-ucomm.
      MOVE okcode TO w_okcode.
      CLEAR okcode.
      CASE w_okcode.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " user_command_2000  INPUT
    *&      Module  alv_grid  OUTPUT
    *       text
    MODULE alv_grid OUTPUT.
      IF w_docking_container IS INITIAL.
        PERFORM create_objects.
        PERFORM display_alv_grid.
      ENDIF.
    ENDMODULE.                 " alv_grid  OUTPUT
    *&      Form  create_objects
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM create_objects.
    * Ratio must be included in [5..95]
      CREATE OBJECT w_docking_container
        EXPORTING
          ratio                       = 95
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          create_error                = 3
          lifetime_error              = 4
          lifetime_dynpro_dynpro_link = 5
          others                      = 6.
      CREATE OBJECT w_alv_grid
        EXPORTING
          i_parent          = w_docking_container.
    ENDFORM.                    " create_objects
    *&      Form  display_alv_grid
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM display_alv_grid.
      CALL METHOD w_alv_grid->set_table_for_first_display
        EXPORTING
          is_layout                     = is_layout
        CHANGING
          it_outtab                     = it_mara
          it_fieldcatalog               = it_fieldcat
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
    ENDFORM.                    " display_alv_grid
    *&      Form  get_data
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM get_data.
      SELECT * FROM mara UP TO 5 ROWS.
        CLEAR : wa_mara-color_line, wa_mara-color_cell.
        MOVE-CORRESPONDING mara TO wa_mara.
        ADD 1                   TO wa_mara-counter.
        MOVE 'Blabla'           TO wa_mara-free_text.
        IF wa_mara-counter = '0002'
        AND p_line = 'X'.
    * Color line
          MOVE 'C410' TO wa_mara-color_line.
        ELSEIF wa_mara-counter = '0004'
        AND p_cell = 'X'.
    * Color cell
          MOVE 'FREE_TEXT' TO wa_color-fname.
          MOVE '5'         TO wa_color-color-col.
          MOVE '1'         TO wa_color-color-int.
          MOVE '1'         TO wa_color-color-inv.
          APPEND wa_color TO it_color.
          wa_mara-color_cell[] = it_color[].
        ENDIF.
        APPEND wa_mara TO it_mara.
      ENDSELECT.
    ENDFORM.                    " get_data
    *&      Form  fill_catalog
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM fill_catalog.
    * Colour code :                                                 *
    * Colour is a 4-char field where :                              *
    *              - 1st char = C (color property)                  *
    *              - 2nd char = color code (from 0 to 7)            *
    *                                  0 = background color         *
    *                                  1 = blue                     *
    *                                  2 = gray                     *
    *                                  3 = yellow                   *
    *                                  4 = blue/gray                *
    *                                  5 = green                    *
    *                                  6 = red                      *
    *                                  7 = orange                   *
    *              - 3rd char = intensified (0=off, 1=on)           *
    *              - 4th char = inverse display (0=off, 1=on)       *
    * Colour overwriting priority :                                 *
    *   1. Line                                                     *
    *   2. Cell                                                     *
    *   3. Column                                                   *
      DATA : w_position TYPE i VALUE '1'.
      CLEAR wa_fieldcat.
      MOVE w_position TO wa_fieldcat-col_pos.
      MOVE 'MATNR'    TO wa_fieldcat-fieldname.
      MOVE 'MARA'     TO wa_fieldcat-ref_table.
      MOVE 'MATNR'    TO wa_fieldcat-ref_field.
      APPEND wa_fieldcat TO it_fieldcat.
      ADD 1 TO w_position.
      CLEAR wa_fieldcat.
      MOVE w_position TO wa_fieldcat-col_pos.
      MOVE 'MATKL'    TO wa_fieldcat-fieldname.
      MOVE 'MARA'     TO wa_fieldcat-ref_table.
      MOVE 'MATKL'    TO wa_fieldcat-ref_field.
    * Color column
      IF p_column = 'X'.
        MOVE 'C610'     TO wa_fieldcat-emphasize.
      ENDIF.
      APPEND wa_fieldcat TO it_fieldcat.
      ADD 1 TO w_position.
      CLEAR wa_fieldcat.
      MOVE w_position TO wa_fieldcat-col_pos.
      MOVE 'COUNTER'  TO wa_fieldcat-fieldname.
      MOVE 'N'        TO wa_fieldcat-inttype.
      MOVE '4'        TO wa_fieldcat-intlen.
      MOVE 'Counter'  TO wa_fieldcat-coltext.
      APPEND wa_fieldcat TO it_fieldcat.
      ADD 1 TO w_position.
      CLEAR wa_fieldcat.
      MOVE w_position  TO wa_fieldcat-col_pos.
      MOVE 'FREE_TEXT' TO wa_fieldcat-fieldname.
      MOVE 'C'         TO wa_fieldcat-inttype.
      MOVE '20'        TO wa_fieldcat-intlen.
      MOVE 'Text'      TO wa_fieldcat-coltext.
      APPEND wa_fieldcat TO it_fieldcat.
    ENDFORM.                    " fill_catalog
    *&      Form  fill_layout
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM fill_layout.
    * Field that identify color line in internal table
      MOVE 'COLOR_LINE' TO is_layout-info_fname.
    * Field that identify cell color in inetrnal table
      MOVE 'COLOR_CELL' TO is_layout-ctab_fname.
    ENDFORM.                    " fill_layout

  • Set Default Color For BarChart YAxis Data Values.

    Remove alert
    |
    Edit
    |
    Delete
    |
    Change type
    0
    I am new to MS Chart. I am drawing a simple bar chart with following code. My chart draws red lines, for my datapoints    (Y Axis), I want to draw, I want to set the color of remaining data points for example for 1st record (i.e. dt1) my jobData
    have value 10, my graph shows red line for 10 points, for remaining 20 points I need to show the Green Line and also for the remaining data points. Thanks in advance.
             double[] jobData = new double[] { 10, 3, 4, 5, 2, 0, 2, 3, 0, 1 };
                DateTime dt1 = new DateTime(2015, 3, 17, 8, 30, 0);
                DateTime dt2 = new DateTime(2015, 3, 17, 8, 35, 0);
                DateTime dt3 = new DateTime(2015, 3, 17, 8, 40, 0);
                DateTime dt4 = new DateTime(2015, 3, 17, 8, 45, 0);
                DateTime dt5 = new DateTime(2015, 3, 17, 8, 50, 0);
                DateTime dt6 = new DateTime(2015, 3, 17, 8, 55, 0);
                DateTime dt7 = new DateTime(2015, 3, 17, 9, 00, 0);
                DateTime dt8 = new DateTime(2015, 3, 17, 9, 05, 0);
                DateTime dt9 = new DateTime(2015, 3, 17, 9, 10, 0);
                DateTime dt10 = new DateTime(2015, 3, 17, 9, 15, 0);
                DateTime[] xData = new DateTime[] { dt1, dt2, dt3, dt4, dt5,dt6,dt7,dt8,dt9,dt10 };
                InitializeComponent();
                //Horizontal bar chart
                //Create a chart area and add it to the chart
                ChartArea area = new ChartArea("First");
                chart1.ChartAreas.Add(area);
               // chart1.x = Color.Green;
              chart1.Size = new Size(1000, 700);
                //Create a series using the data
                Series barSeries = new Series();
                barSeries.XValueType = ChartValueType.DateTime;
                barSeries.BorderColor = Color.Green;
                barSeries.ChartType = SeriesChartType.Column;
                barSeries.Color = Color.Red;
                area.AxisX.LabelStyle.Format = "HH:mm";
                area.AxisY.Maximum = 30;
                area.AxisY.InterlacedColor = Color.Green;
                area.AxisY.Interval = 1;
              //  chart1.ChartAreas(0).AxisX.LabelStyle.Format = "HH:00"
                barSeries.Points.DataBindXY(xData, jobData );
                //Set the chart type, Bar; horizontal bars
                barSeries.ChartType = SeriesChartType.Bar;
                //Assign it to the required area
                barSeries.ChartArea = "First";
                //Add the series to the chart
                chart1.Series.Add(barSeries);

    Remove alert
    |
    Edit
    |
    Delete
    |
    Change type
    0
    I am new to MS Chart. I am drawing a simple bar chart with following code. My chart draws red lines, for my datapoints    (Y Axis), I want to draw, I want to set the color of remaining data points for example for 1st record (i.e. dt1) my jobData
    have value 10, my graph shows red line for 10 points, for remaining 20 points I need to show the Green Line and also for the remaining data points. Thanks in advance.
             double[] jobData = new double[] { 10, 3, 4, 5, 2, 0, 2, 3, 0, 1 };
                DateTime dt1 = new DateTime(2015, 3, 17, 8, 30, 0);
                DateTime dt2 = new DateTime(2015, 3, 17, 8, 35, 0);
                DateTime dt3 = new DateTime(2015, 3, 17, 8, 40, 0);
                DateTime dt4 = new DateTime(2015, 3, 17, 8, 45, 0);
                DateTime dt5 = new DateTime(2015, 3, 17, 8, 50, 0);
                DateTime dt6 = new DateTime(2015, 3, 17, 8, 55, 0);
                DateTime dt7 = new DateTime(2015, 3, 17, 9, 00, 0);
                DateTime dt8 = new DateTime(2015, 3, 17, 9, 05, 0);
                DateTime dt9 = new DateTime(2015, 3, 17, 9, 10, 0);
                DateTime dt10 = new DateTime(2015, 3, 17, 9, 15, 0);
                DateTime[] xData = new DateTime[] { dt1, dt2, dt3, dt4, dt5,dt6,dt7,dt8,dt9,dt10 };
                InitializeComponent();
                //Horizontal bar chart
                //Create a chart area and add it to the chart
                ChartArea area = new ChartArea("First");
                chart1.ChartAreas.Add(area);
               // chart1.x = Color.Green;
              chart1.Size = new Size(1000, 700);
                //Create a series using the data
                Series barSeries = new Series();
                barSeries.XValueType = ChartValueType.DateTime;
                barSeries.BorderColor = Color.Green;
                barSeries.ChartType = SeriesChartType.Column;
                barSeries.Color = Color.Red;
                area.AxisX.LabelStyle.Format = "HH:mm";
                area.AxisY.Maximum = 30;
                area.AxisY.InterlacedColor = Color.Green;
                area.AxisY.Interval = 1;
              //  chart1.ChartAreas(0).AxisX.LabelStyle.Format = "HH:00"
                barSeries.Points.DataBindXY(xData, jobData );
                //Set the chart type, Bar; horizontal bars
                barSeries.ChartType = SeriesChartType.Bar;
                //Assign it to the required area
                barSeries.ChartArea = "First";
                //Add the series to the chart
                chart1.Series.Add(barSeries);
    Hello,
    Since this issue is mainly related to Chart control, I have helped you move this thread to
    Chart Controls for .NET Framework forum to get help.
    Regards,
    Carl
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Set Default Color For BarChart YAxis.

    I am new to MS Chart. I am drawing a simple bar chart with following code. My chart draws red lines, for my datapoints    (Y Axis), I want to draw, I want to set the color of remaining data points for example for 1st record (i.e. dt1) my jobData
    have value 10, my graph shows red line for 10 points, for remaining 20 points I need to show the Green Line and also for the remaining data points. Thanks in advance.
             double[] jobData = new double[] { 10, 3, 4, 5, 2, 0, 2, 3, 0, 1 };
                DateTime dt1 = new DateTime(2015, 3, 17, 8, 30, 0);
                DateTime dt2 = new DateTime(2015, 3, 17, 8, 35, 0);
                DateTime dt3 = new DateTime(2015, 3, 17, 8, 40, 0);
                DateTime dt4 = new DateTime(2015, 3, 17, 8, 45, 0);
                DateTime dt5 = new DateTime(2015, 3, 17, 8, 50, 0);
                DateTime dt6 = new DateTime(2015, 3, 17, 8, 55, 0);
                DateTime dt7 = new DateTime(2015, 3, 17, 9, 00, 0);
                DateTime dt8 = new DateTime(2015, 3, 17, 9, 05, 0);
                DateTime dt9 = new DateTime(2015, 3, 17, 9, 10, 0);
                DateTime dt10 = new DateTime(2015, 3, 17, 9, 15, 0);
                DateTime[] xData = new DateTime[] { dt1, dt2, dt3, dt4, dt5,dt6,dt7,dt8,dt9,dt10 };
                InitializeComponent();
                //Horizontal bar chart
                //Create a chart area and add it to the chart
                ChartArea area = new ChartArea("First");
                chart1.ChartAreas.Add(area);
               // chart1.x = Color.Green;
              chart1.Size = new Size(1000, 700);
                //Create a series using the data
                Series barSeries = new Series();
                barSeries.XValueType = ChartValueType.DateTime;
                barSeries.BorderColor = Color.Green;
                barSeries.ChartType = SeriesChartType.Column;
                barSeries.Color = Color.Red;
                area.AxisX.LabelStyle.Format = "HH:mm";
                area.AxisY.Maximum = 30;
                area.AxisY.InterlacedColor = Color.Green;
                area.AxisY.Interval = 1;
              //  chart1.ChartAreas(0).AxisX.LabelStyle.Format = "HH:00"
                barSeries.Points.DataBindXY(xData, jobData );
                //Set the chart type, Bar; horizontal bars
                barSeries.ChartType = SeriesChartType.Bar;
                //Assign it to the required area
                barSeries.ChartArea = "First";
                //Add the series to the chart
                chart1.Series.Add(barSeries);

    I am not sure this is exactly what you mean, but, I think the only way to change the data color is to use a different series.
    Imports System.Windows.Forms.DataVisualization.Charting
    Public Class Form6
    Private Sub Form6_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    'setup the chart
    With Chart1.ChartAreas(0)
    .AxisX.Title = "X"
    .AxisX.MajorGrid.LineColor = Color.LightBlue
    .AxisX.Minimum = 0
    .AxisX.Maximum = 24
    .AxisX.Interval = 6
    .AxisY.Title = "Y"
    .AxisY.MajorGrid.LineColor = Color.LightGray
    .AxisY.Minimum = 0
    .AxisY.Maximum = 24
    .AxisY.Interval = 6
    .BackColor = Color.FloralWhite 'AntiqueWhite 'LightSkyBlue
    .BackSecondaryColor = Color.White
    .BackGradientStyle = GradientStyle.HorizontalCenter
    .BorderColor = Color.Blue
    .BorderDashStyle = ChartDashStyle.Solid
    .BorderWidth = 1
    .ShadowOffset = 2
    End With
    Dim heading1 As String = " 1 - 12"
    Dim heading2 As String = "13 - 24"
    'draw the chart
    Chart1.Series.Clear()
    Chart1.Series.Add(heading1)
    Chart1.Series.Add(heading2)
    Chart1.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Line
    Chart1.Series(0).BorderWidth = 1
    Chart1.Series(0).Color = Color.Red
    Chart1.Series(0).BorderDashStyle = ChartDashStyle.Dash
    Chart1.Series(0).MarkerStyle = DataVisualization.Charting.MarkerStyle.Square
    Chart1.Series(0).MarkerSize = 4
    Chart1.Series(1).ChartType = DataVisualization.Charting.SeriesChartType.Line
    Chart1.Series(1).Color = Color.ForestGreen
    Chart1.Series(1).BorderWidth = 2
    For x = 1 To 24
    If x > 12 Then
    Chart1.Series(1).Points.AddXY(x, x)
    Else
    Chart1.Series(0).Points.AddXY(x, x)
    End If
    Next
    End Sub
    End Class

  • Setting Font Color [CS3][JS]

    Hello,
    I am looking for a way to set the color of a piece of text that I'm inserting on the page.  I have found information about how to use a swatch color to do it, but I can't find anything about setting the color based on CMYK values without having to create a swatch first.  Likely I just don't know what properties/methods I'm searching for.
    I'm using insertion points to control the location of my text in the frame.  My code looks like this:
    r = app.activeWindow.activeSpread.groups.item('Group-1').textFrames.item('Text1');
    ip = r.insertionPoints.item(0);
    ip.appliedFont = 'ARIAL';
    ip.fillTint = 70;
    ip.tracking = +100;
    //ip.colorSettings.colorSpace [CMYK] :: Process [C=100, M=0, Y=0, K=0]  -- Not sure if this should be one line or two, and no clue how to write it - obviously.
    //ip.fillColor = 'Blue';
    ip.contents = 'This is the text that should appear process cyan based on the CMYK settings.';
    So as you can see, right now I can use a swatch, but I need to loop this script over many files and I don't really want the swatch created in all those files.
    Any help is appreciated.
    Thanks,
    Dave

    You can't directly set the fill or stroke to an arbitrary color specification — it has to be a color, swatch,  a mixed ink, a tint, or a gradient. When you apply a color using the Colors panel, in the user interface, InDesign creates a color object, even though the color object does not appear in the Swatches panel. These colors appear as unnamed colors to scripting, but they're still color objects.
    To apply a color via InDesign scripting, you must use a color or swatch object.

  • How to set default color to e-mail

    I want to set a default color for all e-mail messages and although I have tried to set the color it doesn't seem to work ... second day with a mac, so speak slowly.
    Also want to set up a signature with the name in one color and address and contact info a different color. I went into mail>preferences>signatures and was able to change font on different lines of signature ... but when I tried to apply colors, it didn't work
    Thanks very much in advance for your assistance, halboye

    halboye wrote:
    I want to set a default color for all e-mail messages and although I have tried to set the color it doesn't seem to work ... second day with a mac, so speak slowly.
    that's not possible. you'll have to do it for every message individually.
    Also want to set up a signature with the name in one color and address and contact info a different color. I went into mail>preferences>signatures and was able to change font on different lines of signature ... but when I tried to apply colors, it didn't work
    that's possible. while editing a signature go to Format menu->show fonts. in the popup click on T with a green rectangle next to it. that's the button for font color. you'll get yet another popup for color. highlight some text in the signature and click on the color you want.
    Thanks very much in advance for your assistance, halboye

  • Setting row color in REUSE_ALV_GRID_DISPLAY_LVC

    Hi,
    I'm not sure if this function perhaps is not released or has bugs?  I didn't see any OSS notes.  I've read several sources on how to set the color for a given line and I'm not sure why I don't see it.  I see the values in my internal table in the ROWCOLOR column.
    We are on 4.6C and I wanted to use the LVC function to move toward the ECC versions of the structures ( LVCS_LAYO instead of SLIS_S_LAYOUT).  Perhaps this function module is not really supported???
    Could the ZEBRA parameter throw it off?
    Could it be a buffer issue?  I've tried it alternate ways and don't see a difference.
    Thanks for any suggestions,
    Ray
    Here is the code I'm using to set the layout and define the table.:
    gs_alv-callback_pf_status    = 'PF_STATUS_SET'.
      gs_alv-callback_user_command = 'USER_COMMAND'.
      gs_alv-callback_program      = sy-repid.
      gs_alv-structure_name        = 'ZHUS_ST_SP_REPORT'.
      gs_alv-itabname              = 'GT_DATA'.
      gs_alv-itabwaname            = 'GS_DATA'.
      gs_layo-zebra                = 'X'.
      gs_layo-cwidth_opt           = 'X'.
      gs_layo-box_fname            = 'SELECTED'.  " Checkbox
      gs_layo-info_fname           = 'ROWCOLOR'.
      gs_layo-sel_mode             = 'B'. "Default - multiple rows
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name             = gs_alv-structure_name
        CHANGING
          ct_fieldcat                  = gt_fcat.
    I set the color in my list table:
    ls_data-rowcolor = 'C600'.
          APPEND ls_data TO gt_data.
    This is how I call the grid:
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
        EXPORTING
          i_buffer_active                   = 'X'
          i_callback_program                = gs_alv-callback_program
          i_callback_pf_status_set          = gs_alv-callback_pf_status
          i_callback_user_command           = gs_alv-callback_user_command
          i_structure_name                  = gs_alv-structure_name
          i_grid_title                      = gs_alv-grid_title
          i_grid_settings                   = gs_glay
          is_layout_lvc                     = gs_layo
          it_fieldcat_lvc                   = gt_fcat
          it_excluding                      = gt_excluding
          i_default                         = gs_alv-default
          i_save                            = gs_alv-save
          is_variant                        = gs_disvariant
          it_events                         = gt_event
          it_event_exit                     = gt_event_exit
          is_print_lvc                      = gs_prnt
        TABLES
          t_outtab                          = <gfs_t>
    Edited by: Raymond Mannion on Jun 30, 2009 8:09 PM
    Edited by: Raymond Mannion on Jun 30, 2009 8:10 PM

    THis should help you:
    Re: 'Reuse_alv_grid_display' : making a specific row bold
    [ALV] Text in color and bold

  • Rendering alternate colors in JTree

    I have a JTree within a scrollpane.
    What I would like to do is have every alternate line on the JTree rendered with one of 2 colors, i.e. line 1 is blue, line 2 is yellow, line 3 is blue etc.
    The tricky bit is that I want this color to fill the width of the scrollpane - changing the background of the JLabel color in the renderer will only update from the tree node to the right of the scrollpane (it leaves the area to the left of the node blank).
    Am I making any sense?

    Try this
    regards
    Stas
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.tree.*;
    public class Test {
    JScrollPane scroll;
    JTree tree;
    public Test() throws Exception {
    JFrame frame=new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    DefaultMutableTreeNode root=new DefaultMutableTreeNode("root");
    DefaultMutableTreeNode node1=new DefaultMutableTreeNode("node1");
    DefaultMutableTreeNode node2=new DefaultMutableTreeNode("node2");
    root.add(node1);
    root.add(node2);
    DefaultMutableTreeNode subnode2=new DefaultMutableTreeNode("node2_1");
    node2.add(subnode2);
    subnode2=new DefaultMutableTreeNode("node2_2");
    node2.add(subnode2);
    subnode2=new DefaultMutableTreeNode("node2_3");
    node2.add(subnode2);
    tree=new JTree(root);
    tree.setCellRenderer(new MyRenderer());
    frame.getContentPane().add(tree);
    frame.setBounds(100,100,200,200);
    frame.show();
    public static void main(String[] args) throws Exception {
    new Test();
    class MyRenderer extends DefaultTreeCellRenderer {
    public MyRenderer() {
    super();
    setOpaque(true);
    public Component getTreeCellRendererComponent(JTree tree, Object value,
    boolean sel,
    boolean expanded,
    boolean leaf, int row,
    boolean hasFocus) {
    JLabel l=(JLabel)super.getTreeCellRendererComponent(tree, value,
    sel,
    expanded,
    leaf, row,
    hasFocus);
    l.setPreferredSize(new Dimension(5000,20));
    if (row % 2==0) {
    l.setBackground(Color.CYAN);
    else {
    l.setBackground(Color.YELLOW);
    return l;

Maybe you are looking for

  • How to include security settings into InDesign PDF presets?

    I have prepared an InDesign template for multiple users in my team. Ihave created a set of PDF presets for exporting PDFs to keepconsistency. I want to protect all the PDF files with password and haveto include the password protection in the PDF pres

  • QuickTime Will Not Install - Key Error

    I'm using a validated Microsoft Windows XP Home Edition. I can't get QuickTime to install. I had it installed previously, but I deleted it. I tried to install it again and again, but I still keep getting this exact same error: http://img295.imageshac

  • HT4623 why cant i continue my phone usage after updating without a sim card

    why cant i continue using my iphone 4 after an update with out having a sim card

  • ODBC Connectivity Issue

    We connect fine to another Oracle database via DSN. However, when attempting to connect to a different database using a Driver={} and a dbq="" reference to specify the service name (which matches in tnsnames.ora), the ODBC Dialog Box appears and chal

  • DV6000 will not keep starting - shuts down after 3 seconds

    Greets, When pressing the Power On (PO) button, the comp starts, then shuts down immediately (within 3 seconds). Things to note: The fan and drive start - from start to shut down is about 3 seconds. The fan does spin. The power adapter has been plugg