Results 1 to 3 of 3

Thread: Javapad 2.0

  1. #1
    Eku
    Eku is offline Senior Member
    Join Date
    May 2008
    Location
    Makati, Philippines
    Posts
    234
    Rep Power
    6

    Default 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. =)
    Attached Files Attached Files

  2. #2
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    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.

    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;
        }
    }
    where Component e should be the source of text ( TextArea for example )
    Last edited by sukatoa; 05-13-2008 at 05:08 AM.
    freedom exists in the world of ideas

  3. #3
    Eku
    Eku is offline Senior Member
    Join Date
    May 2008
    Location
    Makati, Philippines
    Posts
    234
    Rep Power
    6

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •