gt: 				str = str.substring(0, i) + str.substring(e);
context: /*
   *  Copyright 2006, 2007 Alessandro Chiari.
   *
   *  This file is part of BrewPlus.
   *
   *  BrewPlus 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 2 of the License, or
   *  (at your option) any later version.
   *
   *  BrewPlus 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 BrewPlus; if not, write to the Free Software
   *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   */
  
  package jmash;
  
  import java.awt.Color;
  import java.awt.Component;
  import java.awt.Dimension;
  import java.awt.FlowLayout;
  import java.awt.GridBagConstraints;
  import java.awt.GridBagLayout;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.List;
  
  import javax.swing.BoxLayout;
  import javax.swing.ImageIcon;
  import javax.swing.JButton;
  import javax.swing.SwingConstants;
  
  public class BrowseHBDRecipator extends javax.swing.JInternalFrame {
  	private List<StyleTreeNode> styleNodes = new ArrayList<StyleTreeNode>();
  
  	/** Creates new form BrowseHBDRecipator */
  	public BrowseHBDRecipator() {
  		initComponents();
  		setBorder(Utils.getDefaultBorder());
  		pnl.setBackground(Color.white);
  		try {
  
  			String base = Utils.download("http://hbd.org/cgi-bin/recipator/recipes");
  			// System.out.println(base);
  			boolean flag = true;
  			while (flag) {
  				int i = base.indexOf("<a href=\"recipes?group=");
  				if (i >= 0) {
  					String G = base.substring(i + "<a href=\"recipes?group=".length(), base.indexOf("</a>", i));
  
  					String N = G.substring(0, G.indexOf("\">")).trim();
  					String T = G.substring(G.indexOf("\">") + "\">".length()).trim();
  					// System.out.println(T+" cod="+N);
  					base = base.substring(base.indexOf("</a>", i));
  
  					styleNodes.add(new StyleTreeNode(new Integer(N), T));
  				} else
  					flag = false;
  			}
  		} catch (Exception ex) {
  			Utils.showException(ex);
  		}
  		FlowLayout fl = new FlowLayout();
  		GridBagLayout gl = new GridBagLayout();
  		BoxLayout bl = new BoxLayout(pnl, BoxLayout.PAGE_AXIS);
  
  		fl.setAlignment(FlowLayout.LEFT);
  		fl.setVgap(2);
  		fl.setHgap(2);
  		this.pnl.setLayout(gl);
  
  		Dimension dim = new Dimension(720, 4000);
  		// this.pnl.setMaximumSize(dim);
  		// this.pnl.setSize(dim);
  		// this.pnl.setPreferredSize(dim);
  		int i = 0;
  		for (StyleTreeNode node : styleNodes) {
  			this.pnl.add(node, newConstraint(i++));
  		}
  	}
  
  	/**
  	 * 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.
  	 */
  	// <editor-fold defaultstate="collapsed" desc="Generated
  	// Code">//GEN-BEGIN:initComponents
  	private void initComponents() {
  
  		jScrollPane1 = new javax.swing.JScrollPane();
  		pnl = new javax.swing.JPanel();
  
  		setClosable(true);
  		setIconifiable(true);
  		setMaximizable(true);
  		setResizable(true);
  		setTitle("HBD.org Recipator");
  		setFont(getFont());
  
  		org.jdesktop.layout.GroupLayout pnlLayout = new org.jdesktop.layout.GroupLayout(pnl);
  		pnl.setLayout(pnlLayout);
  		pnlLayout.setHorizontalGroup(
  				pnlLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(0, 792, Short.MAX_VALUE));
  		pnlLayout.setVerticalGroup(
  				pnlLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(0, 451, Short.MAX_VALUE));
  
  		jScrollPane1.setViewportView(pnl);
  
  		getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
  
  		java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
  		setBounds((screenSize.width - 802) / 2, (screenSize.height - 481) / 2, 802, 481);
  	}// </editor-fold>//GEN-END:initComponents
  
  	// Variables declaration - do not modify//GEN-BEGIN:variables
  	private javax.swing.JScrollPane jScrollPane1;
  	private javax.swing.JPanel pnl;
  	// End of variables declaration//GEN-END:variables
  	private Dimension BTN_DIM = new Dimension(220, 20);
  
  	public class StyleTreeNode extends JButton {
  
  		private static final long serialVersionUID = 9142284801436841375L;
  		private String idStile;
  		private int stile;
  		private String des;
  		private JButton jb = new JButton("Torna a Tutti gli stili",
  				new ImageIcon(BrowseHobbyBirra2.class.getResource("/jmash/images/up.png")));
  
  		public StyleTreeNode(int stile, String des) {
  
  			super(des, new ImageIcon(BrowseHobbyBirra2.class.getResource("/jmash/images/fileopen.png")));
  			this.stile = stile;
  			idStile = "" + stile;
  			this.des = des;
  			setAlignmentX(Component.LEFT_ALIGNMENT);
  			setMaximumSize(BTN_DIM);
  			setSize(BTN_DIM);
  			setPreferredSize(BTN_DIM);
  			setHorizontalAlignment(SwingConstants.LEFT);
  			this.jb.setMaximumSize(BTN_DIM);
  			this.jb.setSize(BTN_DIM);
  			this.jb.setPreferredSize(BTN_DIM);
  			this.jb.addActionListener(new ActionListener() {
  				@Override
  				public void actionPerformed(ActionEvent e) {
  					pnl.removeAll();
  					int i = 0;
  					for (StyleTreeNode node : styleNodes) {
  						GridBagConstraints c = newConstraint(i++);
  						pnl.add(node, c);
  					}
  					pnl.updateUI();
  				}
  			});
  
  			addActionListener(new ActionListener() {
  				@Override
  				public void actionPerformed(ActionEvent e) {
  
  					Thread th = new Thread() {
  						@Override
  						public void run() {
  							setEnabled(false);
  							show();
  							setEnabled(true);
  						}
  					};
  					th.start();
  				}
  			});
  		}
  
  		public String getIdStile() {
  			return this.idStile;
  		}
  
  		@Override
  		public void show() {
  			pnl.removeAll();
  
  			readRecipesForStyle(stile);
  
  			pnl.updateUI();
  		}
  
  		public String getDes() {
  			return this.des;
  		}
  
  		public void setDes(String des) {
  			this.des = des;
  			setText(des);
  		}
  
  		public void readRecipesForStyle(int a) {
  			List<RecipeTreeNode> nodes = new ArrayList<RecipeTreeNode>();
  			try {/*
  					 * RandomAccessFile f=new
  					 * RandomAccessFile("C:/ricetta.html","r"); byte b[]=new
  					 * byte[(int)f.length()]; f.readFully(b); f.close(); String
  					 * base=new String(b);
  					 */
  				String base = Utils.download("http://hbd.org/cgi-bin/recipator/recipes?group=" + a);
  				boolean flag = true;
  				while (flag) {
  					int i = base.indexOf("/cgi-bin/recipator/recipator?group=");
  					if (i >= 0) {
  						String G = base.substring(i + "/cgi-bin/recipator/recipator?group=".length(),
  								base.indexOf("</a>", i));
  						String N = G.substring(G.indexOf("item=") + "item=".length(), G.indexOf("\">")).trim();
  						String T = G.substring(G.indexOf("\">") + "\">".length()).trim();
  						base = base.substring(base.indexOf("</a>", i));
  						RecipeTreeNode node = new RecipeTreeNode(new Integer(N), T);
  						nodes.add(node);
  					} else
  						flag = false;
  				}
  			} catch (Exception ex) {
  				Utils.showException(ex);
  			}
  			Collections.sort(nodes);
  			pnl.add(jb, newConstraint(0));
  			int i = 1;
  			for (RecipeTreeNode node : nodes) {
  				pnl.add(node, newConstraint(i++));
  			}
  			pnl.updateUI();
  		}
  
  	}
  
  	public GridBagConstraints newConstraint(int i) {
  		GridBagConstraints c = new GridBagConstraints();
  		c.insets = new java.awt.Insets(2, 2, 2, 2);
  		c.gridx = i % 4;
  		c.gridy = i / 4;
  		return c;
  	}
  
  	public class RecipeTreeNode extends JButton implements Comparable<RecipeTreeNode> {
  		private int id;
  		private String des;
  
  		public RecipeTreeNode(int id, String des) {
  
  			super(des, new ImageIcon(BrowseHobbyBirra2.class.getResource("/jmash/images/edit.png")));
  			this.id = id;
  			this.des = des;
  			setAlignmentX(Component.LEFT_ALIGNMENT);
  			setMaximumSize(BTN_DIM);
  			setSize(BTN_DIM);
  			setPreferredSize(BTN_DIM);
  			setHorizontalAlignment(SwingConstants.LEFT);
  
  			addActionListener(new ActionListener() {
  				@Override
  				public void actionPerformed(ActionEvent e) {
  					Thread th = new Thread() {
  						@Override
  						public void run() {
  							show();
  						}
  					};
  					th.start();
  				}
  			});
  		}
  
  		@Override
  		public int compareTo(RecipeTreeNode e) {
  			return des.compareTo(e.getDes());
  		}
  
  		private boolean F = false;
  
  		@Override
  		public void show() {
  			if (F)
  				return;
  			F = true;
  			try {
  				String str = Utils.download("http://hbd.org/cgi-bin/recipator/recipator?item=" + id);
  				int i = str.indexOf("<table", 0);
  				int e = str.indexOf("</table>", i) + "</table>".length();
  