[SIZE=1]/*
* frmFLOWer.java
*
* Created on April 25, 2006, 11:56 AM
*/
package flowerschermpositionering;
import java.io.*;
import javax.swing.JFileChooser;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.tree.*;
/**
*
* @author marco
*/
public class frmFLOWer extends javax.swing.JFrame {
/** Creates new form frmFLOWer */
File chpFile;
public DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
public frmFLOWer() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
BestandsKiezer = new javax.swing.JFileChooser();
jRadioButton1 = new javax.swing.JRadioButton();
lblX = new javax.swing.JLabel();
txtX = new javax.swing.JTextField();
lblY = new javax.swing.JLabel();
txtY = new javax.swing.JTextField();
txtCompleteXY = new javax.swing.JTextField();
lblIsXY = new javax.swing.JLabel();
lblB = new javax.swing.JLabel();
lblH = new javax.swing.JLabel();
txtB = new javax.swing.JTextField();
lblIsBH = new javax.swing.JLabel();
txtCompleteBH = new javax.swing.JTextField();
txtH = new javax.swing.JTextField();
cmdOpenBestand = new javax.swing.JButton();
flowerPane = new javax.swing.JSplitPane();
jScrollPane2 = new javax.swing.JScrollPane();
treeProces = treeProces = new JTree(root);
jScrollPane1 = new javax.swing.JScrollPane();
chpTekst = new javax.swing.JTextPane();
BestandsKiezer.setDialogTitle("Kies je chp bestand");
jRadioButton1.setText("jRadioButton1");
jRadioButton1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jRadioButton1.setMargin(new java.awt.Insets(0, 0, 0, 0));
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setForeground(java.awt.Color.white);
addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentMoved(java.awt.event.ComponentEvent evt) {
formComponentMoved(evt);
}
public void componentResized(java.awt.event.ComponentEvent evt) {
formComponentResized(evt);
}
});
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowActivated(java.awt.event.WindowEvent evt) {
formWindowActivated(evt);
}
});
lblX.setText("x:");
lblX.setName("lblX");
txtX.setName("txtX");
txtX.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtXActionPerformed(evt);
}
});
lblY.setText("y:");
lblY.setName("lblY");
txtY.setName("txtY");
txtCompleteXY.setName("txtCompleteXY");
lblIsXY.setText("=");
lblIsXY.setName("lblIS");
lblB.setText("b:");
lblB.setName("lblX");
lblH.setText("h:");
lblH.setName("lblY");
txtB.setName("txtX");
lblIsBH.setText("=");
lblIsBH.setName("lblIS");
txtCompleteBH.setName("txtCompleteBH");
txtH.setName("txtX");
cmdOpenBestand.setText("Open bestand");
cmdOpenBestand.setToolTipText("Open chp bestand");
cmdOpenBestand.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
cmdOpenBestandMouseClicked(evt);
}
});
jScrollPane2.setViewportView(treeProces);
flowerPane.setLeftComponent(jScrollPane2);
jScrollPane1.setViewportView(chpTekst);
flowerPane.setRightComponent(jScrollPane1);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(flowerPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 491, Short.MAX_VALUE)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(lblX)
.add(lblY)
.add(lblB)
.add(lblH))
.add(12, 12, 12)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(txtY, 0, 0, Short.MAX_VALUE)
.add(txtX, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 46, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(txtH, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 46, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(txtB, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 46, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(18, 18, 18)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(layout.createSequentialGroup()
.add(lblIsBH)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(txtCompleteBH, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 83, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(layout.createSequentialGroup()
.add(lblIsXY)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(txtCompleteXY)))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 197, Short.MAX_VALUE)
.add(cmdOpenBestand)
.addContainerGap())))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(31, 31, 31)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(lblX)
.add(txtX, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(lblY)
.add(txtY, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.add(layout.createSequentialGroup()
.add(13, 13, 13)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(lblIsXY)
.add(txtCompleteXY, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(26, 26, 26)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(lblB)
.add(txtB, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(lblH)
.add(txtH, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(cmdOpenBestand)))
.add(layout.createSequentialGroup()
.add(39, 39, 39)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(lblIsBH)
.add(txtCompleteBH, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
.add(7, 7, 7)
.add(flowerPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 224, Short.MAX_VALUE)
.addContainerGap())
);
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setBounds((screenSize.width-509)/2, (screenSize.height-421)/2, 509, 421);
}// </editor-fold>
private void formWindowActivated(java.awt.event.WindowEvent evt) {
// TODO add your handling code here:
}
private void cmdOpenBestandMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
JFileChooser jf = new JFileChooser();
//jf.addChoosableFileFilter(new chpFilter());
jf.showOpenDialog(this);
chpFile = jf.getSelectedFile();
String c;
try
{
chpTekst.setText("");
BufferedReader input = new BufferedReader(new InputStreamReader(new FileInputStream(chpFile), "UTF8"));
do
{
chpTekst.setText(chpTekst.getText() + input.readLine() + '\n');
//chpTekst.setText(chpTekst.getText() + input.readLine() + '\n');
} while((c = input.readLine()) != null);
}
catch(java.io.FileNotFoundException jiFNF)
{
jiFNF.getStackTrace();
}
catch(java.io.IOException jiIOE)
{
jiIOE.getStackTrace();
}
}
private void formComponentMoved(java.awt.event.ComponentEvent evt) {
// TODO add your handling code here:
txtX.setText(new Integer(this.getLocation().x + 4).toString());
txtY.setText(new Integer(this.getLocation().y + 4).toString());
createXYComplete(this.getLocation().x + 4, this.getLocation().y + 4);
}
private void formComponentResized(java.awt.event.ComponentEvent evt) {
// TODO add your handling code here:
txtB.setText(new Integer(this.getWidth() - 8).toString());
txtH.setText(new Integer(this.getHeight()- 8).toString());
createBHComplete(this.getWidth() - 8, this.getHeight() - 8);
}
private void txtXActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new frmFLOWer().setVisible(true);
}
});
}
private void createXYComplete(int x, int y)
{
String strX = "", strY = "";
if(x<10)
strX = "[ " + new Integer(x).toString();
if(y<10)
strY = " " + new Integer(y).toString() + "]";
if((x>10)&&(x<100))
strX = "[ " + new Integer(x).toString();
if((y>10)&&(y<100))
strY = " " + new Integer(y).toString() + "]";
if(x>100)
strX = "[" + new Integer(x).toString();
if(y>100)
strY = new Integer(y).toString() + "]";
txtCompleteXY.setText(strX + ":" + strY);
}
private void createBHComplete(int x, int y)
{
// let op x en y zijn hier eigenlijk b en h
String strX = "", strY = "";
if(x<10)
strX = "[ " + new Integer(x).toString();
if(y<10)
strY = " " + new Integer(y).toString() + "]";
if((x>10)&&(x<100))
strX = "[ " + new Integer(x).toString();
if((y>10)&&(y<100))
strY = " " + new Integer(y).toString() + "]";
if(x>100)
strX = "[" + new Integer(x).toString();
if(y>100)
strY = new Integer(y).toString() + "]";
txtCompleteBH.setText(strX + ":" + strY);
}
// Variables declaration - do not modify
private javax.swing.JFileChooser BestandsKiezer;
private javax.swing.JTextPane chpTekst;
private javax.swing.JButton cmdOpenBestand;
private javax.swing.JSplitPane flowerPane;
private javax.swing.JRadioButton jRadioButton1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JLabel lblB;
private javax.swing.JLabel lblH;
private javax.swing.JLabel lblIsBH;
private javax.swing.JLabel lblIsXY;
private javax.swing.JLabel lblX;
private javax.swing.JLabel lblY;
private javax.swing.JTree treeProces;
private javax.swing.JTextField txtB;
private javax.swing.JTextField txtCompleteBH;
private javax.swing.JTextField txtCompleteXY;
private javax.swing.JTextField txtH;
private javax.swing.JTextField txtX;
private javax.swing.JTextField txtY;
// End of variables declaration
}
[/SIZE]