/** Creates a JRadioButtonMenuItem for the Themes menu */ private JMenuItem createThemesMenuItem( JMenu menu, String label, char mnemonic, String accessibleDescription, DefaultMetalTheme theme) { JRadioButtonMenuItem mi = (JRadioButtonMenuItem) menu.add(new JRadioButtonMenuItem(label)); themesMenuGroup.add(mi); mi.setMnemonic(mnemonic); mi.getAccessibleContext().setAccessibleDescription(accessibleDescription); mi.addActionListener(new ChangeThemeAction(this, theme)); return mi; }
/** * This method initializes jRadioButtonMenuItem1 * * @return JRadioButtonMenuItem */ private JRadioButtonMenuItem getJRadioButtonMenuItem1() { if (jRadioButtonMenuItem1 == null) { jRadioButtonMenuItem1 = new JRadioButtonMenuItem(); jRadioButtonMenuItem1.setText("System"); jRadioButtonMenuItem1.setMnemonic(java.awt.event.KeyEvent.VK_Y); jRadioButtonMenuItem1.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_Y, java.awt.Event.ALT_MASK, false)); jRadioButtonMenuItem1.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { changeLnF(UIManager.getSystemLookAndFeelClassName()); } }); } return jRadioButtonMenuItem1; }
/** * This method initializes jRadioButtonMenuItem * * @return JRadioButtonMenuItem */ private JRadioButtonMenuItem getJRadioButtonMenuItem() { if (jRadioButtonMenuItem == null) { jRadioButtonMenuItem = new JRadioButtonMenuItem(); jRadioButtonMenuItem.setText("Default"); jRadioButtonMenuItem.setSelected(true); jRadioButtonMenuItem.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_D, java.awt.Event.ALT_MASK, false)); jRadioButtonMenuItem.setMnemonic(java.awt.event.KeyEvent.VK_D); jRadioButtonMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { changeLnF(UIManager.getCrossPlatformLookAndFeelClassName()); } }); } return jRadioButtonMenuItem; }
private void initMenu() { JMenuBar menu = new JMenuBar(); setJMenuBar(menu); { // SUDOKU JMenu mSudoku = new JMenu(); menu.add(mSudoku); mSudoku.setText("Sudoku"); mSudoku.setMnemonic('S'); { sudNew = new JMenuItem("New", loadIcon("star1.png")); mSudoku.add(sudNew); setCtrlAcceleratorMenu(sudNew, 'N'); sudNew.addActionListener(mH); sudNew.setMnemonic('N'); sudCreate = new JMenuItem("Create", loadIcon("board1.png")); mSudoku.add(sudCreate); sudCreate.addActionListener(mH); sudCreate.setMnemonic('R'); sudOpen = new JMenuItem("Open...", loadIcon("open1.png")); mSudoku.add(sudOpen); setCtrlAcceleratorMenu(sudOpen, 'O'); sudOpen.addActionListener(mH); sudOpen.setMnemonic('O'); sudSave = new JMenuItem("Save", loadIcon("disk1.png")); mSudoku.add(sudSave); setCtrlAcceleratorMenu(sudSave, 'S'); sudSave.addActionListener(mH); sudSave.setMnemonic('S'); sudSaveAs = new JMenuItem("Save as...", loadIcon("diskAs1.png")); mSudoku.add(sudSaveAs); sudSaveAs.addActionListener(mH); setKeyAcceleratorMenu(sudSaveAs, 'S', Event.SHIFT_MASK + Event.CTRL_MASK); sudSaveAs.setMnemonic('A'); mSudoku.addSeparator(); sudClear = new JMenuItem("Clear", loadIcon("bin1.png")); mSudoku.add(sudClear); sudClear.addActionListener(mH); sudClear.setMnemonic('C'); sudHint = new JMenuItem("Hint", loadIcon("help1.png")); mSudoku.add(sudHint); sudHint.addActionListener(mH); sudHint.setMnemonic('H'); setCtrlAcceleratorMenu(sudHint, 'H'); sudSolve = new JMenuItem("Solve", loadIcon("tick1.png")); mSudoku.add(sudSolve); sudSolve.addActionListener(mH); sudSolve.setMnemonic('L'); mSudoku.addSeparator(); sudExport = new JMenuItem("Export...", loadIcon("export1.png")); mSudoku.add(sudExport); sudExport.addActionListener(mH); setCtrlAcceleratorMenu(sudExport, 'T'); sudExport.setMnemonic('T'); mSudoku.addSeparator(); sudExit = new JMenuItem("Exit", loadIcon("cross1.png")); mSudoku.add(sudExit); setKeyAcceleratorMenu(sudExit, Event.ESCAPE, 0); sudExit.addActionListener(mH); sudExit.setMnemonic('X'); } // Options JMenu mOptions = new JMenu("Options"); mOptions.setMnemonic('O'); menu.add(mOptions); { JLabel jl1 = new JLabel("<HTML>   <U>Difficulty :</U><HTML>"); jl1.setHorizontalAlignment(JLabel.LEFT); jl1.setHorizontalTextPosition(JLabel.LEFT); mOptions.add(jl1); ButtonGroup bGr1 = new ButtonGroup(); opDiffEasy = new JRadioButtonMenuItem("Easy"); opDiffEasy.addActionListener(mH); opDiffEasy.setMnemonic('E'); mOptions.add(opDiffEasy); bGr1.add(opDiffEasy); opDiffNormal = new JRadioButtonMenuItem("Normal", true); opDiffNormal.addActionListener(mH); opDiffNormal.setMnemonic('N'); mOptions.add(opDiffNormal); bGr1.add(opDiffNormal); opDiffHard = new JRadioButtonMenuItem("Hard"); opDiffHard.addActionListener(mH); opDiffHard.setMnemonic('H'); mOptions.add(opDiffHard); bGr1.add(opDiffHard); opDiffCustom = new JRadioButtonMenuItem("Custom..."); mOptions.add(opDiffCustom); opDiffCustom.addActionListener(mH); opDiffCustom.setMnemonic('C'); bGr1.add(opDiffCustom); mOptions.addSeparator(); JLabel jl2 = new JLabel("<HTML>   <U>Number Distribution :</U><HTML>"); jl2.setHorizontalAlignment(JLabel.LEFT); jl2.setHorizontalTextPosition(JLabel.LEFT); mOptions.add(jl2); ButtonGroup bGr2 = new ButtonGroup(); opND1 = new JRadioButtonMenuItem("Evenly filled 3x3 Cubes", true); opND1.addActionListener(mH); opND1.setMnemonic('F'); mOptions.add(opND1); bGr2.add(opND1); opND2 = new JRadioButtonMenuItem("Evenly distributed Numbers"); opND2.addActionListener(mH); opND2.setMnemonic('D'); mOptions.add(opND2); bGr2.add(opND2); opND3 = new JRadioButtonMenuItem("Random"); opND3.addActionListener(mH); opND3.setMnemonic('R'); mOptions.add(opND3); bGr2.add(opND3); mOptions.addSeparator(); opPref = new JMenuItem("Preferences...", loadIcon("wrench1.png")); mOptions.add(opPref); opPref.addActionListener(mH); setCtrlAcceleratorMenu(opPref, 'P'); opPref.setMnemonic('P'); } // Help JMenu mHelp = new JMenu("Help"); mHelp.setMnemonic('H'); menu.add(mHelp); { helpAbout = new JMenuItem("About", loadIcon("cup1.png")); mHelp.add(helpAbout); helpAbout.addActionListener(mH); helpAbout.setMnemonic('A'); } } }
public JMenuBar createMenuBar() { JMenuBar menuBar; JMenu menu, submenu; JMenuItem menuItem; JRadioButtonMenuItem rbMenuItem; JCheckBoxMenuItem cbMenuItem; // Create the menu bar. menuBar = new JMenuBar(); // Build the first menu. menu = new JMenu("A Menu"); menu.setMnemonic(KeyEvent.VK_A); menu.getAccessibleContext() .setAccessibleDescription("The only menu in this program that has menu items"); menuBar.add(menu); // a group of JMenuItems menuItem = new JMenuItem("A text-only menu item", KeyEvent.VK_T); // menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("This doesn't really do anything"); menuItem.addActionListener(this); menu.add(menuItem); ImageIcon icon = createImageIcon("images/middle.gif"); menuItem = new JMenuItem("Both text and icon", icon); menuItem.setMnemonic(KeyEvent.VK_B); menuItem.addActionListener(this); menu.add(menuItem); menuItem = new JMenuItem(icon); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.addActionListener(this); menu.add(menuItem); // a group of radio button menu items menu.addSeparator(); ButtonGroup group = new ButtonGroup(); rbMenuItem = new JRadioButtonMenuItem("A radio button menu item"); rbMenuItem.setSelected(true); rbMenuItem.setMnemonic(KeyEvent.VK_R); group.add(rbMenuItem); rbMenuItem.addActionListener(this); menu.add(rbMenuItem); rbMenuItem = new JRadioButtonMenuItem("Another one"); rbMenuItem.setMnemonic(KeyEvent.VK_O); group.add(rbMenuItem); rbMenuItem.addActionListener(this); menu.add(rbMenuItem); // a group of check box menu items menu.addSeparator(); cbMenuItem = new JCheckBoxMenuItem("A check box menu item"); cbMenuItem.setMnemonic(KeyEvent.VK_C); cbMenuItem.addItemListener(this); menu.add(cbMenuItem); cbMenuItem = new JCheckBoxMenuItem("Another one"); cbMenuItem.setMnemonic(KeyEvent.VK_H); cbMenuItem.addItemListener(this); menu.add(cbMenuItem); // a submenu menu.addSeparator(); submenu = new JMenu("A submenu"); submenu.setMnemonic(KeyEvent.VK_S); menuItem = new JMenuItem("An item in the submenu"); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, ActionEvent.ALT_MASK)); menuItem.addActionListener(this); submenu.add(menuItem); menuItem = new JMenuItem("Another item"); menuItem.addActionListener(this); submenu.add(menuItem); menu.add(submenu); // Build second menu in the menu bar. menu = new JMenu("Another Menu"); menu.setMnemonic(KeyEvent.VK_N); menu.getAccessibleContext().setAccessibleDescription("This menu does nothing"); menuBar.add(menu); return menuBar; }
/** Adds the menu items to the menuber. */ protected void arrangeMenu() { // Build the first menu. fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); menuBar.add(fileMenu); viewMenu = new JMenu("View"); viewMenu.setMnemonic(KeyEvent.VK_V); menuBar.add(viewMenu); runMenu = new JMenu("Run"); runMenu.setMnemonic(KeyEvent.VK_R); menuBar.add(runMenu); // Build the second menu. helpMenu = new JMenu("Help"); helpMenu.setMnemonic(KeyEvent.VK_H); menuBar.add(helpMenu); programMenuItem = new JMenuItem("Load Program", KeyEvent.VK_O); programMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { programMenuItem_actionPerformed(); } }); fileMenu.add(programMenuItem); scriptMenuItem = new JMenuItem("Load Script", KeyEvent.VK_P); scriptMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { scriptMenuItem_actionPerformed(); } }); fileMenu.add(scriptMenuItem); fileMenu.addSeparator(); exitMenuItem = new JMenuItem("Exit", KeyEvent.VK_X); exitMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.ALT_MASK)); exitMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { exitMenuItem_actionPerformed(); } }); fileMenu.add(exitMenuItem); viewMenu.addSeparator(); ButtonGroup animationRadioButtons = new ButtonGroup(); animationSubMenu = new JMenu("Animate"); animationSubMenu.setMnemonic(KeyEvent.VK_A); viewMenu.add(animationSubMenu); partAnimMenuItem = new JRadioButtonMenuItem("Program flow"); partAnimMenuItem.setMnemonic(KeyEvent.VK_P); partAnimMenuItem.setSelected(true); partAnimMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { partAnimMenuItem_actionPerformed(); } }); animationRadioButtons.add(partAnimMenuItem); animationSubMenu.add(partAnimMenuItem); fullAnimMenuItem = new JRadioButtonMenuItem("Program & data flow"); fullAnimMenuItem.setMnemonic(KeyEvent.VK_D); fullAnimMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { fullAnimMenuItem_actionPerformed(); } }); animationRadioButtons.add(fullAnimMenuItem); animationSubMenu.add(fullAnimMenuItem); noAnimMenuItem = new JRadioButtonMenuItem("No Animation"); noAnimMenuItem.setMnemonic(KeyEvent.VK_N); noAnimMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { noAnimMenuItem_actionPerformed(); } }); animationRadioButtons.add(noAnimMenuItem); animationSubMenu.add(noAnimMenuItem); ButtonGroup additionalDisplayRadioButtons = new ButtonGroup(); additionalDisplaySubMenu = new JMenu("View"); additionalDisplaySubMenu.setMnemonic(KeyEvent.VK_V); viewMenu.add(additionalDisplaySubMenu); scriptDisplayMenuItem = new JRadioButtonMenuItem("Script"); scriptDisplayMenuItem.setMnemonic(KeyEvent.VK_S); scriptDisplayMenuItem.setSelected(true); scriptDisplayMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { scriptDisplayMenuItem_actionPerformed(); } }); additionalDisplayRadioButtons.add(scriptDisplayMenuItem); additionalDisplaySubMenu.add(scriptDisplayMenuItem); outputMenuItem = new JRadioButtonMenuItem("Output"); outputMenuItem.setMnemonic(KeyEvent.VK_O); outputMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { outputMenuItem_actionPerformed(); } }); additionalDisplayRadioButtons.add(outputMenuItem); additionalDisplaySubMenu.add(outputMenuItem); compareMenuItem = new JRadioButtonMenuItem("Compare"); compareMenuItem.setMnemonic(KeyEvent.VK_C); compareMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { compareMenuItem_actionPerformed(); } }); additionalDisplayRadioButtons.add(compareMenuItem); additionalDisplaySubMenu.add(compareMenuItem); noAdditionalDisplayMenuItem = new JRadioButtonMenuItem("Screen"); noAdditionalDisplayMenuItem.setMnemonic(KeyEvent.VK_N); noAdditionalDisplayMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { noAdditionalDisplayMenuItem_actionPerformed(); } }); additionalDisplayRadioButtons.add(noAdditionalDisplayMenuItem); additionalDisplaySubMenu.add(noAdditionalDisplayMenuItem); ButtonGroup formatRadioButtons = new ButtonGroup(); numericFormatSubMenu = new JMenu("Format"); numericFormatSubMenu.setMnemonic(KeyEvent.VK_F); viewMenu.add(numericFormatSubMenu); decMenuItem = new JRadioButtonMenuItem("Decimal"); decMenuItem.setMnemonic(KeyEvent.VK_D); decMenuItem.setSelected(true); decMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { decMenuItem_actionPerformed(); } }); formatRadioButtons.add(decMenuItem); numericFormatSubMenu.add(decMenuItem); hexaMenuItem = new JRadioButtonMenuItem("Hexadecimal"); hexaMenuItem.setMnemonic(KeyEvent.VK_H); hexaMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { hexaMenuItem_actionPerformed(); } }); formatRadioButtons.add(hexaMenuItem); numericFormatSubMenu.add(hexaMenuItem); binMenuItem = new JRadioButtonMenuItem("Binary"); binMenuItem.setMnemonic(KeyEvent.VK_B); binMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { binMenuItem_actionPerformed(); } }); formatRadioButtons.add(binMenuItem); numericFormatSubMenu.add(binMenuItem); viewMenu.addSeparator(); singleStepMenuItem = new JMenuItem("Single Step", KeyEvent.VK_S); singleStepMenuItem.setAccelerator(KeyStroke.getKeyStroke("F11")); singleStepMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { singleStepMenuItem_actionPerformed(); } }); runMenu.add(singleStepMenuItem); ffwdMenuItem = new JMenuItem("Run", KeyEvent.VK_F); ffwdMenuItem.setAccelerator(KeyStroke.getKeyStroke("F5")); ffwdMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { ffwdMenuItem_actionPerformed(); } }); runMenu.add(ffwdMenuItem); stopMenuItem = new JMenuItem("Stop", KeyEvent.VK_T); stopMenuItem.setAccelerator(KeyStroke.getKeyStroke("shift F5")); stopMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { stopMenuItem_actionPerformed(); } }); runMenu.add(stopMenuItem); rewindMenuItem = new JMenuItem("Reset", KeyEvent.VK_R); rewindMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { rewindMenuItem_actionPerformed(); } }); runMenu.add(rewindMenuItem); runMenu.addSeparator(); breakpointsMenuItem = new JMenuItem("Breakpoints", KeyEvent.VK_B); breakpointsMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { breakpointsMenuItem_actionPerformed(); } }); runMenu.add(breakpointsMenuItem); profilerMenuItem = new JMenuItem("Profiler", KeyEvent.VK_I); profilerMenuItem.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showProfiler(); } }); profilerMenuItem.setEnabled(false); runMenu.add(profilerMenuItem); usageMenuItem = new JMenuItem("Usage", KeyEvent.VK_U); usageMenuItem.setAccelerator(KeyStroke.getKeyStroke("F1")); usageMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { usageMenuItem_actionPerformed(); } }); helpMenu.add(usageMenuItem); aboutMenuItem = new JMenuItem("About ...", KeyEvent.VK_A); aboutMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { aboutMenuItem_actionPerformed(); } }); helpMenu.add(aboutMenuItem); }
private void createControllers() { selected = IShapeNode.FILL_DEF_COL; this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fichier.setMnemonic(KeyEvent.VK_F); noeuds.setMnemonic(KeyEvent.VK_N); paires.setMnemonic(KeyEvent.VK_P); couleurs.setMnemonic(KeyEvent.VK_C); // quitter quit.setMnemonic(KeyEvent.VK_R); quit.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }); // ajouter un noeud creerNoeuds.setMnemonic(KeyEvent.VK_A); creerNoeuds.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { creerNoeuds.setSelected(!creerNoeuds.isSelected()); neutrePaires.setSelected(true); } }); ggp.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (creerNoeuds.isSelected()) { String nom = JOptionPane.showInputDialog( null, "", "Nommer du noeud", JOptionPane.QUESTION_MESSAGE); if (nom != null) { IShapeNode n = null; // FIXME modifier pour généraliser à plusieurs formes if (circle.isSelected()) { n = new CircleNode(nom, true, selected); } if (rectangle.isSelected()) { n = new RectangleNode(nom, true, selected); } if (simple.isSelected()) { n = new RectangleNode(nom, false, selected); } if (n != null) { n.setPosition(e.getPoint()); ggp.addNode(n); } } } } }); // supprimer un noeud supprimerNoeuds.setMnemonic(KeyEvent.VK_S); supprimerNoeuds.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { supprimerNoeuds.setSelected(!supprimerNoeuds.isSelected()); neutrePaires.setSelected(true); } }); ggp.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (supprimerNoeuds.isSelected()) { // TODO } } }); // ne rien faire des noeuds neutreNoeuds.setMnemonic(KeyEvent.VK_E); neutreNoeuds.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { neutreNoeuds.setSelected(!neutreNoeuds.isSelected()); } }); ggp.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (neutreNoeuds.isSelected()) { // TODO } } }); // créer une paire creerPaires.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { creerPaires.setSelected(true); neutreNoeuds.setSelected(true); } }); ggp.addMouseListener( new MouseAdapter() { IShapeNode select = null; @Override public void mouseClicked(MouseEvent e) { if (creerPaires.isSelected()) { if (ggp.selectedNodes.size() == 1) { if (select != null) { String nom = JOptionPane.showInputDialog( null, "", "Nommer l'arc", JOptionPane.QUESTION_MESSAGE); if (nom != null) { Color col = selected.col(); ; if (selected.equals(ColorSetting.WHITE)) { col = ColorSetting.BLACK.col(); } ggp.addEdge( new DirectEdge( select, (IShapeNode) ggp.selectedNodes.toArray()[0], nom, col)); select = null; } } else select = (IShapeNode) ggp.selectedNodes.toArray()[0]; } } } }); // supprimer des paires supprimerPaires.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { supprimerPaires.setSelected(true); neutreNoeuds.setSelected(true); } }); neutrePaires.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { neutrePaires.setSelected(true); } }); // couleurs for (JRadioButtonMenuItem c : colors) { c.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent a) { selected = mapcol.get(a.getSource()); } }); } // imprime dans l'output une sortie latex latex.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // System.out.println(ggp.latex()); output.setText(ggp.latex()); } }); // vide le panel clear.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { ggp.setModel(new Graphe<IArc>(IArc.class)); output.setText(""); } }); // créer une image à partir d'une compilation latex image.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { JFileChooser fc = new JFileChooser(); int returnVal = fc.showSaveDialog(Appli.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); StringBuffer sb = new StringBuffer("\\documentclass{beamer}\n"); sb.append("\\usepackage{tikz}\n"); sb.append("\\setbeamertemplate{navigation symbols}{}\n"); sb.append("\\begin{document}\n"); sb.append("\\begin{center}\n"); sb.append("\\ \\\\ \n"); sb.append(ggp.latex()); sb.append("\\end{center}\n"); sb.append("\\end{document}\n"); try { BufferedWriter bw = new BufferedWriter(new FileWriter(file)); bw.write(sb.toString()); bw.flush(); bw.close(); Runtime r = Runtime.getRuntime(); Process p; try { p = r.exec("mkdir tmp"); p.waitFor(); p = r.exec( "/usr/texbin/pdflatex -output-directory ./tmp " + file.getAbsolutePath()); p.waitFor(); p = r.exec("mv ./tmp/" + file.getName() + ".pdf " + "file.pdf"); p.waitFor(); p = r.exec("sh sc.sh"); // p.waitFor(); // p = r.exec("ls"); int c = p.getInputStream().read(); while (c != -1) { System.out.print((char) c); c = p.getInputStream().read(); } } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } // System.out.println("mv ./tmp/" + file.getName() + ".pdf file.pdf"); // r.exec("rm -r tmp"); } catch (IOException e) { e.printStackTrace(); } } } }); }