/* * Copyright (C) 2014 Vinu K.N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.domainmath.gui.preferences; import java.awt.Font; import java.io.File; import java.util.prefs.Preferences; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; import org.domainmath.gui.MainFrame; import org.domainmath.gui.Util.DomainMathFileFilter; import org.domainmath.gui.common.FontDialog; /** * * @author Vinu K.N */ public class PreferencesDlg extends javax.swing.JDialog { private final MainFrame frame; private Settings settings; /** Creates new form PreferencesDlg */ public PreferencesDlg(MainFrame frame, boolean modal) { super(frame, modal); initComponents(); this.frame = frame; // in order to run GNU Octave smoothly we should use --interactive and // --traditional. cmdLinField.setText("--interactive --no-history --traditional"); // fltk and qt graphics_toolkit are not supported. startupCmdField.setText("graphics_toolkit gnuplot;"); // load all settings from the file user_dir/settings.xml . try { settings = loadSettingsPref(); } catch (JAXBException ex) { settings = new Settings(); } setPath(); setCmdLineOptions(); setStartupCmd(); setClearTextOption(); setSelectedConsoleFontText(); setSelectedScriptFontText(); setExitConfirmation(); } private void setSelectedConsoleFontText() { this.consoleFontTextField.setText(this.getConsoleFont().getFontName()+","+this.getConsoleFont().getSize()); } private void setSelectedScriptFontText() { this.scriptFontTextField.setText(this.getScriptFont().getFontName()+","+this.getScriptFont().getSize()); } private void setPath() { String path =settings.getOctavePath(); try { if(path != null) { pathField.setText(path); } else { pathField.setText(""); } }catch(Exception e) { pathField.setText(""); } } private void setCmdLineOptions() { String path =settings.getOctaveCommandLineOptions(); try { if(path != null ) { this.cmdLinField.setText(path); } else { cmdLinField.setText("--interactive --no-history --traditional"); } }catch(Exception e) { cmdLinField.setText("--interactive --no-history --traditional"); } } private void setStartupCmd() { String path =settings.getOctaveStartUpCommands(); try { if(path != null ) { this.startupCmdField.setText(path); } else { this.startupCmdField.setText("graphics_toolkit gnuplot;"); } }catch(Exception e) { this.startupCmdField.setText("graphics_toolkit gnuplot;"); } } /** 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() { cancelButton = new javax.swing.JButton(); okButton = new javax.swing.JButton(); jTabbedPane1 = new javax.swing.JTabbedPane(); jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); pathField = new javax.swing.JTextField(); browseButton = new javax.swing.JButton(); jLabel3 = new javax.swing.JLabel(); cmdLinField = new javax.swing.JTextField(); startupCmdField = new javax.swing.JTextField(); jLabel2 = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); clearRadioButton = new javax.swing.JRadioButton(); jLabel4 = new javax.swing.JLabel(); consoleFontTextField = new javax.swing.JTextField(); chooseFontButton = new javax.swing.JButton(); jPanel3 = new javax.swing.JPanel(); jLabel5 = new javax.swing.JLabel(); scriptFontTextField = new javax.swing.JTextField(); jButton2 = new javax.swing.JButton(); jPanel4 = new javax.swing.JPanel(); exitConfirmationCheckBox = new javax.swing.JCheckBox(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/domainmath/gui/preferences/resources/preferences_en"); // NOI18N setTitle(bundle.getString("Dialog.title")); // NOI18N cancelButton.setMnemonic(java.util.ResourceBundle.getBundle("org/domainmath/gui/preferences/resources/preferences_en").getString("cancelButton.mnemonic").charAt(0)); cancelButton.setText(bundle.getString("cancelButton.title")); // NOI18N cancelButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cancelButtonActionPerformed(evt); } }); okButton.setMnemonic(java.util.ResourceBundle.getBundle("org/domainmath/gui/preferences/resources/preferences_en").getString("okButton.mnemonic").charAt(0)); okButton.setText(bundle.getString("okButton.title")); // NOI18N okButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { okButtonActionPerformed(evt); } }); jLabel1.setText(bundle.getString("label.title")); // NOI18N pathField.setToolTipText("If you are using Octave 3.7.2+, choose octave-cli.exe or octave-cli-3.7.2+.exe. Do not choose octave.exe or octave3.7.2+"); browseButton.setMnemonic(java.util.ResourceBundle.getBundle("org/domainmath/gui/preferences/resources/preferences_en").getString("browseButton.mnemonic").charAt(0)); browseButton.setText(bundle.getString("browseButton.title")); // NOI18N browseButton.setToolTipText("If you are using Octave 3.7.2+, choose octave-cli.exe or octave-cli-3.7.2+.exe. Do not choose octave.exe or octave3.7.2+"); browseButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { browseButtonActionPerformed(evt); } }); jLabel3.setText(bundle.getString("commandLine.title")); // NOI18N cmdLinField.setText("--interactive"); jLabel2.setText(bundle.getString("startuplabel.title")); // NOI18N javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel2) .addGap(0, 340, Short.MAX_VALUE)) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(10, 10, 10) .addComponent(cmdLinField)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(browseButton, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(startupCmdField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 427, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addContainerGap()) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(10, 10, 10) .addComponent(pathField, javax.swing.GroupLayout.PREFERRED_SIZE, 348, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jLabel1)) .addContainerGap(56, Short.MAX_VALUE))) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel3) .addContainerGap(332, Short.MAX_VALUE))) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addGap(46, 46, 46) .addComponent(browseButton) .addGap(45, 45, 45) .addComponent(cmdLinField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(36, 36, 36) .addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(startupCmdField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(182, Short.MAX_VALUE)) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(28, 28, 28) .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(pathField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(324, Short.MAX_VALUE))) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(95, 95, 95) .addComponent(jLabel3) .addContainerGap(283, Short.MAX_VALUE))) ); jTabbedPane1.addTab("Octave", jPanel1); clearRadioButton.setSelected(true); clearRadioButton.setText("Clear text after pressing Enter key"); jLabel4.setText("Font:"); consoleFontTextField.setEditable(false); chooseFontButton.setText("Choose"); chooseFontButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { chooseFontButtonActionPerformed(evt); } }); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addComponent(clearRadioButton) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(jPanel2Layout.createSequentialGroup() .addComponent(jLabel4) .addGap(18, 18, 18) .addComponent(consoleFontTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 294, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 28, Short.MAX_VALUE) .addComponent(chooseFontButton))) .addContainerGap()) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(24, 24, 24) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4) .addComponent(consoleFontTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(chooseFontButton)) .addGap(18, 18, 18) .addComponent(clearRadioButton) .addContainerGap(304, Short.MAX_VALUE)) ); jTabbedPane1.addTab("Console", jPanel2); jLabel5.setText("Font:"); scriptFontTextField.setEditable(false); jButton2.setText("Choose"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel5) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(scriptFontTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 301, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 29, Short.MAX_VALUE) .addComponent(jButton2) .addContainerGap()) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addGap(24, 24, 24) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel5) .addComponent(scriptFontTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton2)) .addContainerGap(345, Short.MAX_VALUE)) ); jTabbedPane1.addTab("Script Editor", jPanel3); exitConfirmationCheckBox.setLabel("Exit without confirmation"); javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addContainerGap() .addComponent(exitConfirmationCheckBox) .addContainerGap(335, Short.MAX_VALUE)) ); jPanel4Layout.setVerticalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addGap(24, 24, 24) .addComponent(exitConfirmationCheckBox) .addContainerGap(347, Short.MAX_VALUE)) ); jTabbedPane1.addTab("Window", jPanel4); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent(okButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(cancelButton)) .addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.TRAILING)) .addContainerGap()) ); layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {cancelButton, okButton}); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jTabbedPane1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cancelButton) .addComponent(okButton)) .addContainerGap()) ); layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {cancelButton, okButton}); pack(); }// </editor-fold>//GEN-END:initComponents private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File(System.getProperty("user.dir")+File.separator+"works")); fc.setFileFilter(DomainMathFileFilter.EXE_FILE_FILTER); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setMultiSelectionEnabled(false); File file = null; int returnVal = fc.showOpenDialog(frame); if (returnVal == JFileChooser.APPROVE_OPTION) { file = fc.getSelectedFile(); pathField.setText(file.getAbsolutePath()); } }//GEN-LAST:event_browseButtonActionPerformed private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed dispose(); }//GEN-LAST:event_cancelButtonActionPerformed /** * Returns GNU Octave installation path. * @return GNU Octave installation path */ public String getPath() { return settings.getOctavePath(); } /** * Returns command line options of GNU Octave, default is --interactive --no-history --traditional. * @return Command line options of GNU Octave */ public String getCmdLineOptions() { if(settings.getOctaveCommandLineOptions() != null) { return settings.getOctaveCommandLineOptions(); }else{ return "--interactive --no-history --traditional"; } } /** * Returns user defined commands in order to run after starting GNU Octave. Default * is null. * @return User defined commands or null */ public String getStartupCmd() { if(settings.getOctaveStartUpCommands() != null) { return settings.getOctaveStartUpCommands(); }else{ return ""; } } /** * Returns true if user checked in checkbox 'Clear text after pressing Enter key' * @return true */ public boolean wantedToClearText() { Preferences pr = Preferences.userNodeForPackage(frame.getClass()); return pr.getBoolean("Clear_Text", rootPaneCheckingEnabled); } /** * Performs okButton action and save edited settings. * @param evt */ private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed Preferences pr = Preferences.userNodeForPackage(frame.getClass()); // get previous settings. String path = pathField.getText(); String startup= this.startupCmdField.getText(); String cmdline = this.cmdLinField.getText(); if(!startup.equals("")) { settings.setOctaveStartUpCommands(startup); } // octave path must be a valid path. if(!path.equals("")) { settings.setOctavePath(path); }else { JOptionPane.showMessageDialog(frame, "Please choose Octave path.","Error",JOptionPane.ERROR_MESSAGE); } if(!cmdline.equals("")) { settings.setOctaveCommandLineOptions(cmdline); }else { settings.setOctaveCommandLineOptions("--interactive --traditional"); this.cmdLinField.setText("--interactive --traditional"); } this.saveSettingsPref(settings); pr.putBoolean("Clear_Text", this.clearRadioButton.isSelected()); pr.putBoolean("skip_confirmation", this.exitConfirmationCheckBox.isSelected()); JOptionPane.showMessageDialog(frame, "Please restart DomainMath to take the changes effect.","Information",JOptionPane.INFORMATION_MESSAGE); dispose(); }//GEN-LAST:event_okButtonActionPerformed private void chooseFontButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chooseFontButtonActionPerformed FontDialog fontDialog = new FontDialog(frame,true); fontDialog.setLocationRelativeTo(this); fontDialog.setVisible(true); storeFont("DomainMath_Console_Font",fontDialog.getSelectedFont()); String font=fontDialog.getSelectedFont().getFontName()+","+fontDialog.getSelectedFont().getSize(); this.consoleFontTextField.setText(font); }//GEN-LAST:event_chooseFontButtonActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed FontDialog fontDialog = new FontDialog(frame,true); fontDialog.setLocationRelativeTo(this); fontDialog.setVisible(true); storeFont("DomainMath_ScriptEditor_Font",fontDialog.getSelectedFont()); String font=fontDialog.getSelectedFont().getFontName()+","+fontDialog.getSelectedFont().getSize(); this.scriptFontTextField.setText(font); }//GEN-LAST:event_jButton2ActionPerformed /** * @param args the command line arguments */ // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton browseButton; private javax.swing.JButton cancelButton; private javax.swing.JButton chooseFontButton; private javax.swing.JRadioButton clearRadioButton; private javax.swing.JTextField cmdLinField; private javax.swing.JTextField consoleFontTextField; private javax.swing.JCheckBox exitConfirmationCheckBox; private javax.swing.JButton jButton2; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JTabbedPane jTabbedPane1; private javax.swing.JButton okButton; private javax.swing.JTextField pathField; private javax.swing.JTextField scriptFontTextField; private javax.swing.JTextField startupCmdField; // End of variables declaration//GEN-END:variables private void setClearTextOption() { Preferences pr = Preferences.userNodeForPackage(frame.getClass()); boolean path =pr.getBoolean("Clear_Text", true); this.clearRadioButton.setSelected(path); } private void setExitConfirmation() { Preferences pr = Preferences.userNodeForPackage(frame.getClass()); boolean skip = pr.getBoolean("skip_confirmation", false); this.exitConfirmationCheckBox.setSelected(skip); } public Font getConsoleFont(){ Preferences pr = Preferences.userNodeForPackage(frame.getClass()); return new Font(pr.get("DomainMath_Console_Font.name", "Monospaced"), pr.getInt("DomainMath_Console_Font.style", Font.PLAIN), pr.getInt("DomainMath_Console_Font.size", 13)); } public Font getScriptFont(){ Preferences pr = Preferences.userNodeForPackage(frame.getClass()); return new Font(pr.get("DomainMath_ScriptEditor_Font.name", "Monospaced"), pr.getInt("DomainMath_ScriptEditor_Font.style", Font.PLAIN), pr.getInt("DomainMath_ScriptEditor_Font.size", 13)); } private void storeFont(String font, Font selectedFont) { Preferences pr = Preferences.userNodeForPackage(frame.getClass()); pr.put(font+".name", selectedFont.getFontName()); pr.putInt(font+".style", selectedFont.getStyle()); pr.putInt(font+".size", selectedFont.getSize()); } /** * Save Settings object r to a file. Usually Settings saved in user_dir/settings.xml * @param r */ private void saveSettingsPref(Settings r) { try { File file = new File(System.getProperty("user.dir")+File.separator+"settings.xml"); JAXBContext jaxbContext = JAXBContext.newInstance(Settings.class); Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); jaxbMarshaller.marshal(r, file); jaxbMarshaller.marshal(r, System.out); } catch (JAXBException e) { } } /** * Loads saved DMI settings. Usually the saved settings will be stored in a * file user_dir/settings.xml. * @return an object of Settings * @throws JAXBException */ private Settings loadSettingsPref() throws JAXBException { File file = new File(System.getProperty("user.dir")+File.separator+"settings.xml"); JAXBContext jaxbContext = JAXBContext.newInstance(Settings.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); Settings j = (Settings) jaxbUnmarshaller.unmarshal(file); return j; } }