Font font;\r
int fontSize = 12;\r
\r
+ boolean fitToWindow = true;\r
boolean showDistances = false;\r
boolean showBootstrap = false;\r
\r
repaint();\r
\r
\r
- if( scrollPane.getHeight() > fm.getHeight() * nameHash.size()+offy)\r
+ if( fitToWindow || (!fitToWindow && scrollPane.getHeight() > fm.getHeight() * nameHash.size()+offy ) )\r
{\r
draw(g,scrollPane.getWidth(),scrollPane.getHeight());\r
- setPreferredSize(new Dimension(scrollPane.getWidth(), scrollPane.getHeight()));\r
+ setPreferredSize(null);\r
}\r
else\r
{\r
- setPreferredSize(new Dimension(getWidth(), fm.getHeight() * nameHash.size()));\r
- draw( g,getWidth(), fm.getHeight() * nameHash.size());\r
+ setPreferredSize(new Dimension(scrollPane.getWidth(), fm.getHeight() * nameHash.size()));\r
+ draw( g,scrollPane.getWidth(), fm.getHeight() * nameHash.size());\r
}\r
\r
\r
treeCanvas.startPrinting();\r
}\r
\r
+ protected void fitToWindow_actionPerformed(ActionEvent e)\r
+ {\r
+ treeCanvas.fitToWindow = fitToWindow.isSelected();\r
+ repaint();\r
+ }\r
+\r
+\r
protected void fontSize_actionPerformed(ActionEvent e)\r
{\r
if( treeCanvas==null )\r
protected JMenuItem fontSize = new JMenuItem();
protected JCheckBoxMenuItem bootstrapMenu = new JCheckBoxMenuItem();
protected JCheckBoxMenuItem distanceMenu = new JCheckBoxMenuItem();
+ protected JCheckBoxMenuItem fitToWindow = new JCheckBoxMenuItem();
public GTreePanel()
{
this.getContentPane().setLayout(borderLayout1);
this.setBackground(Color.white);
this.setFont(new java.awt.Font("Verdana", 0, 12));
- this.setMinimumSize(new Dimension(530, 60));
scrollPane.setOpaque(false);
jMenu1.setText("File");
saveMenu.setEnabled(false);
distanceMenu_actionPerformed(e);
}
});
+ fitToWindow.setSelected(true);
+ fitToWindow.setText("Fit to window");
+ fitToWindow.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ fitToWindow_actionPerformed(e);
+ }
+ });
this.getContentPane().add(scrollPane, BorderLayout.CENTER);
jMenuBar1.add(jMenu1);
jMenuBar1.add(jMenu2);
jMenu1.add(saveMenu);
jMenu1.add(printMenu);
+ jMenu2.add(fitToWindow);
jMenu2.add(fontSize);
jMenu2.add(distanceMenu);
jMenu2.add(bootstrapMenu);
}
+ protected void fitToWindow_actionPerformed(ActionEvent e)
+ {
+
+ }
+