SWT_AWT loading Jfreechart does not show jfreechart problem under Window8

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.