1

I need to put this line chart in the same as my JFrame instead of having JFrame and line chart open at the same time

setLayout(new BorderLayout());

setSize(600, 100);
setBounds(600, 450, 800, 200);
//(950, 300, 500, 500);
setTitle("Main Menu");

//data set for graph
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.setValue(8, "", "");
dataset.setValue(6, "", "");
JFreeChart chart = ChartFactory.createLineChart("Chart Name", "X axis name", "Y axis name", dataset);
setTitle("Main Menu"); 
ChartFrame frame =  new ChartFrame("Window name", chart);
frame.setVisible(true);
frame.setBounds(400, 300, 500, 500);

setResizable(false);
setVisible(true);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
Sean
  • 21
  • 1
  • Please re-phrase your question as it's confusing, and tell more of the critical details. – Hovercraft Full Of Eels Nov 14 '16 at 22:41
  • okay so basically when i run this code, it would open an empty JFrame (this is because I havent coded it yet) and will also a line chart both at the same time. I want the line chart open inside the JFrame so only the JFrame will open with the line chart inside it. hope this makes sense – Sean Nov 14 '16 at 22:58
  • 1
    Just put the chart into the JFrame -- it's a Swing component, so add it to the JFrame or to a component (e.g., JPanel) that is held by the JFrame. – Hovercraft Full Of Eels Nov 14 '16 at 22:59

0 Answers0