Today we finally solved the problem of showing Jfreechart on WINDOW8, the requirement is to use Jfreechart in SWT, but jfreechart to use the AWT style, you cannot use the SWT style (Chartcomposite), that is to use Swt_ AWT bridging to implement the display Jfreechart in SWT.
Bridging the way the implementation of the Jfreechart on the Win7 is not a problem, can be directly displayed, but on window 8 for the first time to load a long time, and does not show Jfreechart. The same is true with code improvements to the SWT_AWT test using the Jfreechart SWT example, the code in the Main method is as follows:
Fianel Jfreechart chart = Chartfactory.createtimeserieschart (
"Legal & General Unit Trust Prices",//title
"Date",//X-axis label
"Price Per Unit",//Y-axis label
DataSet,//Data
True,//create legend?
True,//generate ToolTips?
False//Generate URLs?
);
Final Display display = new display ();
Shell shell = new shell (display);
Shell.setsize (600, 300);
Shell.setlayout (New Filllayout ());
Shell.settext ("Time series demo for Jfreechart running with SWT");
Composite comp = new Composite (Shell, SWT. EMBEDDED);//swt. Embedded must
Java.awt.Frame Frame = swt_awt.new_frame (comp);
Chartpanel Chartpanel = new Chartpanel (chart);
Frame.add (Chartpanel);
Shell.open ()
while (!shell.isdisposed ()) {
if (!display.readanddispatch ())
Display.sleep ();
}
This write Window8 first Open will be very card, specific reasons do not know, then click on the interface Jfreechart will appear. It took one weeks to look at the problem and think about the following methods:
1, through to Comp plus ctrolevent event monitoring, and then simulated AWT Mosueevent sent to Chartpanel, to achieve analog click, found not every time effective.
2, first open the SWT window, after the window opened to add Chartpanel to the frame, in the middle of the frame and Chartpanel plus a JPanel, the method can be displayed when open, the window maximized, if JPanel did not add layout is not a problem, Adding a layout causes Chartpanel to refresh during the maximized process, and the Jfreechart does not appear.
Finally did not recruit the good method, looked down to say the load jfreechart sometimes really will be very card, the Chartpanel userbuffered mark set to False, can quickly point. I didn't think it was really useful to try. Modify the code as follows:
Chartpanel Chartpanel = new Chartpanel (chart,false);
This question to see three days did not solve, today do not want to solve, casually read the article on the Internet, try to solve the next, hey, think of that sentence "did not learn a little knowledge, less write a line of code." Spent so much time, and finally just a false question, it is funny, the joy of life lies in one after another surprise, you never know what will happen next second, if you know what the meaning of it.
SWT_AWT loading Jfreechart does not show jfreechart problem under Window8