EG Information
Training Missions
Knowledge Bank
|
|
Enigma Group's Code Bank
MyIDEBy: darkside - Date Submitted: 2010-03-16 23:31:36 import java.io.BufferedReader; import java.io.File; import java.io.FileFilter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; /* * Face.java * * Created on Mar 7, 2010, 12:46:03 AM */ /** * My Integrated Development Environment tested on SLAX and Windows XP * * @author The Son of Man * @version 1.0.0.1 */ public class Face extends javax. swing. JFrame { /** Creates new form Face */ public String curFile, gcc = "/usr/bin/gcc", cc = "/usr/bin/cc", product, _os, titleBar, defaultTitle ; public boolean cFile, isLinux; public Face() { initComponents(); this._os = System. getProperty(nameOS ); this.defaultTitle = "MyIDE" + "@" + this._os + ": "; this.titleBar = this.defaultTitle; setTitle(this.titleBar); if (this._os.equals("Linux")) { this.isLinux = true; } else { this.gccField.setText("specify"); this.parameterField.setText("specify"); this.isLinux = false; } this.setResizable(false); this.cFile = false; this.curFile = null; this.product = null; } /** 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. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { contentPanel = new javax. swing. JPanel(); menuPanel = new javax. swing. JPanel(); gccLabel = new javax. swing. JLabel(); paramLabel = new javax. swing. JLabel(); fileNameLabel = new javax. swing. JLabel(); l_label = new javax. swing. JLabel(); lCount = new javax. swing. JLabel(); pathLabel = new javax. swing. JLabel(); shButton = new javax. swing. JButton(); fileMenu = new javax. swing. JMenu(); fileSeparator = new javax. swing. JPopupMenu. Separator(); codeMenu = new javax. swing. JMenu(); compileMenuItem = new javax. swing. JMenuItem(); aboutMenu = new javax. swing. JMenu(); setTitle("MyIDE"); setCursor (new java. awt. Cursor(java. awt. Cursor. DEFAULT_CURSOR)); getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); contentPanel. setBorder(new javax. swing. border. MatteBorder(null)); menuPanel. setBorder(javax. swing. BorderFactory. createEtchedBorder()); parameterField.setText("-Wall -o"); parameterField.setToolTipText("Parameters for the compiler. Default: -Wall -o"); fileNameField.setText("myapp"); fileNameField.setToolTipText("The filename to save the file as."); gccField.setText("/usr/bin/g++"); gccField.setToolTipText("The location of the gcc, g++, or cc compiler in your system."); gccLabel.setText("gcc location"); paramLabel.setText("parameters"); fileNameLabel.setText("filename"); l_label.setText("line count:"); lCount.setText("0"); pathLabel.setText("program path"); pathField.setText("specify"); pathField.setToolTipText("The path to save the file to."); shButton.setText("shell"); shButton.setToolTipText("Opens a shell."); public void actionPerformed (java. awt. event. ActionEvent evt ) { shButtonActionPerformed(evt); } }); javax.swing.GroupLayout menuPanelLayout = new javax.swing.GroupLayout(menuPanel); menuPanel.setLayout(menuPanelLayout); menuPanelLayout.setHorizontalGroup( menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(menuPanelLayout.createSequentialGroup() .addContainerGap() .addGroup(menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(gccLabel) .addComponent(gccField, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(menuPanelLayout.createSequentialGroup() .addComponent(l_label) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(lCount))) . addPreferredGap(javax. swing. LayoutStyle. ComponentPlacement. RELATED, javax. swing. GroupLayout. DEFAULT_SIZE, Short. MAX_VALUE) .addGroup(menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) . addComponent(parameterField, javax. swing. GroupLayout. Alignment. TRAILING, javax. swing. GroupLayout. DEFAULT_SIZE, 112, Short. MAX_VALUE) .addComponent(paramLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(fileNameLabel) . addComponent(fileNameField, javax. swing. GroupLayout. DEFAULT_SIZE, 112, Short. MAX_VALUE)) .addGap(12, 12, 12) .addGroup(menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(menuPanelLayout.createSequentialGroup() . addComponent(pathField, javax. swing. GroupLayout. DEFAULT_SIZE, 130, Short. MAX_VALUE) .addContainerGap()) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, menuPanelLayout.createSequentialGroup() . addComponent(shButton, javax. swing. GroupLayout. DEFAULT_SIZE, 130, Short. MAX_VALUE) .addContainerGap()) .addGroup(menuPanelLayout.createSequentialGroup() .addComponent(pathLabel) .addGap(27, 27, 27)))) ); menuPanelLayout.setVerticalGroup( menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(menuPanelLayout.createSequentialGroup() .addGroup(menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(gccLabel) .addComponent(paramLabel) .addComponent(fileNameLabel) .addComponent(pathLabel)) .addGap(3, 3, 3) .addGroup(menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(gccField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(parameterField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(fileNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(pathField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(l_label) .addComponent(lCount) .addComponent(shButton, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)) . addContainerGap(javax. swing. GroupLayout. DEFAULT_SIZE, Short. MAX_VALUE)) ); _textArea.setColumns(20); _textArea.setRows(5); _textArea. addCaretListener(new javax. swing. event. CaretListener() { public void caretUpdate (javax. swing. event. CaretEvent evt ) { _textAreaCaretUpdate(evt); } }); scrollPane.setViewportView(_textArea); javax.swing.GroupLayout contentPanelLayout = new javax.swing.GroupLayout(contentPanel); contentPanel.setLayout(contentPanelLayout); contentPanelLayout.setHorizontalGroup( contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, contentPanelLayout.createSequentialGroup() . addContainerGap(javax. swing. GroupLayout. DEFAULT_SIZE, Short. MAX_VALUE) .addComponent(menuPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) . addComponent(scrollPane, javax. swing. GroupLayout. DEFAULT_SIZE, 548, Short. MAX_VALUE) ); contentPanelLayout.setVerticalGroup( contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, contentPanelLayout.createSequentialGroup() . addComponent(scrollPane, javax. swing. GroupLayout. DEFAULT_SIZE, 510, Short. MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(menuPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); getContentPane().add(contentPanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 550, 610)); fileMenu.setText("File"); fileMenu.setToolTipText(""); openMenuItem.setText("Open a file"); openMenuItem.setToolTipText("Open an already written file for editing purposes, etc."); public void actionPerformed (java. awt. event. ActionEvent evt ) { openMenuItemActionPerformed(evt); } }); fileMenu.add(openMenuItem); saveMenuItem.setText("Save current file"); saveMenuItem.setToolTipText("Save this file for future usage, etc."); public void actionPerformed (java. awt. event. ActionEvent evt ) { saveMenuItemActionPerformed(evt); } }); fileMenu.add(saveMenuItem); closeMenuItem.setText("Close this file"); closeMenuItem.setToolTipText("Close this file to begin coding something else, etc."); public void actionPerformed (java. awt. event. ActionEvent evt ) { closeMenuItemActionPerformed(evt); } }); fileMenu.add(closeMenuItem); fileMenu.add(fileSeparator); exitMenuItem.setText("Exit"); exitMenuItem.setToolTipText("This will close the application."); public void actionPerformed (java. awt. event. ActionEvent evt ) { exitMenuItemActionPerformed(evt); } }); fileMenu.add(exitMenuItem); menuBar.add(fileMenu); codeMenu.setText("Code"); codeMenu.setToolTipText(""); compileMenuItem.setText("Compile"); compileMenuItem.setToolTipText("Compiles the file. Be sure to check it out with the shell button."); compileMenuItem. addActionListener(new java. awt. event. ActionListener() { public void actionPerformed (java. awt. event. ActionEvent evt ) { compileMenuItemActionPerformed(evt); } }); codeMenu.add(compileMenuItem); cnrMenuItem.setText("Compile & Run"); cnrMenuItem.setToolTipText("Compiles the file and executes it afterward."); public void actionPerformed (java. awt. event. ActionEvent evt ) { cnrMenuItemActionPerformed(evt); } }); codeMenu.add(cnrMenuItem); menuBar.add(codeMenu); aboutMenu.setText("About"); aboutMenu.setToolTipText(""); myIDEMenuItem.setText("MyIDE"); myIDEMenuItem.setToolTipText("Usage/Author information."); public void actionPerformed (java. awt. event. ActionEvent evt ) { myIDEMenuItemActionPerformed(evt); } }); aboutMenu.add(myIDEMenuItem); menuBar.add(aboutMenu); setJMenuBar(menuBar); pack(); }// </editor-fold>//GEN-END:initComponents private void openMenuItemActionPerformed (java. awt. event. ActionEvent evt ) {//GEN-FIRST:event_openMenuItemActionPerformed try { if (this.cFile == false) { int returnval = this.fChooser.showOpenDialog(this); File file = this. fChooser. getSelectedFile(); try { boolean eof = false; while (!eof) { String line = fData. readLine(); if (line != null) lines += (line+"rn"); else eof = true; } fData.close(); String _message = "Could not open the file.", _title = "Error"; } this.cFile = true; this.curFile = file.getPath(); this.setTitleBar(this.curFile); this._textArea.setText(lines); } } else { String _message = "Please (save and) close the current file first.", _title = "Error"; } String _message = "Please (save and) close the current file first.", _title = "Error"; } }//GEN-LAST:event_openMenuItemActionPerformed private void saveMenuItemActionPerformed (java. awt. event. ActionEvent evt ) {//GEN-FIRST:event_saveMenuItemActionPerformed int returnval = this.fChooser.showSaveDialog(this); File file = this. fChooser. getSelectedFile(); this._textArea.append("n"); // for gcc purposes try { String fData = this._textArea. getText(); this.curFile = file.getPath(); out.write(fData); out.close(); String _message = "The file could not be saved.", _title = "Error"; } } this.cFile = true; this.setTitleBar(this.curFile); }//GEN-LAST:event_saveMenuItemActionPerformed private void closeMenuItemActionPerformed (java. awt. event. ActionEvent evt ) {//GEN-FIRST:event_closeMenuItemActionPerformed try { if (this.cFile == true) { this.curFile.equals(null); this.setTitleBar(""); this.cFile = false; this._textArea.setText(""); } else if (!(this._textArea.getText().isEmpty())) { this._textArea.setText(""); } else { String _message = "No text to clear.", _title = "Error"; } String _message = "No text to clear.", _title = "Error"; } }//GEN-LAST:event_closeMenuItemActionPerformed private void setTitleBar (String _curFile ) { this.titleBar = this.defaultTitle + _curFile; setTitle(this.titleBar); } private void exitMenuItemActionPerformed (java. awt. event. ActionEvent evt ) {//GEN-FIRST:event_exitMenuItemActionPerformed this.dispose(); }//GEN-LAST:event_exitMenuItemActionPerformed private void compileMenuItemActionPerformed (java. awt. event. ActionEvent evt ) {//GEN-FIRST:event_compileMenuItemActionPerformed try { if (this.cFile == true) { if (!(this.gccField.getText().equals(null)) && !(this.parameterField.getText().equals(null)) && !(this.fileNameField.getText().equals(null)) && !(this.pathField.getText().equals(null))) { try { String cmd = this. gccField. getText() + " " + this.parameterField.getText() + " " + this.pathField.getText() + this.fileNameField.getText() + " " + this.curFile; String _message = "Could not compile.", _title = "Error"; } } else { String _message = "Fill out each text field first.", _title = "Error"; } } else { String _message = "Save the file first or choose a file.", _title = "Error"; } String _message = "Fill out each text field first.", _title = "Error"; } }//GEN-LAST:event_compileMenuItemActionPerformed private void cnrMenuItemActionPerformed (java. awt. event. ActionEvent evt ) {//GEN-FIRST:event_cnrMenuItemActionPerformed try { if (this.cFile == true) { if (!(this.gccField.getText().equals(null)) && !(this.parameterField.getText().equals(null)) && !(this.fileNameField.getText().equals(null)) && !(this.pathField.getText().equals(null))) { try { String cmd = this. gccField. getText() + " " + this.parameterField.getText() + " " + this.pathField.getText() + this.fileNameField.getText() + " " + this.curFile; String _message = "Could not compile.", _title = "Error"; } this.product.equals(this.fileNameField.getText()); this.pathField.setText(this.product); String sh_cmd = "/usr/bin/xterm" + " " + this. pathField. getText() + this. fileNameField. getText(); try { String _message = "Could not execute the compilation.nn" + exc. getMessage(), _title = "Error"; } } else { String _message = "Fill out each text field first.", _title = "Error"; } } else { String _message = "Save the file first or choose a file.", _title = "Error"; } String _message = "Fill out each text field first.", _title = "Error"; } }//GEN-LAST:event_cnrMenuItemActionPerformed private void myIDEMenuItemActionPerformed (java. awt. event. ActionEvent evt ) {//GEN-FIRST:event_myIDEMenuItemActionPerformed String _message = "I wrote this program because I seriously couldn't find a C++ IDE for Linux.n" + "MyIDE is a simple, platform-independent application written with Java Technology.n" + "nInstructions:n" + "Specify location of gccn" + "Specify gcc parametersn" + "Specify compilation file namen" + "Specify path to save file to" + "nnAuthor: The Son of Man" + "nEMail: 6461726B73696465@gmail.com", _title = "About MyIDE"; }//GEN-LAST:event_myIDEMenuItemActionPerformed private void shButtonActionPerformed (java. awt. event. ActionEvent evt ) {//GEN-FIRST:event_shButtonActionPerformed if (this.isLinux == true) { String cmd = "/usr/bin/xterm"; try { p = Runtime. getRuntime(). exec(cmd, null, wd ); String _message = "Couldn't open bash.", _title = "Error"; } } else if (this.isLinux == false) { String cmd = "C:\WINDOWS\system32\cmd.exe"; try { p = Runtime. getRuntime(). exec(cmd ); String _message = "Couldn't open command prompt.", _title = "Error"; } } else { String _message = "You must manually open your shell.", _title = "Error"; } }//GEN-LAST:event_shButtonActionPerformed private void _textAreaCaretUpdate (javax. swing. event. CaretEvent evt ) {//GEN-FIRST:event__textAreaCaretUpdate int count = this._textArea.getLineCount(); this. lCount. setText(String. valueOf(count )); }//GEN-LAST:event__textAreaCaretUpdate /** * @param args the command line arguments */ public static void main (String args []) { public void run() { new Face().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax. swing. JMenu aboutMenu ; private javax. swing. JMenu codeMenu ; private javax. swing. JMenuItem compileMenuItem ; private javax. swing. JPanel contentPanel ; private javax. swing. JMenu fileMenu ; private javax. swing. JLabel fileNameLabel ; private javax. swing. JPopupMenu. Separator fileSeparator ; private javax. swing. JLabel gccLabel ; private javax. swing. JLabel lCount ; private javax. swing. JLabel l_label ; private javax. swing. JPanel menuPanel ; private javax. swing. JLabel paramLabel ; private javax. swing. JLabel pathLabel ; private javax. swing. JButton shButton ; // End of variables declaration//GEN-END:variables }
|
| Return to
java category list |
|
|
Who's Online
483 Guests, 100 Users ckryptix, Nasrudin, Diznablo, CollapsingWalls, asapong, mehtaparag, bitstrike, jnony, C, Nicid1, Nusquam-Redono-Sapientia, bazcrown, saifulfaizan, The End, Ultraminor, psychomarine, st3alth, themastersinner, pgmrlink, login, lionaneesh, ishkur88, mahraja, Mac, chekifr, gandalf88, Vap0r, t0ast, tantrum6226, BnE, Distorted, Psiber_Syn, Ausome1, invas10n, oldgoat, freedaysbecumei, BinaryShinigami, Rex_Mundi, Red_beard, Strobeflux, s0m3nak3dguy, Descent, teehee, machupicchu, Genetix, Anandarl, NotMyOwn, thegamerdude, Godzila, popo12341234, RedEvolution, rabbidmind, velocity_b, myne17, teto111, aVoid, Central-Gsm, 1101, JackalReborn, InjectioN, h4lted, c0re, DisPater, markt4death, splatta, Jackowacko, saint556, Pyron2312, Azerion, howsens, white.hat.gone.bad, vazzilly, pwunkz, Ios, Inverted, QuarterCask, Infernoe11, deskata, cr4ck3rj4ck, Blizer, jasonmax, j0sh, gwenwavor, N4g4c3N, spizeyboy, Network X, Uino59, Jae Cee, ianFDK, saykov, medhaavee, zofy, demonkiller410, Stumble, SaMTHG, kishore, Raze, helasraizam, Venom1019, Jakabo |
| |
|
|
|
|
|