Results 1 to 3 of 3
Thread: Javapad 2.0
- 05-13-2008, 03:25 AM #1
Senior Member
- Join Date
- May 2008
- Location
- Makati, Philippines
- Posts
- 234
- Rep Power
- 6
Javapad 2.0
Attach here the Beta Version of Notepad with some Java Features.
Contains Basic Features of a Notepad. Except the Print feature is not yet working. (Can someone send me a printing function =))
Contains Extra Features such as Build, Run, Open-Command Line (Must have java_home and Java declared in the environmental variables) (Works in Windows but not yet tested in other platforms)
Feel free to email me your reactions/proposed feature/Bugs and error.
This is my contribution to the Java Community. =)
- 05-13-2008, 05:01 AM #2
I've tested your program....
Win XP SP3
Im using jdk 6 update 3
bin path already set
Build and Runtime error. why? using Runtime? or JavaCompiler class?
I suggest you shall create a documentation about your program. How should specifically use it, its condition before using it, and EULA ( detailed )...
Not bad, keep it up.....
Here is a simple PrintData Class, it will print a page.
where Component e should be the source of text ( TextArea for example )Java Code:public class PrintData implements Printable{ private Component data; public PrintData(Component e){ this.data = e; } public void setValue(){ new PrintData(data).initializePrint(); } public void initializePrint(){ PrinterJob proceed = PrinterJob.getPrinterJob(); proceed.setPrintable(this); if(proceed.printDialog()){ try{ proceed.print(); }catch(Exception e){ JOptionPane.showMessageDialog(null,"AN ERROR OCCURED WHILE INITIALIZING PRINTER"); } } } public int print(Graphics g, PageFormat format, int page){ int value = Printable.PAGE_EXISTS; Font pattern = new Font("Arial",Font.PLAIN,10); if(page>0){value = Printable.NO_SUCH_PAGE;} Graphics2D g2D = (Graphics2D)g; g2D.setFont(pattern); g2D.translate(format.getImageableX(),format.getImageableY()); data.setFont(pattern); data.paint(g2D); return value; } }Last edited by sukatoa; 05-13-2008 at 05:08 AM.
freedom exists in the world of ideas
- 05-13-2008, 06:36 AM #3
Senior Member
- Join Date
- May 2008
- Location
- Makati, Philippines
- Posts
- 234
- Rep Power
- 6
WAW thanks a lot. I really appreciate it. =)
I just used the command line in Compiling. Here is the Command i used. i just cut it from the main code. I just invoke the Javac and java commands. One more problem is how do i Handle those errors in compiling. I will read the compilerClass, thanks for informing that, Im still have lots to learn about java. =)
Java Code:else if (command.equals("Build")) { try { File filename2 = new File(filename.getAbsolutePath().substring(0,filename.getAbsolutePath().lastIndexOf("."))); String s ="javac -cp \""+ filename2.getAbsolutePath().substring(0, filename2.getAbsolutePath().lastIndexOf("\\"))+"\" \""+ filename2.getAbsolutePath() +".java\""; Runtime.getRuntime().exec(s); JOptionPane.showMessageDialog(this,"Building Succesful"); } catch (Exception ex){ System.err.println(ex); JOptionPane.showMessageDialog(this,"Building Error");} } else if (command.equals("Run")) { try { File filename3 = new File(filename.getAbsolutePath().substring(0,filename.getAbsolutePath().lastIndexOf("."))); String s ="cmd.exe /k start java -cp \""+ filename3.getAbsolutePath().substring(0, filename3.getAbsolutePath().lastIndexOf("\\")) + "\" "+ filename.getName().substring(0,filename.getName().lastIndexOf(".")); Process process = Runtime.getRuntime().exec(s); BufferedReader stdout = new BufferedReader(new InputStreamReader(process.getInputStream())); JOptionPane.showMessageDialog(this,"Run Succesful"); } catch (Exception ex){ System.err.println(ex); JOptionPane.showMessageDialog(this,"Run Time Error");} }else if (command.equals("Open Command Line")) { try { Runtime.getRuntime().exec("cmd.exe /k start cd \\");} catch (Exception ex){ System.err.println(ex); JOptionPane.showMessageDialog(this,"Run Time Error");} }Last edited by Eku; 05-13-2008 at 06:40 AM.


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks