I have a class called Graph and all drawing functionality and resize/redrawing behavior is encapsulated in this class. So, I have created a graph by using 2D graphics on JPanel (instance of JInternal Frame)and want the graph to be resizable when the user dragging the corners of the window.
Any idea?
-----------------------
public class HW2 extends JApplet {
private JDesktopPane theDesktopPane;
Dimension component_dimen = new Dimension(100, 100);
public void init() {
setBackground(Color.gray);
theDesktopPane = new JDesktopPane();
getContentPane().add(theDesktopPane);
JInternalFrame frame = new JInternalFrame("Home Work2", true, true, true, true);
Container container = frame.getContentPane();
//---------------------
Graph topPanel = new Graph((new Dimension (400, 400)), // size
0, // minX
0, // minY
200.0, // maxX
1.0, // maxY
"Sin and Cos", // title
"X", // x label
"Y", // y label
20.0, // tick X
0.1, // tick Y
// "##0", // format axis X
//"##0.00" ); // format axis Y
new DecimalFormat( "##0" ),
new DecimalFormat( "##0.00"
);
container.add(topPanel, BorderLayout.CENTER);
//this.validate();
frame.setMinimumSize(component_dimen);
//frame.resi
frame.pack();
theDesktopPane.add(frame);
frame.setVisible(true);
setSize(400, 400);
setVisible(true);
}
------------------------------
Any idea?
-----------------------
public class HW2 extends JApplet {
private JDesktopPane theDesktopPane;
Dimension component_dimen = new Dimension(100, 100);
public void init() {
setBackground(Color.gray);
theDesktopPane = new JDesktopPane();
getContentPane().add(theDesktopPane);
JInternalFrame frame = new JInternalFrame("Home Work2", true, true, true, true);
Container container = frame.getContentPane();
//---------------------
Graph topPanel = new Graph((new Dimension (400, 400)), // size
0, // minX
0, // minY
200.0, // maxX
1.0, // maxY
"Sin and Cos", // title
"X", // x label
"Y", // y label
20.0, // tick X
0.1, // tick Y
// "##0", // format axis X
//"##0.00" ); // format axis Y
new DecimalFormat( "##0" ),
new DecimalFormat( "##0.00"
container.add(topPanel, BorderLayout.CENTER);
//this.validate();
frame.setMinimumSize(component_dimen);
//frame.resi
frame.pack();
theDesktopPane.add(frame);
frame.setVisible(true);
setSize(400, 400);
setVisible(true);
}
------------------------------