Sample

Schnappinger/diarymanagement/TBA.Client.GUI.SettingsDialog

Human rating uses the original dataset scale.

Human3
Lines740

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
4.5Δ 22.9
Scalabrino0.7390–1; higher is more readable
46.2Δ 18.8
Dorn00–1; higher is more readable
6.6Δ 20.8
Mi0.040–1; higher is more readable
5.3Δ 22.1
LLOC291Logical lines; fewer is more readable
7.3Δ 20.1
DeepSeek V4 Pro6.330–20; mean of three runs
3.0Δ 24.4
GPT-6.1 Sol10.330–20; mean of three runs
2.0Δ 25.4
BTTF0.2390–1; higher is more readable
15.2Δ 12.2
Human31–4; original rating
27.4

Views

Source code

/* * * * Created on 15/10/2009, 11:04:35 */ package TBA.Client.GUI; import TBA.Sounds.SoundResources; import javax.swing.JFileChooser; import java.io.*; import javax.swing.ComboBoxModel; import java.util.Vector; import TBA.MouseGestures.GesturesResource; import java.util.logging.Logger; /** * This Class is the GUI dealing with editing program settings * @author Charles Jap */ public class SettingsDialog extends javax.swing.JDialog { private SoundResources soundResources; private GesturesResource gesturesResources; private boolean isNowMute=false; //default private String nowLocation="defaultNow.wav"; private String user = new String(); private String server="localhost"; //default private int port=9999;// default private final static Logger LOGIT = Logger.getLogger(SettingsDialog.class.getName()); //default gestures logon add entry settings private String[] names = {"Shake Sideways", "Clockwise", "Anti-Clockwise"}; //all the available gestures including unassigned private String[] methods = {"Shake Sideways", "Clockwise", "Anti-Clockwise", "Up and Shake", "Down and Shake", "Disabled"}; //holds unassigned gestures users can choose Vector<String> options = new Vector<String>(); /** * This function is a setter to pass down the soundfile, so the actual * sound files can be changed * @param soundResources - set and passed from mainclientview */ public void setSoundResources(SoundResources soundResources) { this.soundResources = soundResources; } /** Creates new form SettingsDialog * @param parent * @param modal * @param soundResources - passed down from mainclient gui */ public SettingsDialog(java.awt.Frame parent, boolean modal, SoundResources soundResources) { super(parent, modal); addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent e) { setVisible(false); } }); initComponents(); } /** 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() { jPanel8 = new javax.swing.JPanel(); jTabbedPane1 = new javax.swing.JTabbedPane(); GeneralPanelTab = new javax.swing.JPanel(); SoundPanel = new javax.swing.JPanel(); txtNowAlert = new javax.swing.JTextField(); btnNowBrowse = new javax.swing.JButton(); chkNowtAlert = new javax.swing.JCheckBox(); GesturePanel = new javax.swing.JPanel(); jLabel6 = new javax.swing.JLabel(); comboName = new javax.swing.JComboBox(); jLabel8 = new javax.swing.JLabel(); comboGesture = new javax.swing.JComboBox(); jPanel12 = new javax.swing.JPanel(); ConnectionPanelTab = new javax.swing.JPanel(); LogonPanel = new javax.swing.JPanel(); jLabel4 = new javax.swing.JLabel(); txtUser = new javax.swing.JTextField(); ServerPanel = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); txtServer = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); txtPort = new javax.swing.JTextField(); btnOK = new javax.swing.JButton(); jbCancel = new javax.swing.JButton(); javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8); jPanel8.setLayout(jPanel8Layout); jPanel8Layout.setHorizontalGroup( jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 100, Short.MAX_VALUE) ); jPanel8Layout.setVerticalGroup( jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 100, Short.MAX_VALUE) ); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Settings"); setName("SettingsDialog"); // NOI18N SoundPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Sounds")); btnNowBrowse.setText("Browse"); btnNowBrowse.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnNowBrowseActionPerformed(evt); } }); chkNowtAlert.setText("Mute when meeting is now alert"); chkNowtAlert.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { chkNowtAlertActionPerformed(evt); } }); javax.swing.GroupLayout SoundPanelLayout = new javax.swing.GroupLayout(SoundPanel); SoundPanel.setLayout(SoundPanelLayout); SoundPanelLayout.setHorizontalGroup( SoundPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(SoundPanelLayout.createSequentialGroup() .addContainerGap() .addGroup(SoundPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(chkNowtAlert) .addGroup(SoundPanelLayout.createSequentialGroup() .addComponent(txtNowAlert, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnNowBrowse, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(218, Short.MAX_VALUE)) ); SoundPanelLayout.setVerticalGroup( SoundPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(SoundPanelLayout.createSequentialGroup() .addComponent(chkNowtAlert) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(SoundPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txtNowAlert, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnNowBrowse, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); txtNowAlert.setText(nowLocation); GesturePanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Gestures")); jLabel6.setText("Name"); comboName.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Login", "Add Entry", "Preferences" })); comboName.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { comboNameActionPerformed(evt); } }); jLabel8.setText("Gesture"); options.add(names[comboName.getSelectedIndex()]); fillComboMethods(); jPanel12.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12); jPanel12.setLayout(jPanel12Layout); jPanel12Layout.setHorizontalGroup( jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 114, Short.MAX_VALUE) ); jPanel12Layout.setVerticalGroup( jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 109, Short.MAX_VALUE) ); javax.swing.GroupLayout GesturePanelLayout = new javax.swing.GroupLayout(GesturePanel); GesturePanel.setLayout(GesturePanelLayout); GesturePanelLayout.setHorizontalGroup( GesturePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(GesturePanelLayout.createSequentialGroup() .addContainerGap() .addGroup(GesturePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(comboName, 0, 163, Short.MAX_VALUE) .addComponent(jLabel6) .addComponent(jLabel8) .addComponent(comboGesture, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 183, Short.MAX_VALUE) .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); GesturePanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {comboGesture, comboName}); GesturePanelLayout.setVerticalGroup( GesturePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(GesturePanelLayout.createSequentialGroup() .addGroup(GesturePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(GesturePanelLayout.createSequentialGroup() .addComponent(jLabel6) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(comboName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel8) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(comboGesture, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); javax.swing.GroupLayout GeneralPanelTabLayout = new javax.swing.GroupLayout(GeneralPanelTab); GeneralPanelTab.setLayout(GeneralPanelTabLayout); GeneralPanelTabLayout.setHorizontalGroup( GeneralPanelTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(GeneralPanelTabLayout.createSequentialGroup() .addContainerGap() .addGroup(GeneralPanelTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(GesturePanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(SoundPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) ); GeneralPanelTabLayout.setVerticalGroup( GeneralPanelTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(GeneralPanelTabLayout.createSequentialGroup() .addContainerGap() .addComponent(SoundPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(GesturePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); jTabbedPane1.addTab("General", GeneralPanelTab); LogonPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Default Logon Details")); jLabel4.setText("Username"); javax.swing.GroupLayout LogonPanelLayout = new javax.swing.GroupLayout(LogonPanel); LogonPanel.setLayout(LogonPanelLayout); LogonPanelLayout.setHorizontalGroup( LogonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(LogonPanelLayout.createSequentialGroup() .addContainerGap() .addGroup(LogonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(txtUser, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE) .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING)) .addContainerGap(280, Short.MAX_VALUE)) ); LogonPanelLayout.setVerticalGroup( LogonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(LogonPanelLayout.createSequentialGroup() .addComponent(jLabel4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtUser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); ServerPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Default Server Details")); jLabel2.setText("Server"); jLabel3.setText("Port"); javax.swing.GroupLayout ServerPanelLayout = new javax.swing.GroupLayout(ServerPanel); ServerPanel.setLayout(ServerPanelLayout); ServerPanelLayout.setHorizontalGroup( ServerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(ServerPanelLayout.createSequentialGroup() .addContainerGap() .addGroup(ServerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2) .addComponent(jLabel3) .addGroup(ServerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(txtPort, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txtServer, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE))) .addContainerGap(280, Short.MAX_VALUE)) ); ServerPanelLayout.setVerticalGroup( ServerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(ServerPanelLayout.createSequentialGroup() .addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtServer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(32, Short.MAX_VALUE)) ); txtServer.setText(server); txtPort.setText(Integer.toString(port)); javax.swing.GroupLayout ConnectionPanelTabLayout = new javax.swing.GroupLayout(ConnectionPanelTab); ConnectionPanelTab.setLayout(ConnectionPanelTabLayout); ConnectionPanelTabLayout.setHorizontalGroup( ConnectionPanelTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(ConnectionPanelTabLayout.createSequentialGroup() .addContainerGap() .addGroup(ConnectionPanelTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(LogonPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(ServerPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) ); ConnectionPanelTabLayout.setVerticalGroup( ConnectionPanelTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(ConnectionPanelTabLayout.createSequentialGroup() .addContainerGap() .addComponent(LogonPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(ServerPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(26, Short.MAX_VALUE)) ); jTabbedPane1.addTab("Connection", ConnectionPanelTab); btnOK.setText("OK"); btnOK.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnOKActionPerformed(evt); } }); jbCancel.setText("Cancel"); jbCancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbCancelActionPerformed(evt); } }); 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(395, Short.MAX_VALUE) .addComponent(btnOK) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jbCancel) .addContainerGap()) .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 523, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jTabbedPane1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jbCancel) .addComponent(btnOK)) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents private void jbCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbCancelActionPerformed // TODO add your handling code here: this.setVisible(false); }//GEN-LAST:event_jbCancelActionPerformed private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed user = txtUser.getText(); server = txtServer.getText(); port = Integer.parseInt(txtPort.getText()); ComboBoxModel cbmMethod = comboGesture.getModel(); switch(comboName.getSelectedIndex()) { case 0: // Log On names[0] = cbmMethod.getSelectedItem().toString(); break; case 1: // Add Entry names[1] = cbmMethod.getSelectedItem().toString(); break; case 2: // Open Settings Dialog names[2] = cbmMethod.getSelectedItem().toString(); break; case 3: break; case 4: break; } Update(); this.setVisible(false); }//GEN-LAST:event_btnOKActionPerformed private void comboNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboNameActionPerformed if (evt.getActionCommand().equals("comboBoxChanged")) { options.clear(); options.add(names[comboName.getSelectedIndex()]); fillComboMethods(); } }//GEN-LAST:event_comboNameActionPerformed private void chkNowtAlertActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkNowtAlertActionPerformed if(chkNowtAlert.isSelected()) { txtNowAlert.setEnabled(false); btnNowBrowse.setEnabled(false); } else { txtNowAlert.setEnabled(true); btnNowBrowse.setEnabled(true); } }//GEN-LAST:event_chkNowtAlertActionPerformed private void btnNowBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNowBrowseActionPerformed final JFileChooser fc = new JFileChooser(); fc.showOpenDialog(this); File selected = fc.getSelectedFile(); nowLocation = selected.getPath(); //newSound = fc.getName(selected); txtNowAlert.setText(nowLocation); }//GEN-LAST:event_btnNowBrowseActionPerformed private void fillComboMethods() { for(int x=0; x<5; x++) { boolean found = false; for(int y=0; y<3; y++) { if(methods[x].equalsIgnoreCase(names[y]) == true) { found = true; } } if (found == false) { options.add(methods[x]); } } options.add(methods[5]); ComboBoxModel cbmOptions = new javax.swing.DefaultComboBoxModel(options); comboGesture.setModel(cbmOptions); } /** * @param args the command line arguments */ public static void main(String args[]) { /*java.awt.EventQueue.invokeLater(new Runnable() { public void run() { SettingsDialog dialog = new SettingsDialog(new javax.swing.JFrame(), true); dialog.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { setVisible(false); } }); dialog.setVisible(true); } });*/ } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel ConnectionPanelTab; private javax.swing.JPanel GeneralPanelTab; private javax.swing.JPanel GesturePanel; private javax.swing.JPanel LogonPanel; private javax.swing.JPanel ServerPanel; private javax.swing.JPanel SoundPanel; private javax.swing.JButton btnNowBrowse; private javax.swing.JButton btnOK; private javax.swing.JCheckBox chkNowtAlert; private javax.swing.JComboBox comboGesture; private javax.swing.JComboBox comboName; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel8; private javax.swing.JPanel jPanel12; private javax.swing.JPanel jPanel8; private javax.swing.JTabbedPane jTabbedPane1; private javax.swing.JButton jbCancel; private javax.swing.JTextField txtNowAlert; private javax.swing.JTextField txtPort; private javax.swing.JTextField txtServer; private javax.swing.JTextField txtUser; // End of variables declaration//GEN-END:variables /** * This method reads from settings.ini and populates all the controls with it */ public void LoadSettings() { File file = new File("settings.ini"); if(file.exists()) { try { FileReader fstream = new FileReader("settings.ini"); BufferedReader in = new BufferedReader(fstream); String temp; temp = in.readLine(); //general line temp = in.readLine(); //sound line temp = in.readLine(); //now alert if(temp.equals("true")) { isNowMute = true; chkNowtAlert.setSelected(true); txtNowAlert.setEnabled(false); } temp = in.readLine(); //now alert location nowLocation = temp.substring(temp.indexOf("=")+1); txtNowAlert.setText(nowLocation); temp = in.readLine(); //gestures temp = in.readLine(); //logon names[0] = temp.substring(temp.indexOf("=")+1); temp = in.readLine(); //add new entry names[1] = temp.substring(temp.indexOf("=")+1); temp = in.readLine(); //settings names[2] = temp.substring(temp.indexOf("=")+1); options.clear(); options.add(names[comboName.getSelectedIndex()]); fillComboMethods(); temp = in.readLine(); //connection temp = in.readLine(); //user user = temp.substring(temp.indexOf("=")+1); txtUser.setText(user); temp = in.readLine(); //server server = temp.substring(temp.indexOf("=")+1); txtServer.setText(server); temp = in.readLine(); //port temp = temp.substring(temp.indexOf("=")+1); port = Integer.parseInt(temp); txtPort.setText(temp); in.close(); } catch (IOException e) { } } } /** * Getter for the port in the settings dialougue, this value is subservient * to its commandline counterpart - eg if there is a port provided in the * commandline, the main program will choose that over this * @return port field to be retrieved */ public int getPort() { return port; } /** * Setter for the port in the settings dialogue * @param port - new port to set to */ public void setPort(int port) { this.port = port; } /** * Getter for the server field in the settings dialogue, this value is subservient * to its commandline counterpart - eg if there is a server provided in the * commandline, the main program will choose that over this * @return server field to be retrieved */ public String getServer() { return server; } /** * Setter fo the server in the settings dialogue * @param server - new server to set to */ public void setServer(String server) { this.server = server; } /** * Getter for username if remembered by settings dialogue * @return user field */ public String getUser() { return user; } /** * Setter of the username if remembered by settings dialogue * @param user - to set to */ public void setUser(String user) { this.user = user; } /** * This method writes the values to file, and then recalls LoadSettings() * to make sure. */ public void Update() { try{ FileWriter fstream = new FileWriter("settings.ini"); BufferedWriter out = new BufferedWriter(fstream); //----------------to write-------------- //general tab out.write("General"); out.newLine(); out.write("Sound"); out.newLine(); out.write("NowAlertMuted=" + chkNowtAlert.isSelected()); out.newLine(); out.write("NowAlertLocation=" + txtNowAlert.getText()); out.newLine(); out.write("Gestures"); out.newLine(); out.write("Logon="+names[0]); out.newLine(); out.write("AddEntry="+names[1]); out.newLine(); out.write("Settings="+names[2]); out.newLine(); //connections tab out.write("Connection"); out.newLine(); out.write("User=" + user); out.newLine(); out.write("Server=" + server); out.newLine(); out.write("Port=" + Integer.toString(port)); out.newLine(); //---------------end write-------------- out.close(); }catch (Exception e){ LOGIT.severe("Error: " + e.getMessage()); } LoadSettings(); } /** * This method returns whether or not the user wishes there to be sound * @return true if sound is muted, false otherwise */ public boolean IsNowMute() { return isNowMute; } /** * Getter for the address of the path of the filename of the sound to be * played at each alert * @return nowLocation - location of sound to play */ public String getNowLocation() { return nowLocation; } /** * Setter of rht address of the path of the filename of the sound to be * played at each alert * @param nowLocation */ public void setNowLocation(String nowLocation) { this.nowLocation = nowLocation; } /** * This method returns the string containing the "gesuture" eg shake to a * corresponding method eg logon * name[0] corresponds to logon * name[1] corresponds to add new entry * name[2] corresponds to settings * @param gestureName * @return name[] - gesture coresponding to gestureName (method) eg shake */ public String getMethodName(String gestureName) { if(gestureName.equalsIgnoreCase("Logon")) { return names[0]; } else if(gestureName.equalsIgnoreCase("Add New Entry")) { return names[1]; } else if(gestureName.equalsIgnoreCase("Settings")) { return names[2]; } return ""; } /** * This is the setter to initialise the GestureResources which holds the * images for each gesture. * @param gesturesResources */ public void setGesturesResources(GesturesResource gesturesResources) { this.gesturesResources = gesturesResources; } }

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.37806.881−1247.627
Source linesThe number of non-empty source lines.740+296
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.4.817−7.225

Intercept 8.87 + feature contributions = -949.982 (log-odds).
Score = sigmoid(-949.982) = 0.

Score0.739

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.741−25.2
Indentation frequencyHow rapidly indentation changes from line to line.617+20.604
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.617−13.737
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.739.973+9.934
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.183.972−4.127
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.183.993+2.164
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.082+0.148

Intercept 0.07 + feature contributions = -10.145 (log-odds).
Score = sigmoid(-10.145) = 0.

Score0.04
Score291
Run 1

The code suffers from major readability issues. The generated Swing layout code dominates and creates deeply nested, verbose GroupLayout configurations that are hard to follow. Naming is inconsistent (e.g., 'jbCancel', 'txtNowAlert', 'chkNowtAlert') and often ambiguous. The class mixes concerns: UI construction, file I/O, event handling, and settings management. Several methods have unclear names ('Update', 'LoadSettings'), and comments add noise rather than clarity. Error handling swallows exceptions silently. Magic numbers and hard-coded indices (e.g., loops bounded by 5 and 3, switch cases 0-4) obscure intent. Action granularity varies, with event handlers performing multiple operations. While some structure exists (tabbed panels, method separation), the overall flow is disrupted by generated code and inconsistent organization.

Run 2

This code is largely unreadable due to a massive auto-generated GUI initialization method (initComponents) that dominates the class with hundreds of lines of nested GroupLayout configuration. The generated code is deeply nested, mixes concerns, and obscures any hand-written logic. Variable names like jLabel2, jPanel8, and jPanel12 are meaningless and fail to convey intent. The event handlers are scattered and contain cryptic logic (e.g., magic numbers in switch cases and loops). Methods like fillComboMethods use inefficient nested loops with boolean flags, making the algorithm hard to follow. There is also inconsistent formatting, commented-out code, and redundant boolean comparisons (== true/false). While the non-generated getters/setters are simple, the overall structure buries them under verbose, tangled layout code. The score reflects that the readable parts are minimal, and the dominant code is difficult to navigate or understand.

Run 3

The code suffers from readability issues despite decent separation of concerns. The massive `initComponents()` method (hundreds of lines of auto-generated GroupLayout code) dominates the class and obscures the actual logic, making it hard to navigate and understand. Nesting is deep within the layout code, though event handlers and business methods are relatively flat. Intent is unclear in places: cryptic variable names like `txtNowAlert`, `chkNowtAlert`, and `jPanel8` lack semantic clarity, and empty catch blocks silently swallow exceptions. Action granularity is mostly reasonable outside generated code. The `LoadSettings()` method repeatedly parses settings with low-level file I/O and magic strings, while `fillComboMethods()` uses nested loops and boolean flags in a way that obscures its purpose. Reading flow is interrupted by dead code (`main()` is commented out), unused fields, and inconsistent formatting. While getters/setters and javadocs help somewhat, the overall readability is hampered by generated UI code and poor naming.

Run 1

Code Structure: Separate event handlers, accessors, and persistence methods provide organization, but one class mixes UI construction, settings storage, and gesture management. Nesting: Most handlers are shallow; nested gesture loops and deeply chained layout expressions increase reading effort. Clarity of intent: Descriptive control names and comments establish the dialog's purpose, but generic names such as names, methods, and temp, magic indices, inconsistent naming conventions, and an empty catch obscure details. Code length: Extensive generated layout boilerplate dominates the class; repetitive file operations, redundant switch branches, and commented-out code add noise. Action granularity: Statements generally perform one action per line, although long layout chains are visually dense. Reading flow: Related UI sections are grouped logically, but inconsistent formatting, generated markers, and persistence methods placed after component declarations disrupt navigation. Overall, the main behavior is understandable, but verbosity and weak abstraction make detailed inspection cumbersome.

Run 2

Code Structure: Separate event handlers and accessors provide organization, but GUI construction, settings persistence, and gesture management share one large class. Nesting: Most handlers are shallow; nested gesture loops and deeply chained GroupLayout expressions increase reading effort. Clarity of intent: UI labels and documentation establish the purpose, but generic names such as names, methods, temp, and jLabel6, magic indices, and inconsistent method capitalization obscure details. Code length: Generated layout boilerplate dominates, while repetitive parsing/writing, redundant switch cases, and commented-out code add clutter. Action granularity: Statements generally perform one action per line, although layout chains contain dense expressions. Reading flow: Initialization and handlers follow a recognizable sequence, but inconsistent indentation, scattered declarations, verbose comments, and persistence methods placed after generated fields interrupt navigation.

Run 3

Code Structure: Initialization, event handlers, persistence, and accessors are separated into methods, but UI and settings logic share one large class. Nesting: Most handlers are shallow; nested gesture loops and deeply nested layout expressions increase reading effort. Clarity of intent: The dialog's purpose and many controls are clear, but generic names such as names, methods, temp, and numbered labels obscure meaning; positional file parsing requires tracking implicit structure. Code length: Generated Swing layout dominates the class, while repetitive persistence operations, redundant switch cases, and commented-out code add noise. Action granularity: Statements generally perform one action per line, although long chained layout expressions are harder to scan. Reading flow: Related UI sections and explanatory comments help, but inconsistent indentation, capitalization, spacing, and placement of persistence methods interrupt navigation. Overall, understandable application logic is buried beneath verbose generated code and inconsistent presentation.