I have parent panel and child panel. child parent exists on parent panel. Both are Jpanels of different size. Now i want to show a ChartPanel on the child panel. I have tried various ways of displaying it but unsucessfull. Please suggest some way of adding chartpanel to Jpanel.
sorry i couldnt paste the code. I have also tried various ways suggested in stackoverflow Q&A, but in vain.
因为ChartPanel
确定了首选大小,而BoxLayout
依赖于首选大小,所以让newPanel
使用所需的方向扩展Box
add()
child
和chartPanel
都add()
到newPanel
。
I think your problem has nothing to do with JFreeChart. Probably the code below helps you to start:
JFrame frame = new JFrame();
JPanel parentPanel = new JPanel();
parentPanel.setBorder(BorderFactory.createTitledBorder("parent panel"));
JPanel childPanel = new JPanel();
childPanel.setBorder(BorderFactory.createTitledBorder("child panel"));
// Add a button to the child panel
childPanel.add(new JButton("button"));
// In the instruction below you have to create and add your ChartPanel
childPanel.add(yourChartPanel);
parentPanel.add(childPanel);
frame.add(parentPanel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.