开发者

laying out a jpanel with multiple custom components using swing

I'm trying to set up a JPanel using a BorderLayout in such a way to create a chart. For this, I have an axis component in the west & south regions and the chart itself in the center region. The problem is.. when I add my 'graph' component (basic class extending Component) and draw things onto it, this overlaps with the other axis areas.

I'm wondering how I can set things up in such a wa开发者_Go百科y that the reference for 0,0 from each component refers to it's particular starting point and not have all of them reference the same point (as is happening now).

Hope this explanation isn't too difficult to understand. Thanks in advance.


If your graph really extends Component, note that you generally can't mix AWT and Swing components that way. Try extending JComponent instead.

Alternatively, consider JFreeChart

Addendum: Even with a JComponent in the CENTER of a BorderLayout, WEST and SOUTH generally won't meet at a point, as seen in the API diagram.

Can you amplify on why JFreeChart isn't sufficient? It's never let me down, but you might also look at this simulation's Histogram class for another approach.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜