Help with a program I would like to write

Discussion in 'Software' started by red death68, Sep 5, 2012.

  1. red death68

    red death68 Command Sergeant Major

    I would like to write a program that would make it easier to take notes in math class. As about anyone who has ever taken math knows there are a lot of symbols in math that are not default on a keyboard. I would like to make an application to change all of that even if its just for personal use.

    I am planning to use java as the language as that is the only non scripting language I relatively know. What I need help with is the following:

    I need someone to help me figure out how to use jpanel or some other class in java to add the user interface(we never really coverd ui when i learned java)

    I need help figuring out how to make a typable text area.

    I need to know how I can insert the math symbols and what format the resulting file need to be saved in so the math symbols dont become broken symbols.

    I need to know how to make it save in a perticular way so as the needed encoding is applied.

    and any other advice that can be given. This will be my main project for a while other then completly customizing my computer once it is fixed so I would like to get started on it as soon as possible so any help will be much appreciated.

    Thank you very much in advance for any help I may recieve.
     
  2. GermanOne

    GermanOne Guest

    I can't help you with Java but a lot of math symbols can be found in the common fonts if you use Unicode charset. Also you could use a monospaced font which makes it easier to arrange formulas clearly.
    Run charmap.exe select font "Courier New" and charset "Unicode" and have a look at the characters HEX 2202 and following (∂∆∏∑−∕√∞∟∩∫≈≠≡≤≥ etc.). You can save those characters in a simple text file. Perhaps you should read something about Endianess and Byte Order Marks to understand how it works.

    Regards
    GermanOne
     
  3. PC-XT

    PC-XT Master Sergeant

    Here is the Java documentation:

    http://docs.oracle.com/javase/tutorial/uiswing/components/text.html
    http://docs.oracle.com/javase/1.4.2/docs/api/javax/swing/text/JTextComponent.html
    A styled component like JEditorPane or JTextPane might be better for showing math, but if you prefer simple Unicode, the others work pretty well.

    Using top-level containers:
    http://docs.oracle.com/javase/tutorial/uiswing/components/toplevel.html

    I think I have some UI templates somewhere that I used to use... If you want them, I'll try to look them up.
     
  4. red death68

    red death68 Command Sergeant Major

    thanks for all the help any other help would be appreciated you can never be to informed when writing a program especially if you have no idea what you are doing.....
     
  5. pwillener

    pwillener MajorGeek

    The symbols that GermanOne mentioned can easily be inserted by Word (Insert | Symbols | Mathematical Symbols), so there is no real need to write your own editor.

    Word 2010 has even more advanced Symbols and Equations functionality.
     
  6. red death68

    red death68 Command Sergeant Major

    though there may be no "need" it would be reat experience for me when it came to programming
     
  7. pwillener

    pwillener MajorGeek

    That, of course, is true. Unfortunately I have never written anything in Java, so I can't help you.

    Good luck!
     
  8. PC-XT

    PC-XT Master Sergeant

    I looked over what I found. There are two main template styles, one extends the frame, for applications with one main window, and the other just creates a frame object and uses it. This is the JFrame extension, taken from code made with NetBeans IDE, including a menu bar.
    Code:
    public class Application extends javax.swing.JFrame {
    
    	/** Creates new form Application */
        public Application() {
    
            jTextPane1 = new javax.swing.JTextPane();
            getContentPane().add(jTextPane1, java.awt.BorderLayout.CENTER);
    
            menuBar = new javax.swing.JMenuBar();
    
            fileMenu = new javax.swing.JMenu();
            fileMenu.setText("File");
    
            openMenuItem = new javax.swing.JMenuItem();
            openMenuItem.setText("Open");
    
            fileMenu.add(openMenuItem);
            saveMenuItem = new javax.swing.JMenuItem();
            saveMenuItem.setText("Save");
    
            fileMenu.add(saveMenuItem);
            saveAsMenuItem = new javax.swing.JMenuItem();
            saveAsMenuItem.setText("Save As ...");
    
            fileMenu.add(saveAsMenuItem);
            exitMenuItem = new javax.swing.JMenuItem();
            exitMenuItem.setText("Exit");
            exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
                                               public void actionPerformed(java.awt.event.ActionEvent evt) {
                                                   exitMenuItemActionPerformed(evt);
                                               }
                                           }
                                          );
    
            fileMenu.add(exitMenuItem);
            menuBar.add(fileMenu);
            editMenu = new javax.swing.JMenu();
            editMenu.setText("Edit");
    
            cutMenuItem = new javax.swing.JMenuItem();
            cutMenuItem.setText("Cut");
    
            editMenu.add(cutMenuItem);
            copyMenuItem = new javax.swing.JMenuItem();
            copyMenuItem.setText("Copy");
    
            editMenu.add(copyMenuItem);
            pasteMenuItem = new javax.swing.JMenuItem();
            pasteMenuItem.setText("Paste");
    
            editMenu.add(pasteMenuItem);
            deleteMenuItem = new javax.swing.JMenuItem();
            deleteMenuItem.setText("Delete");
    
            editMenu.add(deleteMenuItem);
            menuBar.add(editMenu);
            helpMenu = new javax.swing.JMenu();
            helpMenu.setText("Help");
    
            contentsMenuItem = new javax.swing.JMenuItem();
            contentsMenuItem.setText("Contents");
    
            helpMenu.add(contentsMenuItem);
            aboutMenuItem = new javax.swing.JMenuItem();
            aboutMenuItem.setText("About");
    
            helpMenu.add(aboutMenuItem);
            menuBar.add(helpMenu);
            addWindowListener(new java.awt.event.WindowAdapter() {
                                  public void windowClosing(java.awt.event.WindowEvent evt) {
                                      exitForm(evt);
                                  }
                              }
                             );
    
            setJMenuBar(menuBar);
    
            pack();
        }
    
        private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
            System.exit(0);
        }
    
        /** Exit the Application */
        private void exitForm(java.awt.event.WindowEvent evt) {
            System.exit(0);
        }
    
        /**
        * @param args the command line arguments
        */
        public static void main(String args[]) {
    		 new Application().show();
        }
    
        // Variables declaration
        private javax.swing.JTextPane jTextPane1;
        private javax.swing.JMenuBar menuBar;
        private javax.swing.JMenu fileMenu;
        private javax.swing.JMenuItem openMenuItem;
        private javax.swing.JMenuItem saveMenuItem;
        private javax.swing.JMenuItem saveAsMenuItem;
        private javax.swing.JMenuItem exitMenuItem;
        private javax.swing.JMenu editMenu;
        private javax.swing.JMenuItem cutMenuItem;
        private javax.swing.JMenuItem copyMenuItem;
        private javax.swing.JMenuItem pasteMenuItem;
        private javax.swing.JMenuItem deleteMenuItem;
        private javax.swing.JMenu helpMenu;
        private javax.swing.JMenuItem contentsMenuItem;
        private javax.swing.JMenuItem aboutMenuItem;
        // End of variables declaration
    
    }
    And this one I just typed here creates a JFrame window and adds a JTextPane to it, without extending the JFrame:
    Code:
    public class Application {
    	private javax.swing.JFrame frame;
    	private javax.swing.JTextPane jTextPane;
    	public static void makeGUI(){
    		frame=new javax.swing.JFrame("Application Template");
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		jTextPane = new javax.swing.JTextPane();
    		frame.getContentPane().add(jTextPane, java.awt.BorderLayout.CENTER);
    	}
    	public static void main(String args[]) {
            javax.swing.SwingUtilities.invokeLater(new Runnable() {public void run() {makeGUI();}});
    	}
    }
    Another example here, with other elements instead of a JTextPane: http://docs.oracle.com/javase/tutor...lDemoProject/src/components/TopLevelDemo.java
    Note the thread-safe way to call the GUI method.

    The layouts (how the elements are placed in the window) can be confusing. These use BorderLayout, which is the default, but other layouts give more control. Most people use a graphical layout editer (usually part of an IDE) to generate the code, but you can do it with a simple editor if you know how. I started with a graphical one so I could see the relationship of code to display effects, then migrated to simple editor.
    http://docs.oracle.com/javase/tutorial/uiswing/layout/index.html
     
  9. red death68

    red death68 Command Sergeant Major

    thank you for the help pc
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds