import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;
import java.util.Vector;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.WindowConstants;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.filechooser.FileFilter;
/**
@author Netarrow
*/
public static String lookandfeel
;
public static boolean isFirst;
static {
try {
p.load(fis);
pathsdk = p.getProperty("pathsdk");
lookandfeel = p.getProperty("lookandfeel");
isFirst = true;
p.put("pathsdk", "");
p.put("lookandfeel", "");
e.printStackTrace();
e.printStackTrace();
e.printStackTrace();
e.printStackTrace();
e.printStackTrace();
}
}
public static void main
(String[] args
) {
JavArrow inst = new JavArrow();
inst.setVisible(true);
inst.
setDefaultCloseOperation(JFrame.
DO_NOTHING_ON_CLOSE);
}
p.setProperty("pathsdk", path);
p.setProperty("lookandfeel", ((LookAndFeelInfo)JavArrow.uim.get(laf)).getClassName());
p.store(fos, "JavArrow");
}
public JavArrow() {
super();
initGUI();
centerFrame();
LookAndFeelInfo
[] uim
= UIManager.
getInstalledLookAndFeels();
for(int i = 0; i < uim.length; i++) {
JavArrow.uim.add(uim[i]);
}
if(isFirst) {
new SetOptions(this, uim, true);
}
}
private void initGUI() {
try {
doc.onExit();
}
});
this.setTitle("JavArrow MicroEdition - by Netarrow");
this.getContentPane().setLayout(thisLayout);
this.setSize(511, 419);
{
jPanel1.setLayout(jPanel1Layout);
{
{
{
jmb3.add(options);
options.setText("Extras");
{
options.add(about);
about.setText("About");
JOptionPane.
showMessageDialog(null,
"JavArrow MicroEdition by Netarrow 2004",
"About",
JOptionPane.
INFORMATION_MESSAGE);
}
});
}
{
options.add(op);
op.setText("Options");
onOption();
}
});
}
}
jmb2.add(project);
project.setText("Project");
{
project.add(compile);
compile.setText("Compile");
try {
doc.compile(pathsdk, console);
e.printStackTrace();
}
doc.compilato = true;
}
});
}
{
project.add(run);
run.setText("Run");
try {
doc.runn(pathsdk, console);
e.printStackTrace();
}
}
});
}
}
jmb.add(file);
file.setLayout(fileLayout);
file.setText("File");
{
file.add(apri);
apri.setText("Open");
apri.addActionListener(this);
}
{
file.add(nuovo);
nuovo.setText("New");
nuovo.addActionListener(this);
}
{
file.add(salva);
salva.setText("Save");
salva.addActionListener(this);
}
{
file.add(saveAs);
saveAs.setText("Save As");
saveAs.addActionListener(this);
}
{
file.add(esci);
esci.setText("Exit");
esci.addActionListener(this);
}
}
}
{
jPanel2.setLayout(jPanel2Layout);
{
{
jScrollPane1.setViewportView(console);
console.
setPreferredSize(new java.
awt.
Dimension(469, 116
));
console.setEditable(false);
}
}
{
{
sourcecontent.setViewportView(source);
source.
setPreferredSize(new java.
awt.
Dimension(443, 271
));
doc.edit = true;
}
});
}
}
}
e.printStackTrace();
}
}
return source.getText();
}
private void onOption() {
LookAndFeelInfo
[] uim
= UIManager.
getInstalledLookAndFeels();
for(int i = 0; i < uim.length; i++) {
JavArrow.uim.add(uim[i]);
}
new SetOptions(this, uim, false);
}
String source
= e.
getActionCommand();
if(source.equals("Save")) {
try {
doc.salva();
e1.printStackTrace();
}
} else if(source.equals("Save As")) {
try {
doc.saveAs();
e1.printStackTrace();
}
} else if(source.equals("Open")) {
try {
if(text != null) {
this.source.setText(text);
doc.salvato = true;
}
e1.printStackTrace();
}
} else if(source.equals("Exit")) {
doc.onExit();
} else if(source.equals("New")) {
doc.nuovo(this.source);
}
}
public void centerFrame() {
win=getSize();
setLocation(d.width/2-(win.width/2)-1,d.height/2-(win.height/2)-1);
}
}
static {
System.
loadLibrary("Document");
}
public boolean salvato, compilato, edit;
int j = 0;
private JavArrow parent;
public native void Run
(String path
);
salvato = false;
compilato = false;
edit = false;
this.parent = parent;
}
if(!compilato) compile(pathsdk, p);
FileWriter fww
= new FileWriter(file.
toString().
substring(0, file.
toString().
lastIndexOf('.')) + ".bat");
fw.write(pathsdk.replace('/', '\\') + "\\java -cp " + file.getCanonicalPath().substring(0, file.getCanonicalPath().lastIndexOf('\\')) + " " + file.getName().substring(0, file.getName().lastIndexOf('.')));
fw.close();
Run(file.toString().substring(0, file.toString().lastIndexOf('.')) + ".bat");
}
boolean nuovo = false;
if(!edit) {
salvato = false;
compilato = false;
edit = true;
c.setText("");
} else {
int resp
= JOptionPane.
showConfirmDialog(null,
"E' aperto un documento non salvato, salvare ora?",
"Salvataggio",
JOptionPane.
YES_NO_CANCEL_OPTION);
switch(resp) {
try {
salva();
salvato = false;
compilato = false;
edit = true;
c.setText("");
e1.printStackTrace();
}
break;
salvato = false;
compilato = false;
edit = true;
c.setText("");
break;
;
}
}
}
public void onExit() {
if(!edit) {
} else {
int resp
= JOptionPane.
showConfirmDialog(null,
"E' aperto un documento non salvato, salvare ora?",
"Salvataggio",
JOptionPane.
YES_NO_CANCEL_OPTION);
switch(resp) {
try {
salva();
e1.printStackTrace();
}
break;
break;
;
}
}
}
if(salvato) {
fos.write(parent.getSource().getBytes());
fos.close();
edit = false;
} else {
saveAs();
}
}
fc.setFileFilter(this);
fc.setApproveButtonText("Salva");
fc.addChoosableFileFilter(this);
int resp = fc.showOpenDialog(parent);
file
= new File((fc.
getSelectedFile().
toString().
endsWith(".java") ? fc.
getSelectedFile().
toString().
replace('\\',
'/'):(fc.
getSelectedFile().
toString()+ ".java").
replace('\\',
'/')));
fos.write(parent.getSource().getBytes());
fos.close();
salvato = true;
edit = false;
}
}
fc.addChoosableFileFilter(this);
fc.setFileFilter(this);
fc.setApproveButtonText("Apri");
int resp = fc.showOpenDialog(parent);
file
= new File(fc.
getSelectedFile().
toString().
replace('\\',
'/'));
int i = 0;
while((i = fis.read()) != -1) {
text.append((char)i);
}
ret = text.toString();
}
return ret;
}
if(!edit) {
text = getStr();
} else {
int resp
= JOptionPane.
showConfirmDialog(parent,
"E' aperto un altro file non salvato, salvare ora le modifiche?",
"Salvataggio",
JOptionPane.
YES_NO_CANCEL_OPTION);
switch(resp) {
salva();
text = getStr();
if(text != null) {
salvato = true;
compilato = false;
edit = false;
}
break;
text = getStr();
if(text != null) {
salvato = true;
compilato = false;
edit = false;
}
break;
text = null;
}
}
return text;
}
salva();
try {
int i = 0;
Process p
= Runtime.
getRuntime().
exec(path
+ "/javac " + file.
toString());
console.setText("");
while((i = is.read())!= -1) {
console.setText(console.getText() + (char)i);
}
is.close();
e.printStackTrace();
}
compilato = true;
}
public boolean accept
(File f
) {
return f.toString().toLowerCase().endsWith(".java") || f.isDirectory();
}
public String getDescription
() {
return "Sorgente java(*.java)";
}
}