Now i need to add the Existing Application(someDemo.java) when the button clicked.i have achieved that but i need to add a Button at the end of the frame(or Jdialog what ever it is).
here is My Source Code:
_____________________
public class Test extends JDialog {
XYDataset data,data2;
public Test(String title) {
// super(title);
XYSeries series = new XYSeries("Test Data");
series.add(1, 1.0);
series.add(2, 1.1);
series.add(3, 1.3);
series.add(4, 1.5);
series.add(5, 1.7);
series.add(6, 1.

series.add(7, 1.9);
series.add(8, 2.0);
series.add(9, 2.1);
series.add(10,2.2);
series.add(11,2.3);
series.add(12,2.4);
series.add(12.1, 5.0);
series.add(12.3, 5.1);
series.add(12.5, 5.3);
series.add(13.4, 5.5);
series.add(13.8, 5.7);
series.add(14.1, 5.

series.add(14.7, 5.9);
series.add(15, 6.0);
series.add(15.9, 6.1);
series.add(16,6.2);
series.add(18,6.3);
series.add(20,6.4);
data = new XYSeriesCollection(series);
double [][] my2d=
{
{1,1.0},{2,1.1},{3,1.3},{4,1.5},{5,1.7},{6,1.8},{7,1.9},{8,2.0},{9,2.1},{10,2.2},{11,2.3},{12,2.4},
{12.1,5.0},{12.3,5.1},{12.5,5.3},{13.4,5.5},{13.8,5.7},{14.1,5.8},{14.7,5.9},{15,6.0},{15.9,6.1},{16,6.2},{18,6.3},{20,6.4}
};
JFreeChart chart = createOverlaidChart();
chart.getPlot().setBackgroundPaint(Color.yellow);
ChartPanel panel = new ChartPanel(chart, true, true, true, true, true);
panel.setPreferredSize(new java.awt.Dimension(270, 270));
JButton close=new JButton("Close");
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(close,BorderLayout.SOUTH);
double[] result=Regression.getOLSRegression(data,0);
// Regression.getOLSRegression(this.data1, 0);
LineFunction2D myf=new LineFunction2D(result[0],result[1]);
data2 =DatasetUtilities.sampleFunction2D(myf,1,20,100,"regression");
}
private JFreeChart createOverlaidChart() {
// create subplot 1...
XYDataset data1 =data;
XYDotRenderer renderer1 = new XYDotRenderer();
XYPlot subplot1 = new XYPlot(data1, null, null, renderer1);
// create subplot 2...
XYItemRenderer renderer2 = new StandardXYItemRenderer();
XYPlot subplot2 = new XYPlot(data2, null, null, renderer2);
subplot2.setSeriesPaint(0, Color.green);
// make an overlaid plot and add the subplots...
ValueAxis domainAxis = new HorizontalDateAxis("X");
ValueAxis rangeAxis = new VerticalNumberAxis("Y");
OverlaidXYPlot plot = new OverlaidXYPlot(domainAxis, rangeAxis);
plot.add(subplot1);
plot.add(subplot2);
// return a new chart containing the overlaid plot...
return new JFreeChart("Linear Regression Example", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
}
}
-------------------------------------------------------------------
i have removed main() from this and i am calling this clas from some other class, when ever (some)Button is clicked.
That code is:
-------------------------------------------------------------------------
public void actionPerformed(ActionEvent ae)
{
Test demo = new Test("Liner Regression Demo");
demo.setModal(true);
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
demo.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
demo.setFocusable(true);
}
----------------------------------------------------------------------------------------
how do i add a close Button to the frame at the appropriate Place.
when i run the above code, Button is is coming over the Test Data Box.
i.e I Guess, in the Demo applications the Graph is occupying the entire Frame.
how do i add a Button after Graph(.e Test Dtaa Label)..so that upon clicking this Close button ,user will comeout of the Frame(JDialog).
Hope i am clear in Expressing my Problem, if Not Please let me Know so that i can be more clear...
Thanks,
Kishore.