package ls.graph.ui;
import java.awt.BorderLayout;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.border.Border;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.TabSet;
import javax.swing.text.TabStop;
public class ScriptPanel extends JPanel
{
private static final long serialVersionUID = 1L;
// private MainWindow window = null;
ScriptPanel(MainWindow w)
{
super();
// this.window = w;
initComponents();
}
private JTextPane txtScript = null;
private void initComponents()
{
this.setLayout(new BorderLayout());
txtScript = new JTextPane();
txtScript.setEditable(true);
txtScript.setEnabled(true);
txtScript.setAlignmentY(0.0f);
//txtScript.setFont(new Font("Arial",Font.PLAIN,11));
Style style = txtScript.addStyle("Script", null);
float tabLength = 7.0f;
style.addAttribute(
StyleConstants.FontConstants.TabSet,
new TabSet(new TabStop[]
{new TabStop(tabLength),
new TabStop(tabLength*2),
new TabStop(tabLength*3),
new TabStop(tabLength*4),
new TabStop(tabLength*5),
new TabStop(tabLength*6)}));
style.addAttribute(StyleConstants.FontConstants.FontFamily, "Courier New");
txtScript.setLogicalStyle(style);
JScrollPane scrollPanel = new JScrollPane(txtScript);
this.add(scrollPanel,BorderLayout.CENTER);
Border scriptPaneBorder = BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),"Algorithm Code");
this.setBorder(scriptPaneBorder);
}
void setScriptText(String st)
{
if (st != null)
txtScript.setText(st);
}
String getScriptText()
{
return txtScript.getText();
}
}