小弟 目前在一个公司实习,接手了一个RCP开发的做了一半的项目(原来的开发人员有事走了郁闷阿)其中一个模块是在DIALOG中显示曲线图在弄这个的时候遇到了个问题还请大侠帮忙问题:我把图加在dialog中后在菜单里面调不出来这个对话框,但是把JFreeChart的东西去掉后就能。在DIalog里面加上main 直接显示这个Dialog也可以小弟 刚开始搞这个 学艺不精 大学的基础也不好 还望各位不吝赐教
谢谢大家代码 ACTIONCopy code
public class CurveShowAction extends Action {
private IWorkbenchWindow window;
public CurveShowAction(IWorkbenchWindow window){
this.window = window;
this.setText("曲线显示");
}
public void run(){
System.out.println("here");
curveShowDialog = new CurveShowDialog(window.getShell());
System.out.println("here1");
curveShowDialog.open();
}
}here可以打印 here1不能打印
我觉得问题就在这句curveShowDialog = new CurveShowDialog(window.getShell());
但是不知道应该怎么改dialog 对话框基本都是用插件画的 open方法Copy code
public Object open() { createContents();
shell.open();
shell.layout();
Display display = getParent().getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
return result;
}chartCopy code
JFreeChart chart = createChart(createDataset());
final ChartComposite frame = new ChartComposite(composite_1, SWT.NONE, chart,false);
final FormData fd_frame = new FormData();
fd_frame.top = new FormAttachment(0, 46);
frame.setLayoutData(fd_frame);
createChartCopy code
private static JFreeChart createChart(XYDataset xydataset) {
JFreeChart jfreechart = ChartFactory.createXYLineChart("曲线图", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false);
return jfreechart;
}
private static XYDataset createDataset() {
XYSeries xyseries = new XYSeries("曲线");
xyseries.add(5,5);
xyseries.add(10,10);//数据是假的测试用
return new XYSeriesCollection(xyseries);
}
public static void main(String args[]){
Display display = new Display();
Shell shell = new Shell(display);
CurveShowDialog curveShowDialog = new CurveShowDialog(shell,SWT.NONE);
curveShowDialog.open();
}有趣的是我把和构建chart有关的代码注释掉还留下createChart 和 createDataset这两个方法的时候也不行,小弟现在就是便学边做的确是很迷茫 谢谢大家了
代码实在太长了 全贴出来没法看 不知道这些可以不 再次感谢大家
谢谢大家代码 ACTIONCopy code
public class CurveShowAction extends Action {
private IWorkbenchWindow window;
public CurveShowAction(IWorkbenchWindow window){
this.window = window;
this.setText("曲线显示");
}
public void run(){
System.out.println("here");
curveShowDialog = new CurveShowDialog(window.getShell());
System.out.println("here1");
curveShowDialog.open();
}
}here可以打印 here1不能打印
我觉得问题就在这句curveShowDialog = new CurveShowDialog(window.getShell());
但是不知道应该怎么改dialog 对话框基本都是用插件画的 open方法Copy code
public Object open() { createContents();
shell.open();
shell.layout();
Display display = getParent().getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
return result;
}chartCopy code
JFreeChart chart = createChart(createDataset());
final ChartComposite frame = new ChartComposite(composite_1, SWT.NONE, chart,false);
final FormData fd_frame = new FormData();
fd_frame.top = new FormAttachment(0, 46);
frame.setLayoutData(fd_frame);
createChartCopy code
private static JFreeChart createChart(XYDataset xydataset) {
JFreeChart jfreechart = ChartFactory.createXYLineChart("曲线图", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false);
return jfreechart;
}
private static XYDataset createDataset() {
XYSeries xyseries = new XYSeries("曲线");
xyseries.add(5,5);
xyseries.add(10,10);//数据是假的测试用
return new XYSeriesCollection(xyseries);
}
public static void main(String args[]){
Display display = new Display();
Shell shell = new Shell(display);
CurveShowDialog curveShowDialog = new CurveShowDialog(shell,SWT.NONE);
curveShowDialog.open();
}有趣的是我把和构建chart有关的代码注释掉还留下createChart 和 createDataset这两个方法的时候也不行,小弟现在就是便学边做的确是很迷茫 谢谢大家了
代码实在太长了 全贴出来没法看 不知道这些可以不 再次感谢大家
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货