isCustom = true; try { start.setValue(Integer.parseInt(startTF.getText(), 16)); } catch (NumberFormatException e) {} try { end.setValue(Integer.parseInt(endTF.getText(), 16)); } catch (NumberFormatException e) {}
if (!changingSlider) { changingTF = true; isCustom = true; int st = -1, e = -1; try { st = Integer.parseInt(startTF.getText(), 16); } catch (NumberFormatException e1) {} try { e = Integer.parseInt(endTF.getText(), 16); } catch (NumberFormatException e2) {} if(st >= 0 && e >= 0) { start.setValue(Math.min(st,e)); end.setValue(Math.max(st,e)); }   changingTF = false; }
    protected void init()    {        initResetRanges();        mainWindow = new JFrame(this.getDescription());        mainWindow.setLocationRelativeTo(JHack.main.getMainWindow());        mainWindow.setSize(620, 210);        mainWindow.getContentPane().setLayout(new BorderLayout());        //start bottom buttons        JPanel buttons = new JPanel();        buttons.setLayout(new FlowLayout());        JButton reset = new JButton("Reset Area");        reset.setActionCommand("reset");        reset.addActionListener(this);        buttons.add(reset);        JButton makeips = new JButton("Make Partial IPS");        makeips.setActionCommand("makeips");        makeips.addActionListener(this);        buttons.add(makeips);        buttons.add(new JSeparator());        JButton decomp = new JButton("Decomp...");        decomp.setActionCommand("decomp");        decomp.addActionListener(this);        buttons.add(decomp);        JButton comp = new JButton("Comp...");        comp.setActionCommand("comp");        comp.addActionListener(this);        buttons.add(comp);        buttons.add(new JSeparator());        JButton close = new JButton("Close");        close.setActionCommand("close");        close.addActionListener(this);        buttons.add(close);        mainWindow.getContentPane().add(buttons, BorderLayout.SOUTH);        //end bottom buttons        Box entry = new Box(BoxLayout.Y_AXIS);        entry.add(pairComponents(rangeSelector = HackModule            .createJComboBoxFromArray(ranges.toArray()),            subrangeSelector = new JComboBox(), true));        rangeSelector.addActionListener(new ActionListener()        {            public void actionPerformed(ActionEvent ae)            {                ResetRange rr = ((ResetRange) ranges.get(rangeSelector                    .getSelectedIndex()));                setSelectedRange(rr);                subrangeSelector.removeAllItems();                subrangeSelector.addItem("All");                for (int i = 0; i < rr.getSubRanges().length; i++)                {                    subrangeSelector.addItem(rr.getSubRanges()[i]);                }                subrangeSelector.setSelectedIndex(0);            }        });        subrangeSelector.addActionListener(new ActionListener()        {            public void actionPerformed(ActionEvent ae)            {                isCustom = false;                ResetRange rr;                try                {                    rr = ((ResetRange) ranges.get(rangeSelector                        .getSelectedIndex())).getSubRanges()[subrangeSelector                        .getSelectedIndex() - 1];                }                catch (ArrayIndexOutOfBoundsException e)                {                    rr = ((ResetRange) ranges.get(rangeSelector                        .getSelectedIndex()));                }                setSelectedRange(rr);            }        });        //slider ChangeListener        ChangeListener scl = new ChangeListener()        {            public void stateChanged(ChangeEvent arg0)            {                try                {                    startTF.setText(addZeros(Integer.toString(start.getValue(),                        16), 6));                    endTF.setText(addZeros(                        Integer.toString(end.getValue(), 16), 6));                    lenTF.setText(Integer.toString(end.getValue()                        - start.getValue() + 1, 16));                }                catch (IllegalStateException e)                {                    //e.printStackTrace();                }            }        };        //TextField DocumentListner        DocumentListener tdl = new DocumentListener()        {            public void doStuff()            {                isCustom = true;                try                {                    start.setValue(Integer.parseInt(startTF.getText(), 16));                }                catch (NumberFormatException e)                {}                try                {                    end.setValue(Integer.parseInt(endTF.getText(), 16));                }                catch (NumberFormatException e)                {}                //				lenTF.setText(                //					Integer.toString(                //						end.getValue() - start.getValue() + 1,                //						16));            }            public void insertUpdate(DocumentEvent arg0)            {                doStuff();            }            public void removeUpdate(DocumentEvent arg0)            {                doStuff();            }            public void changedUpdate(DocumentEvent arg0)            {                doStuff();            }        };        entry.add(start = new JSlider(0, rom.length() - 1, 0));        entry.add(HackModule.createFlowLayout(new JComponent[]{            startTF = HackModule.createSizedJTextField(6), new JLabel(" to "),            endTF = HackModule.createSizedJTextField(6),            new JLabel(" (Length: "),            lenTF = HackModule.createSizedJTextField(6), new JLabel(")")}));        lenTF.setEnabled(false);        entry.add(end = new JSlider(0, rom.length() - 1, rom.length() - 1));        start.addChangeListener(new ChangeListener()        {            public void stateChanged(ChangeEvent arg0)            {                isCustom = true;                try                {                    startTF.setText(addZeros(Integer.toString(start.getValue(),                        16), 6));                    lenTF.setText(Integer.toString(end.getValue()                        - start.getValue() + 1, 16));                }                catch (IllegalStateException e)                {                    //e.printStackTrace();                }            }        });        end.addChangeListener(new ChangeListener()        {            public void stateChanged(ChangeEvent arg0)            {                isCustom = false;                try                {                    endTF.setText(addZeros(                        Integer.toString(end.getValue(), 16), 6));                    lenTF.setText(Integer.toString(end.getValue()                        - start.getValue() + 1, 16));                }                catch (IllegalStateException e)                {                    //e.printStackTrace();                }            }        });        startTF.getDocument().addDocumentListener(tdl);        endTF.getDocument().addDocumentListener(tdl);        lenTF.getDocument().addDocumentListener(tdl);        scl.stateChanged(new ChangeEvent(this));        mainWindow.getContentPane().add(            HackModule.pairComponents(new JLabel(), entry, false),            BorderLayout.CENTER);        //load ROM stuff        orgRom = JHack.main.getOrginalRomFile(rom.getRomType());        JButton loadb;        JPanel loadPane = HackModule.pairComponents(            loadb = new JButton("Load"), this.path = new JLabel(orgRom                .getPath()), true);        loadb.addActionListener(this);        loadb.setActionCommand("load");        mainWindow.getContentPane().add(loadPane, BorderLayout.NORTH);        rangeSelector.setSelectedIndex(0);        mainWindow.pack();    }