1

When i used Sea-glass look and feel with JFreechart, the chart appreared normally but Sea-Glass didn't change the look and feel at all, although when sea-glass was used without Jfreechart, it worked.

So, what could be the reason?

public static void main(String[] args) throws Exception{

        EventQueue.invokeLater(new Runnable() {
            public void run() { 
try {
    UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel");
    JFreeChart chart = chart_producer(url) //my own static method to make the chart//
    JFrame frame = new JFrame();
    JPanel panel = new JPanel();
    ChartPanel chartPanel = new ChartPanel(chart);
    //chartPanel.setPopupMenu(null);
    //chartPanel.setMouseZoomable(false);
    panel.add(chartPanel);
    frame.add(panel);
    frame.pack();
    frame.setVisible(true);
} catch (ClassNotFoundException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
} catch (InstantiationException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
} catch (IllegalAccessException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
} catch (UnsupportedLookAndFeelException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
} catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
};
        }
        );
    }
TU_HEO DAKAI
  • 2,197
  • 8
  • 28
  • 39

1 Answers1

2

Note that JFreeChart is not a JComponent. It does not have a UI delegate to change. Alternatively, applying a ChartTheme may be effective.

Addendum: Although a chart is not a component, it may be added to a ChartPanel as part of an arbitrary L&F/layout, as shown here, here and here.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • Sea-Glass doesn't work in the way that the new Jframe(with sea-glass) looks exactly the one without Sea-Glass. – TU_HEO DAKAI Mar 30 '12 at 15:06
  • @TU_HEO DAKAI you can apply Look and Feel only to the [JComponents](http://docs.oracle.com/javase/tutorial/uiswing/components/index.html), `JFreeChart` is not part of a `JComponents` – mKorbel Mar 30 '12 at 15:18
  • @mKorbel : how about the JFrame (that contains the JFreeChart)? In my case, Sea-Glass doen't make any change to JFrame : the min, max, close buttons... – TU_HEO DAKAI Mar 30 '12 at 15:24
  • 1
    @TU_HEO DAKAI It wrong, very wrong way to create a new JFrame, use JDialog, JWindow for popup window only, otherwise look at [CardLayout](http://docs.oracle.com/javase/tutorial/uiswing/layout/card.html), for changing L&F on the runtime you have look at [SwingUtilities.updateComponentTreeUI(frame);](http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html#dynamic) – mKorbel Mar 30 '12 at 15:29
  • @mKorbel: is correct; more above. Frame decorations belong to the host platform. – trashgod Mar 30 '12 at 17:16