16Skittles wrote:
theprogrammerpro wrote:
C:\Users\Me\Documents\NetBeansProjects\test\build\classes
so try
Code:
cd NetBeansProjects\test\build
alright now how do i do this without the CMD
Offline
Maybe Eclipse has a compile/run tool?
Otherwise, you're stuck with the command line.
Offline
net beans does but i want an icon so i can distribute this project.
import java.awt.*; import java.awt.event.*; import java.awt.event.ActionListener.*; import java.awt.datatransfer.*; import java.io.*; public class WriterBasic extends Frame { String filename; TextArea tx; Clipboard clip = getToolkit().getSystemClipboard(); WriterBasic() { super("WriterBasic"); setLayout(new GridLayout(1,1)); tx = new TextArea(); add(tx); MenuBar mb = new MenuBar(); Menu F = new Menu("file"); MenuItem n = new MenuItem("New"); MenuItem o = new MenuItem("Open"); MenuItem s = new MenuItem("Save"); MenuItem e = new MenuItem("Exit"); n.addActionListener(new New()); F.add(n); o.addActionListener(new Open()); F.add(o); s.addActionListener(new Save()); F.add(s); e.addActionListener(new Exit()); F.add(e); mb.add(F); Menu E = new Menu("Edit"); MenuItem cut = new MenuItem("Cut"); MenuItem copy = new MenuItem("Copy"); MenuItem paste = new MenuItem("Paste"); cut.addActionListener(new Cut()); E.add(cut); copy.addActionListener(new Copy()); E.add(copy); paste.addActionListener(new Paste()); E.add(paste); mb.add(E); setMenuBar(mb); mylistener mylist = new mylistener(); addWindowListener(mylist); } class mylistener extends WindowAdapter { @Override public void windowClosing (WindowEvent e) { System.exit(0); } } class New implements ActionListener { @Override public void actionPerformed(ActionEvent e) { tx.setText(" "); setTitle(filename); } } class Open implements ActionListener { @Override public void actionPerformed(ActionEvent e) { FileDialog fd = new FileDialog(WriterBasic.this, "select File",FileDialog.LOAD); fd.show(); if (fd.getFile()!=null) { filename = fd.getDirectory() + fd.getFile(); setTitle(filename); ReadFile(); } tx.requestFocus(); } } class Save implements ActionListener { public void actionPerformed(ActionEvent e) { FileDialog fd = new FileDialog(WriterBasic.this,"Save File",FileDialog.SAVE); fd.show(); if (fd.getFile()!=null) { filename = fd.getDirectory() + fd.getFile(); setTitle(filename); try { DataOutputStream d = new DataOutputStream(new FileOutputStream(filename)); String line = tx.getText(); BufferedReader br = new BufferedReader(new StringReader(line)); while((line = br.readLine())!=null) { d.writeBytes(line + "\r\n"); d.close(); } } catch(Exception ex) { System.out.println("File not found"); } tx.requestFocus(); } } } class Exit implements ActionListener { @Override public void actionPerformed(ActionEvent e) { System.exit(0); } } void ReadFile() { BufferedReader d; StringBuilder sb = new StringBuilder(); try { d = new BufferedReader(new FileReader(filename)); String line; while((line=d.readLine())!=null) sb.append(line).append("\n"); tx.setText(sb.toString()); d.close(); } catch(FileNotFoundException fe) { System.out.println("File not Found"); } catch(IOException ioe){} } class Cut implements ActionListener { @Override public void actionPerformed(ActionEvent e) { String sel = tx.getSelectedText(); StringSelection ss = new StringSelection(sel); clip.setContents(ss,ss); tx.replaceRange(" ",tx.getSelectionStart(),tx.getSelectionEnd()); } } class Copy implements ActionListener { @Override public void actionPerformed(ActionEvent e) { String sel = tx.getSelectedText(); StringSelection clipString = new StringSelection(sel); clip.setContents(clipString,clipString); } } class Paste implements ActionListener { @Override public void actionPerformed(ActionEvent e) { Transferable cliptran = clip.getContents(WriterBasic.this); try { String sel = (String) cliptran.getTransferData(DataFlavor.stringFlavor); tx.replaceRange(sel,tx.getSelectionStart(),tx.getSelectionEnd()); } catch( UnsupportedFlavorException | IOException exc) { System.out.println("not string flavour"); } } } public static void main(String args[]) { Frame f = new WriterBasic(); f.setSize(500,400); f.setVisible(true); f.show(); } }
Offline