Changeset 102

Show
Ignore:
Timestamp:
14/05/08 10:28:03 (7 months ago)
Author:
altglass
Message:

Beginning of a new parsing system (resources only atm)
New layouts of resources' editing dialogues

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/vlcskineditor/GlobalVariables.java

    r85 r102  
    378378      update(); 
    379379      frame.setVisible(false); 
     380      frame.dispose(); 
     381      frame = null; 
    380382    } 
    381383    else if(e.getSource().equals(help_btn)) { 
  • trunk/src/vlcskineditor/Main.java

    r101 r102  
    4747   
    4848  //The version identification of the current build.    
    49   public final String VERSION = "0.7.0.b"; 
     49  public final String VERSION = "0.7.0 dev"; 
    5050  //The directory in which the VLC executable is found 
    5151  String vlc_dir = ""; 
     
    787787      } 
    788788      catch (IOException ex) { 
    789          
     789        JOptionPane.showMessageDialog(this,"VLC Media Player could not be launched","Error",JOptionPane.ERROR_MESSAGE); 
    790790      } 
    791791    } 
  • trunk/src/vlcskineditor/Skin.java

    r99 r102  
    2323package vlcskineditor; 
    2424 
    25 import vlcskineditor.history.*; 
     25import java.awt.Desktop; 
     26import java.awt.Dimension; 
     27import java.awt.FlowLayout; 
     28import java.awt.event.ActionEvent; 
     29import java.awt.event.ActionListener; 
     30import java.awt.image.BufferedImage; 
     31import java.io.BufferedReader; 
     32import java.io.File; 
     33import java.io.FileReader; 
     34import java.io.FileWriter; 
     35import java.util.LinkedList; 
     36import javax.swing.BorderFactory; 
     37import javax.swing.JButton; 
     38import javax.swing.JFrame; 
     39import javax.swing.JLabel; 
     40import javax.swing.JOptionPane; 
     41import javax.swing.JPanel; 
     42import javax.swing.JTextField; 
     43import javax.swing.JTree; 
     44import javax.swing.border.EtchedBorder; 
     45import javax.swing.tree.DefaultMutableTreeNode; 
     46import javax.swing.tree.TreePath; 
     47import javax.xml.parsers.DocumentBuilder; 
     48import javax.xml.parsers.DocumentBuilderFactory; 
     49import org.w3c.dom.Document; 
     50import org.w3c.dom.Element; 
     51import org.w3c.dom.NamedNodeMap; 
     52import org.w3c.dom.Node; 
     53import org.w3c.dom.NodeList; 
     54import vlcskineditor.history.ThemeEditEvent; 
    2655import vlcskineditor.resources.Bitmap; 
    2756import vlcskineditor.resources.BitmapFont; 
     57import vlcskineditor.resources.Font; 
    2858import vlcskineditor.resources.SubBitmap; 
    29 import java.awt.*; 
    30 import java.awt.event.*; 
    31 import java.awt.image.*; 
    32 import java.io.*; 
    33 import javax.swing.*; 
    34 import javax.swing.tree.*; 
    35 import java.util.*; 
    36 import javax.swing.border.EtchedBorder; 
    3759 
    3860/** 
     
    104126    skinfolder = f.getParentFile().getAbsolutePath()+File.separator;     
    105127    try { 
    106       //System.out.println("Creating Buffered Reader..."); 
     128      parse(f); 
     129      //parseXML(f); 
     130    }  
     131    catch (Exception ex) { 
     132      ex.printStackTrace(); 
     133      String stackTrace =""; 
     134      for (int i=0;i<ex.getStackTrace().length;i++) { 
     135        stackTrace+=ex.getStackTrace()[i].toString()+"\n"; 
     136      } 
     137      JOptionPane.showMessageDialog(null,ex.toString()+"\n\n"+stackTrace,ex.getMessage(),JOptionPane.ERROR_MESSAGE);     
     138      update(); 
     139    }     
     140    update();            
     141  } 
     142  /** 
     143   * Parses the given file line by line, expecting each xml-tag to be in his own single line 
     144   * @param f The file that should be parsed 
     145   * @throws java.lang.Exception 
     146   */ 
     147  private void parse(File f) throws Exception { 
     148  //System.out.println("Creating Buffered Reader..."); 
    107149      BufferedReader br = new BufferedReader(new FileReader(f)); 
    108150      //System.out.println("Ready..."); 
     
    182224        } 
    183225        //</editor-fold> 
    184         else if(line.startsWith("<Font")) resources.add(new vlcskineditor.resources.Font(line,this)); 
     226        else if(line.startsWith("<Font")) resources.add(new Font(line,this)); 
    185227        else if(line.startsWith("<BitmapFont")) resources.add(new BitmapFont(line,this));         
    186228        //<editor-fold defaultstate="collapsed" desc=" Window tag ">  
     
    209251      } 
    210252      br.close(); 
    211       //System.out.println("Buffered Reader was closed"); 
    212     }  
    213     catch (Exception ex) { 
    214       String stackTrace =""; 
    215       for (int i=0;i<ex.getStackTrace().length;i++) { 
    216         stackTrace+=ex.getStackTrace()[i].toString()+"\n"; 
    217       } 
    218       JOptionPane.showMessageDialog(null,ex.toString()+"\n\n"+stackTrace,ex.getMessage(),JOptionPane.ERROR_MESSAGE);     
    219       update(); 
    220     }     
    221     update();            
    222   } 
    223   /** Parses the XML Code into the skinfile **/ 
     253      //System.out.println("Buffered Reader was closed");   
     254   
     255  } 
     256  /** 
     257   * Parses the skin file via Java's XMLReader 
     258   * @param f The file that should be parsed 
     259   * @throws java.lang.Exception 
     260   */ 
     261  private void parseXML(File f) throws Exception{ 
     262    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); 
     263    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); 
     264    Document doc = docBuilder.parse(f); 
     265     
     266    if(!doc.getDoctype().getName().equals("Theme")) 
     267      throw new Exception("Selected file is not a valid VLC skin file!"); 
     268     
     269    NodeList nodes = doc.getElementsByTagName("*"); 
     270    for(int i=0;i<nodes.getLength();i++) { 
     271     Element e = (Element)nodes.item(i);      
     272     parseElement(e); 
     273    } 
     274  } 
     275  private void parseElement(Element e) throws Exception{ 
     276    String tag = e.getTagName();     
     277    if(tag.equals("Theme")) { 
     278      if(e.hasAttribute("version"))  theme_version = e.getAttribute("version"); 
     279      if(Double.parseDouble(theme_version)!=2.0)  
     280        throw new Exception("The version of the theme used in the selected skin is not yet supported!"); 
     281    } 
     282    else if(tag.equals("ThemeInfo")) { 
     283      if(e.hasAttribute("author")) themeinfo_author = e.getAttribute("author"); 
     284      if(e.hasAttribute("name")) themeinfo_name = e.getAttribute("name"); 
     285      if(e.hasAttribute("email")) themeinfo_email = e.getAttribute("email"); 
     286      if(e.hasAttribute("webpage")) themeinfo_webpage = e.getAttribute("webpage"); 
     287    } 
     288    else if(tag.equals("Bitmap")) { 
     289      resources.add(new Bitmap(e,this)); 
     290    } 
     291    else if(tag.equals("SubBitmap")) { 
     292      Node p = e.getParentNode(); 
     293      String id = p.getAttributes().getNamedItem("id").getNodeValue(); 
     294      Bitmap b = (Bitmap)getResource(id); 
     295      b.SubBitmaps.add(new SubBitmap(e,this,b)); 
     296    } 
     297    else if(tag.equals("Font")) { 
     298      resources.add(new Font(e,this)); 
     299    } 
     300  } 
     301  /** Saves the XML Code into the skinfile **/ 
    224302  public void save() {    
    225303    try { 
  • trunk/src/vlcskineditor/package.html

    r68 r102  
    66<body> 
    77 
    8 The VLC Skin Editor's package 
     8The VLC Skin Editor's main package 
    99 
    1010 
    11 @author Daniel Dreibrodt <mailto:daniel_DOT_dreibrodt_AT_gmx_DOT_de
    12 @version 0.6.0 
     11@author Daniel Dreibrodt <mailto:daniel_DOT_dreibrodt_AT_googlemail_DOT_com
     12@version 0.7.0 
    1313 
    1414 
  • trunk/src/vlcskineditor/resources/Bitmap.java

    r101 r102  
    3434import java.awt.event.*; 
    3535import java.io.*; 
     36import org.w3c.dom.Element; 
    3637 
    3738/** 
     
    5960   
    6061  /** 
     62   * Creates a new Bitmap from a W3C DOM element 
     63   * @param e The W3C DOM element 
     64   * @param s_ The skin in which the Bitmap is used 
     65   */   
     66  public Bitmap(Element e, Skin s_) { 
     67    type = "Bitmap"; 
     68    s = s_; 
     69    if(e.hasAttribute("id")) id = e.getAttribute("id"); 
     70    if(e.hasAttribute("file")) file = e.getAttribute("file"); 
     71    if(e.hasAttribute("alphacolor")) alphacolor = e.getAttribute("alphacolor"); 
     72    if(e.hasAttribute("nbframes")) nbframes = Integer.valueOf(e.getAttribute("nbframes")); 
     73    if(e.hasAttribute("fps")) fps = Integer.valueOf(e.getAttribute("fps")); 
     74    updateImage();     
     75  } 
     76   
     77  /** 
    6178   * Creates a new Bitmap from xml code 
    6279   * @param xmlcode The XML code from which the Bitmap should be created. One line per tag. 
    63    * @param s_ The skin in which the Bitmap is used. 
    64    * This is necessary in order that the image file can be located relatively to the skin file. 
     80   * @param s_ The skin in which the Bitmap is used. This is necessary in order that the image file can be located relatively to the skin file. 
    6581   */   
    6682  public Bitmap(String xmlcode, Skin s_) {     
     
    130146   * Regenerates the image represented by the Bitmap object. 
    131147   */ 
    132   public void updateImage() { 
     148  public boolean updateImage() { 
    133149    try { 
    134150      image = ImageIO.read(new File(s.skinfolder+file));        
     
    165181    catch(Exception ex) {       
    166182      ex.printStackTrace(); 
    167       JOptionPane.showMessageDialog(null,ex.getMessage()+"\n"+s.skinfolder+file,"Bitmap \""+id+"\" caused an error",JOptionPane.ERROR_MESSAGE);  
    168       showOptions(); 
    169       return; 
    170     }     
     183      //JOptionPane.showMessageDialog(null,ex.getMessage()+"\n"+s.skinfolder+file,"Bitmap \""+id+"\" caused an error",JOptionPane.ERROR_MESSAGE);  
     184      //showOptions(); 
     185      image = new BufferedImage(32,32,BufferedImage.TYPE_INT_ARGB); 
     186      Graphics2D g = (Graphics2D)image.getGraphics(); 
     187      g.setColor(new Color(255,0,0,128)); 
     188      g.fillRect(0, 0, 32, 32); 
     189      return false; 
     190    } 
     191    return true; 
    171192  } 
    172193  public void update() { 
     
    180201      s.updateResources(); 
    181202      s.expandResource(id); 
    182     } 
    183     updateImage(); 
     203    }     
    184204    be.setNew(); 
    185205    s.m.hist.addEvent(be); 
     
    212232      fps_tf.setToolTipText("Only used in animated bitmaps; it is the number of frames (images) per seconds of the animation."); 
    213233      ok_btn = new JButton("OK"); 
    214       ok_btn.addActionListener(this); 
    215       ok_btn.setPreferredSize(new Dimension(70,25)); 
     234      ok_btn.addActionListener(this);       
    216235      cancel_btn = new JButton("Cancel"); 
    217       cancel_btn.addActionListener(this); 
    218       cancel_btn.setPreferredSize(new Dimension(70,25)); 
     236      cancel_btn.addActionListener(this);       
    219237      help_btn = new JButton("Help"); 
    220       help_btn.addActionListener(this); 
    221       help_btn.setPreferredSize(new Dimension(70,25)); 
    222        
     238      help_btn.addActionListener(this);       
     239      JLabel attr_l = new JLabel("* Attributes marked with a star must be specified."); 
    223240       
    224241      JPanel general = new JPanel(null); 
    225242      general.add(id_l); 
    226243      general.add(id_tf); 
    227       id_l.setBounds(5,15,75,24); 
    228       id_tf.setBounds(85,15,150,24); 
    229244      general.add(file_l); 
    230245      general.add(file_tf); 
    231246      general.add(file_btn); 
    232       file_l.setBounds(5,45,75,24); 
    233       file_tf.setBounds(85,45,150,24); 
    234       file_btn.setBounds(240,45,100,24); 
    235247      general.add(alphacolor_l); 
    236248      general.add(alphacolor_tf); 
    237249      general.add(alphacolor_btn); 
    238       alphacolor_l.setBounds(5,75,75,24); 
    239       alphacolor_tf.setBounds(85,75,150,24); 
    240       alphacolor_btn.setBounds(240,75,100,24); 
    241250      general.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "General Attributes"));        
    242       general.setMinimumSize(new Dimension(345,110)); 
    243       general.setPreferredSize(new Dimension(345,110)); 
    244       general.setMaximumSize(new Dimension(345,110)); 
    245251      frame.add(general); 
     252       
     253      //Distance of textfields to WEST edge of container 
     254      Component[] labels = { id_l, file_l, alphacolor_l, nbframes_l, fps_l}; 
     255      int tf_dx = Helper.maxWidth(labels)+10; 
     256      //Max. textfield width 
     257      int tf_wd = 200; 
     258      //Width of buttons 
     259      Component[] btns = { file_btn, alphacolor_btn }; 
     260      int btn_wd = Helper.maxWidth(btns); 
     261       
     262      SpringLayout general_layout = new SpringLayout(); 
     263      general.setLayout(general_layout);       
     264       
     265      general_layout.putConstraint(SpringLayout.NORTH, id_l, 5, SpringLayout.NORTH, general); 
     266      general_layout.putConstraint(SpringLayout.WEST, id_l, 5, SpringLayout.WEST, general);       
     267      general_layout.putConstraint(SpringLayout.WEST, id_tf, tf_dx, SpringLayout.WEST, general); 
     268      general_layout.putConstraint(SpringLayout.NORTH, id_tf, 0, SpringLayout.NORTH, id_l); 
     269      general_layout.putConstraint(SpringLayout.EAST, id_tf, 0, SpringLayout.EAST, file_btn); 
     270       
     271      general_layout.putConstraint(SpringLayout.NORTH, file_l, 10, SpringLayout.SOUTH, id_l); 
     272      general_layout.putConstraint(SpringLayout.WEST, file_l, 5, SpringLayout.WEST, general);       
     273      general_layout.putConstraint(SpringLayout.WEST, file_tf, tf_dx, SpringLayout.WEST, general); 
     274      general_layout.putConstraint(SpringLayout.NORTH, file_tf, 0, SpringLayout.NORTH, file_l);       
     275      file_tf.setPreferredSize(new Dimension(tf_wd-btn_wd,file_tf.getPreferredSize().height)); 
     276      file_btn.setPreferredSize(new Dimension(btn_wd,file_btn.getPreferredSize().height)); 
     277      general_layout.putConstraint(SpringLayout.WEST, file_btn, 5, SpringLayout.EAST, file_tf); 
     278      general_layout.putConstraint(SpringLayout.NORTH, file_btn, 0, SpringLayout.NORTH, file_l); 
     279      general_layout.putConstraint(SpringLayout.EAST, general, 5, SpringLayout.EAST, file_btn); 
     280       
     281      general_layout.putConstraint(SpringLayout.NORTH, alphacolor_l, 10, SpringLayout.SOUTH, file_l); 
     282      general_layout.putConstraint(SpringLayout.WEST, alphacolor_l, 5, SpringLayout.WEST, general);       
     283      general_layout.putConstraint(SpringLayout.WEST, alphacolor_tf, tf_dx, SpringLayout.WEST, general); 
     284      general_layout.putConstraint(SpringLayout.NORTH, alphacolor_tf, 0, SpringLayout.NORTH, alphacolor_l); 
     285      alphacolor_tf.setPreferredSize(new Dimension(tf_wd-btn_wd,alphacolor_tf.getPreferredSize().height)); 
     286      alphacolor_btn.setPreferredSize(new Dimension(btn_wd,alphacolor_btn.getPreferredSize().height)); 
     287      general_layout.putConstraint(SpringLayout.WEST, alphacolor_btn, 5, SpringLayout.EAST, alphacolor_tf); 
     288      general_layout.putConstraint(SpringLayout.NORTH, alphacolor_btn, 0, SpringLayout.NORTH, alphacolor_l); 
     289      general_layout.putConstraint(SpringLayout.EAST, general, 5, SpringLayout.EAST, alphacolor_btn); 
     290       
     291      general_layout.putConstraint(SpringLayout.SOUTH, general, 10, SpringLayout.SOUTH, alphacolor_l); 
    246292       
    247293      JPanel animation = new JPanel(null); 
     
    249295      animation.add(nbframes_tf); 
    250296      animation.add(fps_l); 
    251       animation.add(fps_tf); 
    252       nbframes_l.setBounds(5,15,150,24); 
    253       nbframes_tf.setBounds(160,15,150,24); 
    254       fps_l.setBounds(5,45,150,24); 
    255       fps_tf.setBounds(160,45,150,24); 
    256       animation.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Animation Attributes"));        
    257       animation.setMinimumSize(new Dimension(345,80)); 
    258       animation.setPreferredSize(new Dimension(345,80)); 
    259       animation.setMaximumSize(new Dimension(345,80));       
     297      animation.add(fps_tf);       
     298      animation.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Animation Attributes"));              
     299       
     300      SpringLayout ani_layout = new SpringLayout(); 
     301      animation.setLayout(ani_layout); 
     302       
     303      nbframes_tf.setPreferredSize(new Dimension(tf_wd,nbframes_tf.getPreferredSize().height));       
     304       
     305      ani_layout.putConstraint(SpringLayout.NORTH, nbframes_l, 5, SpringLayout.NORTH, animation); 
     306      ani_layout.putConstraint(SpringLayout.WEST, nbframes_l, 5, SpringLayout.WEST, animation);       
     307      ani_layout.putConstraint(SpringLayout.WEST, nbframes_tf, tf_dx, SpringLayout.WEST, animation); 
     308      ani_layout.putConstraint(SpringLayout.NORTH, nbframes_tf, 0, SpringLayout.NORTH, nbframes_l); 
     309      ani_layout.putConstraint(SpringLayout.EAST, animation, 5, SpringLayout.EAST, nbframes_tf); 
     310       
     311      ani_layout.putConstraint(SpringLayout.NORTH, fps_l, 10, SpringLayout.SOUTH, nbframes_l); 
     312      ani_layout.putConstraint(SpringLayout.WEST, fps_l, 5, SpringLayout.WEST, animation);       
     313      ani_layout.putConstraint(SpringLayout.WEST, fps_tf, tf_dx, SpringLayout.WEST, animation); 
     314      ani_layout.putConstraint(SpringLayout.NORTH, fps_tf, 0, SpringLayout.NORTH, fps_l); 
     315      ani_layout.putConstraint(SpringLayout.EAST, fps_tf, 0, SpringLayout.EAST, nbframes_tf); 
     316       
     317      ani_layout.putConstraint(SpringLayout.SOUTH, animation, 10, SpringLayout.SOUTH, fps_l); 
     318       
     319       
    260320      frame.add(animation); 
    261321      
     
    263323      frame.add(cancel_btn); 
    264324      frame.add(help_btn); 
    265       frame.add(new JLabel("Attributes marked with a star must be specified.")); 
    266        
    267       frame.setMinimumSize(new Dimension(355,260));      
    268       frame.setPreferredSize(new Dimension(355,260)); 
    269       frame.setMaximumSize(new Dimension(355,260)); 
     325      frame.add(attr_l); 
     326       
     327      SpringLayout layout = new SpringLayout(); 
     328      frame.setLayout(layout); 
     329       
     330      layout.putConstraint(SpringLayout.NORTH, general, 5, SpringLayout.NORTH, frame.getContentPane()); 
     331      layout.putConstraint(SpringLayout.WEST, general, 5, SpringLayout.WEST, frame.getContentPane()); 
     332       
     333      layout.putConstraint(SpringLayout.NORTH, animation, 5, SpringLayout.SOUTH, general); 
     334      layout.putConstraint(SpringLayout.WEST, animation, 5, SpringLayout.WEST, frame.getContentPane()); 
     335       
     336       
     337      layout.putConstraint(SpringLayout.NORTH, attr_l, 5, SpringLayout.SOUTH, animation); 
     338      layout.putConstraint(SpringLayout.WEST, attr_l, 5, SpringLayout.WEST, frame.getContentPane()); 
     339      layout.putConstraint(SpringLayout.EAST, attr_l, 5, SpringLayout.EAST, frame.getContentPane()); 
     340       
     341       
     342      layout.putConstraint(SpringLayout.NORTH, ok_btn, 5, SpringLayout.SOUTH, attr_l); 
     343      layout.putConstraint(SpringLayout.NORTH, cancel_btn, 5, SpringLayout.SOUTH, attr_l); 
     344      layout.putConstraint(SpringLayout.NORTH, help_btn, 5, SpringLayout.SOUTH, attr_l); 
     345       
     346      layout.putConstraint(SpringLayout.WEST, ok_btn, 5, SpringLayout.WEST, frame.getContentPane()); 
     347      layout.putConstraint(SpringLayout.WEST, cancel_btn, 5, SpringLayout.EAST, ok_btn); 
     348      layout.putConstraint(SpringLayout.WEST, help_btn, 5, SpringLayout.EAST, cancel_btn); 
     349       
     350      layout.putConstraint(SpringLayout.SOUTH, frame.getContentPane(), 5, SpringLayout.SOUTH, ok_btn); 
     351      layout.putConstraint(SpringLayout.EAST, frame.getContentPane(), 5, SpringLayout.EAST, general); 
    270352       
    271353      frame.pack(); 
     
    326408        return; 
    327409      }       
    328       update();     
    329       frame.setVisible(false); 
    330       frame.dispose(); 
    331       frame = null;         
     410      update(); 
     411      if(updateImage()) { 
     412        frame.setVisible(false); 
     413        frame.dispose(); 
     414        frame = null; 
     415      } 
     416      else {         
     417        JOptionPane.showMessageDialog(frame,"The given bitmap file could not be loaded!","File not valid",JOptionPane.ERROR_MESSAGE); 
     418      } 
    332419    } 
    333420    else if(e.getSource().equals(help_btn)) { 
  • trunk/src/vlcskineditor/resources/Font.java

    r99 r102  
    3131import java.awt.event.*; 
    3232import java.io.*; 
     33import org.w3c.dom.Element; 
    3334/** 
    3435 * Handles font resources 
     
    5051  public java.awt.Font f; 
    5152   
     53  public Font(Element e, Skin s_) { 
     54    type = "Font"; 
     55    s = s_; 
     56    if(e.hasAttribute("id")) id = e.getAttribute("id"); 
     57    if(e.hasAttribute("file")) file = e.getAttribute("file"); 
     58    if(e.hasAttribute("size")) size = Integer.parseInt(e.getAttribute("size")); 
     59  } 
     60   
    5261  /** 
    5362   * Creates a Font from XML. 
     
    110119    showOptions(); 
    111120  } 
    112   public void updateFont() { 
     121  public Integer updateFont() { 
    113122    try {       
    114123      f = java.awt.Font.createFont(java.awt.Font.TRUETYPE_FONT,new File(s.skinfolder+file)); 
    115       f = f.deriveFont((float)size); 
     124      f = f.deriveFont((float)size);       
    116125    } 
    117126    catch(Exception e) {       
    118127      if(file.indexOf(".otf")==-1) { 
    119         JOptionPane.showMessageDialog(frame,"Error while loading font file!\n Please choose another file\n","Font file not valid",JOptionPane.ERROR_MESSAGE); 
     128        //JOptionPane.showMessageDialog(frame,"Error while loading font file!\n Please choose another file\n","Font file not valid",JOptionPane.ERROR_MESSAGE); 
    120129        f = new java.awt.Font(java.awt.Font.SANS_SERIF,java.awt.Font.PLAIN,size); 
    121         showOptions(); 
     130        //showOptions(); 
     131        return 0; 
    122132      } 
    123133      else { 
    124         JOptionPane.showMessageDialog(frame,"You have chosen an OpenType font, VLC will display it correctly but the Skin Editor can not display it.\nYou will see another font instead.","Notice",JOptionPane.INFORMATION_MESSAGE); 
     134        //JOptionPane.showMessageDialog(frame,"You have chosen an OpenType font, VLC will display it correctly but the Skin Editor can not display it.\nYou will see another font instead.","Notice",JOptionPane.INFORMATION_MESSAGE);         
    125135        try {       
    126136          f = new java.awt.Font(java.awt.Font.SANS_SERIF,java.awt.Font.PLAIN,size); 
    127137          f = f.deriveFont(12); 
    128138        } 
    129         catch(Exception ex) { 
     139        catch(Exception ex) {           
    130140          ex.printStackTrace(); 
    131           f = new java.awt.Font(java.awt.Font.SANS_SERIF,java.awt.Font.PLAIN,size); 
     141          f = new java.awt.Font(java.awt.Font.SANS_SERIF,java.awt.Font.PLAIN,size);           
    132142        } 
     143        return 2; 
    133144      }       
    134145    } 
     146    return 1; 
    135147  } 
    136148  public void update() { 
     
    141153    id=id_tf.getText(); 
    142154    s.updateResources(); 
    143     s.expandResource(id); 
    144     updateFont(); 
     155    s.expandResource(id);     
    145156    fe.setNew(); 
    146157    s.m.hist.addEvent(fe); 
     
    150161      frame = new JFrame("Font settings"); 
    151162      frame.setResizable(false); 
    152       frame.setLayout(new FlowLayout());       
    153163      JLabel id_l = new JLabel("ID*:"); 
    154164      id_tf = new JTextField(); 
     
    163173      size_tf.setDocument(new NumbersOnlyDocument()); 
    164174      ok_btn = new JButton("OK"); 
    165       ok_btn.addActionListener(this); 
    166       ok_btn.setPreferredSize(new Dimension(70,25)); 
     175      ok_btn.addActionListener(this);       
    167176      cancel_btn = new JButton("Cancel"); 
    168       cancel_btn.addActionListener(this); 
    169       cancel_btn.setPreferredSize(new Dimension(70,25)); 
     177      cancel_btn.addActionListener(this);       
    170178      help_btn = new JButton("Help"); 
    171       help_btn.addActionListener(this); 
    172       help_btn.setPreferredSize(new Dimension(70,25)); 
    173        
    174       JPanel general = new JPanel(null); 
     179      help_btn.addActionListener(this);       
     180      JLabel attr_l = new JLabel("* Attributes marked with a star must be specified."); 
     181       
     182      JPanel general = new JPanel(null);       
    175183      general.add(id_l); 
    176       general.add(id_tf); 
    177       id_l.setBounds(5,15,75,24); 
    178       id_tf.setBounds(85,15,150,24); 
     184      general.add(id_tf);      
    179185      general.add(file_l); 
    180186      general.add(file_tf); 
    181187      general.add(file_btn); 
    182       file_l.setBounds(5,45,75,24); 
    183       file_tf.setBounds(85,45,150,24); 
    184       file_btn.setBounds(240,45,100,24); 
    185188      general.add(size_l); 
    186189      general.add(size_tf); 
    187       size_l.setBounds(5,75,75,24); 
    188       size_tf.setBounds(85,75,150,24); 
    189190       
    190191      general.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "General Attributes"));        
    191       general.setMinimumSize(new Dimension(345,110)); 
    192       general.setPreferredSize(new Dimension(345,110)); 
    193       general.setMaximumSize(new Dimension(345,110)); 
    194       frame.add(general);          
    195       
     192       
     193      SpringLayout general_layout = new SpringLayout(); 
     194      general.setLayout(general_layout); 
     195       
     196      //Textfield distance to WEST border of container 
     197      Component[] labels = { id_l, file_l, size_l }; 
     198      int tf_dx = Helper.maxWidth(labels)+10;                
     199      //Maximal textfield width 
     200      int tf_wd = 200; 
     201      //Button width 
     202      int btn_wd = file_btn.getPreferredSize().width; 
     203       
     204      general_layout.putConstraint(SpringLayout.NORTH, id_l, 5, SpringLayout.NORTH, general); 
     205      general_layout.putConstraint(SpringLayout.WEST, id_l, 5, SpringLayout.WEST, general);       
     206      general_layout.putConstraint(SpringLayout.WEST, id_tf, tf_dx, SpringLayout.WEST, general); 
     207      general_layout.putConstraint(SpringLayout.NORTH, id_tf, 0, SpringLayout.NORTH, id_l); 
     208      general_layout.putConstraint(SpringLayout.EAST, id_tf, 0, SpringLayout.EAST, file_btn); 
     209       
     210      general_layout.putConstraint(SpringLayout.NORTH, file_l, 10, SpringLayout.SOUTH, id_l); 
     211      general_layout.putConstraint(SpringLayout.WEST, file_l, 5, SpringLayout.WEST, general);       
     212      general_layout.putConstraint(SpringLayout.WEST, file_tf, tf_dx, SpringLayout.WEST, general); 
     213      general_layout.putConstraint(SpringLayout.NORTH, file_tf, 0, SpringLayout.NORTH, file_l);       
     214      file_tf.setPreferredSize(new Dimension(tf_wd-btn_wd,file_tf.getPreferredSize().height)); 
     215      general_layout.putConstraint(SpringLayout.WEST, file_btn, 5, SpringLayout.EAST, file_tf); 
     216      general_layout.putConstraint(SpringLayout.NORTH, file_btn, 0, SpringLayout.NORTH, file_l); 
     217      general_layout.putConstraint(SpringLayout.EAST, general, 5, SpringLayout.EAST, file_btn); 
     218       
     219      general_layout.putConstraint(SpringLayout.NORTH, size_l, 10, SpringLayout.SOUTH, file_l); 
     220      general_layout.putConstraint(SpringLayout.WEST, size_l, 5, SpringLayout.WEST, general);       
     221      general_layout.putConstraint(SpringLayout.WEST, size_tf, tf_dx, SpringLayout.WEST, general); 
     222      general_layout.putConstraint(SpringLayout.NORTH, size_tf, 0, SpringLayout.NORTH, size_l); 
     223      general_layout.putConstraint(SpringLayout.EAST, size_tf, 0, SpringLayout.EAST, file_btn); 
     224       
     225      general_layout.putConstraint(SpringLayout.SOUTH, general, 10, SpringLayout.SOUTH, size_l); 
     226       
     227      frame.add(general);      
     228      frame.add(attr_l);     
    196229      frame.add(ok_btn);  
    197230      frame.add(cancel_btn); 
    198       frame.add(help_btn); 
    199       frame.add(new JLabel("Attributes marked with a star must be specified.")); 
    200        
    201       frame.setMinimumSize(new Dimension(355,175));      
    202       frame.setPreferredSize(new Dimension(355,175)); 
    203       frame.setMaximumSize(new Dimension(355,175)); 
    204        
    205       frame.pack();       
     231      frame.add(help_btn);     
     232       
     233      SpringLayout layout = new SpringLayout(); 
     234      frame.setLayout(layout); 
     235       
     236      layout.putConstraint(SpringLayout.NORTH, general, 5, SpringLayout.NORTH, frame.getContentPane()); 
     237      layout.putConstraint(SpringLayout.WEST, general, 5, SpringLayout.WEST, frame.getContentPane()); 
     238      //layout.putConstraint(SpringLayout.EAST, general, 5, SpringLayout.EAST, frame.getContentPane()); 
     239       
     240      layout.putConstraint(SpringLayout.NORTH, attr_l, 5, SpringLayout.SOUTH, general); 
     241      layout.putConstraint(SpringLayout.WEST, attr_l, 5, SpringLayout.WEST, frame.getContentPane()); 
     242      layout.putConstraint(SpringLayout.EAST, attr_l, 5, SpringLayout.EAST, frame.getContentPane()); 
     243       
     244       
     245      layout.putConstraint(SpringLayout.NORTH, ok_btn, 5, SpringLayout.SOUTH, attr_l); 
     246      layout.putConstraint(SpringLayout.NORTH, cancel_btn, 5, SpringLayout.SOUTH, attr_l); 
     247      layout.putConstraint(SpringLayout.NORTH, help_btn, 5, SpringLayout.SOUTH, attr_l); 
     248       
     249      layout.putConstraint(SpringLayout.WEST, ok_btn, 5, SpringLayout.WEST, frame.getContentPane()); 
     250      layout.putConstraint(SpringLayout.WEST, cancel_btn, 5, SpringLayout.EAST, ok_btn); 
     251      layout.putConstraint(SpringLayout.WEST, help_btn, 5, SpringLayout.EAST, cancel_btn); 
     252       
     253      layout.putConstraint(SpringLayout.SOUTH, frame.getContentPane(), 5, SpringLayout.SOUTH, ok_btn); 
     254      layout.putConstraint(SpringLayout.EAST, frame.getContentPane(), 5, SpringLayout.EAST, general); 
     255       
     256      frame.pack(); 
    206257    } 
    207258    id_tf.setText(id); 
     
    239290        return; 
    240291      } 
    241       update();  
    242       frame.setVisible(false); 
    243       frame.dispose(); 
    244       frame = null;            
     292      update(); 
     293      int i = updateFont(); 
     294      if(i==0) JOptionPane.showMessageDialog(frame,"Error while loading font file!\n Please choose another file\n","Font file not valid",JOptionPane.ERROR_MESSAGE); 
     295      else if(i==2) JOptionPane.showMessageDialog(frame,"Error while loading font file!\n Please choose another file\n","Font file not valid",JOptionPane.ERROR_MESSAGE); 
     296      else if(i==1) { 
     297        frame.setVisible(false); 
     298        frame.dispose(); 
     299        frame = null;   
     300      } 
    245301    } 
    246302    else if(e.getSource().equals(help_btn)) { 
  • trunk/src/vlcskineditor/resources/SubBitmap.java

    r99 r102  
    3030import java.awt.image.*; 
    3131import java.awt.event.*; 
     32import org.w3c.dom.Element; 
    3233import vlcskineditor.history.SubBitmapAddEvent; 
    3334/** 
     
    5051  JFrame frame = null; 
    5152  JTextField id_tf, x_tf, y_tf, width_tf, height_tf, nbframes_tf, fps_tf; 
    52   JButton file_btn, ok_btn, cancel_btn, help_btn; 
     53  JButton ok_btn, cancel_btn, help_btn; 
    5354  JFileChooser fc; 
    5455   
     
    5657   
    5758  SubBitmapEditWindow sbew = null; 
     59  /** 
     60   * Creates a new SubBitmap from a DOM Element 
     61   * @param e The DOM Element 
     62   * @param s_ The skin in which the SubBitmap is used 
     63   * @param parent_ The parent Bitmap. This is necessary to create the image represented by the SubBitmap. 
     64   */ 
     65   
     66  public SubBitmap(Element e, Skin s_, Bitmap parent_) { 
     67    s = s_; 
     68    parent = parent_; 
     69    type = "Bitmap"; 
     70    if(e.hasAttribute("id")) id = e.getAttribute("id"); 
     71    if(e.hasAttribute("x")) x = Integer.parseInt(e.getAttribute("x")); 
     72    if(e.hasAttribute("y")) y = Integer.parseInt(e.getAttribute("y")); 
     73    if(e.hasAttribute("width")) width = Integer.parseInt(e.getAttribute("width")); 
     74    if(e.hasAttribute("height")) height = Integer.parseInt(e.getAttribute("height")); 
     75    created = true; 
     76  } 
    5877   
    5978  /** 
     
    94113   */ 
    95114  public void updateImage() { 
    96     if(parent.image != null) image = parent.image.getSubimage(x,y,width,height);         
     115    if(parent.image != null) image = parent.image.getSubimage(x,y,width,height); 
    97116  }   
    98117  public void update() {     
     
    157176      fps_tf.setToolTipText("Only used in animated bitmaps; it is the number of frames (images) per seconds of the animation."); 
    158177      ok_btn = new JButton("OK"); 
    159       ok_btn.addActionListener(this); 
    160       ok_btn.setPreferredSize(new Dimension(70,25)); 
     178      ok_btn.addActionListener(this);       
    161179      cancel_btn = new JButton("Cancel"); 
    162       cancel_btn.addActionListener(this); 
    163       cancel_btn.setPreferredSize(new Dimension(70,25)); 
     180      cancel_btn.addActionListener(this);       
    164181      help_btn = new JButton("Help"); 
    165182      help_btn.addActionListener(this); 
    166       help_btn.setPreferredSize(new Dimension(70,25)); 
     183      JLabel attr_l = new JLabel("* Attributes marked with a star must be specified."); 
     184       
     185      //Distance of textfields to WEST edge of container 
     186      Component[] labels = { id_l, x_l, y_l, width_l, height_l, nbframes_l, fps_l}; 
     187      int tf_dx = Helper.maxWidth(labels)+10; 
     188      //Max. textfield width 
     189      int tf_wd = 200; 
    167190       
    168191      JPanel general = new JPanel(null); 
    169192      general.add(id_l); 
    170193      general.add(id_tf); 
    171       id_l.setBounds(5,15,75,24); 
    172       id_tf.setBounds(85,15,150,24);        
    173       general.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "General Attributes"));        
    174       general.setMinimumSize(new Dimension(345,50)); 
    175       general.setPreferredSize(new Dimension(345,50)); 
    176       general.setMaximumSize(new Dimension(345,50)); 
     194      id_tf.setPreferredSize(new Dimension(tf_wd,id_tf.getPreferredSize().height)); 
     195      general.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "General Attributes")); 
     196      SpringLayout general_layout = new SpringLayout(); 
     197      general.setLayout(general_layout); 
     198      general_layout.putConstraint(SpringLayout.NORTH, id_l, 5, SpringLayout.NORTH, general); 
     199      general_layout.putConstraint(SpringLayout.WEST, id_l, 5, SpringLayout.WEST, general);       
     200      general_layout.putConstraint(SpringLayout.WEST, id_tf, tf_dx, SpringLayout.WEST, general); 
     201      general_layout.putConstraint(SpringLayout.NORTH, id_tf, 0, SpringLayout.NORTH, id_l); 
     202      general_layout.putConstraint(SpringLayout.EAST, general, 5, SpringLayout.EAST, id_tf); 
     203      general_layout.putConstraint(SpringLayout.SOUTH, general, 10, SpringLayout.SOUTH, id_l); 
    177204      frame.add(general); 
    178205       
     
    180207      bounds.add(x_l); 
    181208      bounds.add(x_tf); 
     209      x_tf.setPreferredSize(new Dimension(tf_wd,x_tf.getPreferredSize().height)); 
    182210      bounds.add(y_l); 
    183211      bounds.add(y_tf); 
     212      y_tf.setPreferredSize(new Dimension(tf_wd,y_tf.getPreferredSize().height)); 
    184213      bounds.add(width_l); 
    185214      bounds.add(width_tf); 
     215      width_tf.setPreferredSize(new Dimension(tf_wd,width_tf.getPreferredSize().height)); 
    186216      bounds.add(height_l); 
    187217      bounds.add(height_tf); 
    188       x_l.setBounds(5,15,75,24); 
    189       x_tf.setBounds(85,15,150,24);       
    190       y_l.setBounds(5,45,75,24); 
    191       y_tf.setBounds(85,45,150,24); 
    192       width_l.setBounds(5,75,75,24); 
    193       width_tf.setBounds(85,75,150,24); 
    194       height_l.setBounds(5,105,75,24); 
    195       height_tf.setBounds(85,105,150,24); 
    196       bounds.setMinimumSize(new Dimension(345,145)); 
    197       bounds.setPreferredSize(new Dimension(345,145)); 
    198       bounds.setMaximumSize(new Dimension(345,145)); 
     218      height_tf.setPreferredSize(new Dimension(tf_wd,height_tf.getPreferredSize().height)); 
    199219      bounds.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Position and Dimension Attributes"));        
     220      SpringLayout bounds_layout = new SpringLayout(); 
     221      bounds.setLayout(bounds_layout); 
     222      bounds_layout.putConstraint(SpringLayout.NORTH, x_l, 5, SpringLayout.NORTH, bounds); 
     223      bounds_layout.putConstraint(SpringLayout.WEST, x_l, 5, SpringLayout.WEST, bounds);       
     224      bounds_layout.putConstraint(SpringLayout.WEST, x_tf, tf_dx, SpringLayout.WEST, bounds); 
     225      bounds_layout.putConstraint(SpringLayout.NORTH, x_tf, 0, SpringLayout.NORTH, x_l); 
     226      bounds_layout.putConstraint(SpringLayout.EAST, bounds, 5, SpringLayout.EAST, x_tf);       
     227      bounds_layout.putConstraint(SpringLayout.NORTH, y_l, 10, SpringLayout.SOUTH, x_l); 
     228      bounds_layout.putConstraint(SpringLayout.WEST, y_l, 5, SpringLayout.WEST, bounds);       
     229      bounds_layout.putConstraint(SpringLayout.WEST, y_tf, tf_dx, SpringLayout.WEST, bounds); 
     230      bounds_layout.putConstraint(SpringLayout.NORTH, y_tf, 0, SpringLayout.NORTH, y_l); 
     231      bounds_layout.putConstraint(SpringLayout.EAST, y_tf, 0, SpringLayout.EAST, x_tf); 
     232      bounds_layout.putConstraint(SpringLayout.NORTH, width_l, 10, SpringLayout.SOUTH, y_l); 
     233      bounds_layout.putConstraint(SpringLayout.WEST, width_l, 5, SpringLayout.WEST, bounds);       
     234      bounds_layout.putConstraint(SpringLayout.WEST, width_tf, tf_dx, SpringLayout.WEST, bounds); 
     235      bounds_layout.putConstraint(SpringLayout.NORTH, width_tf, 0, SpringLayout.NORTH, width_l); 
     236      bounds_layout.putConstraint(SpringLayout.EAST, width_tf, 0, SpringLayout.EAST, x_tf); 
     237      bounds_layout.putConstraint(SpringLayout.NORTH, height_l, 10, SpringLayout.SOUTH, width_l); 
     238      bounds_layout.putConstraint(SpringLayout.WEST, height_l, 5, SpringLayout.WEST, bounds);       
     239      bounds_layout.putConstraint(SpringLayout.WEST, height_tf, tf_dx, SpringLayout.WEST, bounds); 
     240      bounds_layout.putConstraint(SpringLayout.NORTH, height_tf, 0, SpringLayout.NORTH, height_l); 
     241      bounds_layout.putConstraint(SpringLayout.EAST, height_tf, 0, SpringLayout.EAST, x_tf);       
     242      bounds_layout.putConstraint(SpringLayout.SOUTH, bounds, 10, SpringLayout.SOUTH, height_l); 
    200243      frame.add(bounds); 
    201244       
     
    204247      animation.add(nbframes_tf); 
    205248      animation.add(fps_l); 
    206       animation.add(fps_tf); 
    207       nbframes_l.setBounds(5,15,150,24); 
    208       nbframes_tf.setBounds(160,15,150,24); 
    209       fps_l.setBounds(5,45,150,24); 
    210       fps_tf.setBounds(160,45,150,24); 
    211       animation.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Animation Attributes"));        
    212       animation.setMinimumSize(new Dimension(345,80)); 
    213       animation.setPreferredSize(new Dimension(345,80)); 
    214       animation.setMaximumSize(new Dimension(345,80));       
     249      animation.add(fps_tf);      
     250      animation.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Animation Attributes")); 
     251      SpringLayout ani_layout = new SpringLayout(); 
     252      animation.setLayout(ani_layout);       
     253      nbframes_tf.setPreferredSize(new Dimension(tf_wd,nbframes_tf.getPreferredSize().height)); 
     254      ani_layout.putConstraint(SpringLayout.NORTH, nbframes_l, 5, SpringLayout.NORTH, animation); 
     255      ani_layout.putConstraint(SpringLayout.WEST, nbframes_l, 5, SpringLayout.WEST, animation);       
     256      ani_layout.putConstraint(SpringLayout.WEST, nbframes_tf, tf_dx, SpringLayout.WEST, animation); 
     257      ani_layout.putConstraint(SpringLayout.NORTH, nbframes_tf, 0, SpringLayout.NORTH, nbframes_l); 
     258      ani_layout.putConstraint(SpringLayout.EAST, animation, 5, SpringLayout.EAST, nbframes_tf); 
     259      ani_layout.putConstraint(SpringLayout.NORTH, fps_l, 10, SpringLayout.SOUTH, nbframes_l); 
     260      ani_layout.putConstraint(SpringLayout.WEST, fps_l, 5, SpringLayout.WEST, animation);       
     261      ani_layout.putConstraint(SpringLayout.WEST, fps_tf, tf_dx, SpringLayout.WEST, animation); 
     262      ani_layout.putConstraint(SpringLayout.NORTH, fps_tf, 0, SpringLayout.NORTH, fps_l); 
     263      ani_layout.putConstraint(SpringLayout.EAST, fps_tf, 0, SpringLayout.EAST, nbframes_tf); 
     264      ani_layout.putConstraint(SpringLayout.SOUTH, animation, 10, SpringLayout.SOUTH, fps_l);      
    215265      frame.add(animation); 
    216266      
     
    218268      frame.add(cancel_btn); 
    219269      frame.add(help_btn); 
    220       frame.add(new JLabel("* must be specified.")); 
    221        
    222       frame.setMinimumSize(new Dimension(355,355));      
    223       frame.setPreferredSize(new Dimension(355,355)); 
    224       frame.setMaximumSize(new Dimension(355,355)); 
    225        
    226       frame.pack(); 
    227        
     270      frame.add(attr_l); 
     271       
     272      SpringLayout layout = new SpringLayout(); 
     273      frame.setLayout(layout); 
     274       
     275      layout.putConstraint(SpringLayout.NORTH, general, 5, SpringLayout.NORTH, frame.getContentPane()); 
     276      layout.putConstraint(SpringLayout.WEST, general, 5, SpringLayout.WEST, frame.getContentPane()); 
     277       
     278      layout.putConstraint(SpringLayout.NORTH, bounds, 5, SpringLayout.SOUTH, general); 
     279      layout.putConstraint(SpringLayout.WEST, bounds, 5, SpringLayout.WEST, frame.getContentPane()); 
     280       
     281      layout.putConstraint(SpringLayout.NORTH, animation, 5, SpringLayout.SOUTH, bounds); 
     282      layout.putConstraint(SpringLayout.WEST, animation, 5, SpringLayout.WEST, frame.getContentPane()); 
     283       
     284      layout.putConstraint(SpringLayout.NORTH, attr_l, 5, SpringLayout.SOUTH, animation); 
     285      layout.putConstraint(SpringLayout.WEST, attr_l, 5, SpringLayout.WEST, frame.getContentPane()); 
     286      layout.putConstraint(SpringLayout.EAST, attr_l, 5, SpringLayout.EAST, frame.getContentPane()); 
     287       
     288       
     289      layout.putConstraint(SpringLayout.NORTH, ok_btn, 5, SpringLayout.SOUTH, attr_l); 
     290      layout.putConstraint(SpringLayout.NORTH, cancel_btn, 5, SpringLayout.SOUTH, attr_l); 
     291      layout.putConstraint(SpringLayout.NORTH, help_btn, 5, SpringLayout.SOUTH, attr_l); 
     292       
     293      layout.putConstraint(SpringLayout.WEST, ok_btn, 5, SpringLayout.WEST, frame.getContentPane()); 
     294      layout.putConstraint(SpringLayout.WEST, cancel_btn, 5, SpringLayout.EAST, ok_btn); 
     295      layout.putConstraint(SpringLayout.WEST, help_btn, 5, SpringLayout.EAST, cancel_btn); 
     296       
     297      layout.putConstraint(SpringLayout.SOUTH, frame.getContentPane(), 5, SpringLayout.SOUTH, ok_btn); 
     298      layout.putConstraint(SpringLayout.EAST, frame.getContentPane(), 5, SpringLayout.EAST, general); 
     299       
     300      frame.pack();       
    228301    } 
    229302    id_tf.setText(id);     
     
    254327        } 
    255328      } 
    256       if(Integer.parseInt(width_tf.getText())<1) { 
    257         JOptionPane.showMessageDialog(frame,"Width must be greater 0!","Width not valid",JOptionPane.INFORMATION_MESSAGE); 
     329      if(Integer.parseInt(height_tf.getText())<1) { 
     330        JOptionPane.showMessageDialog(frame,"height must be greater 0!","height not valid",JOptionPane.INFORMATION_MESSAGE); 
    258331        return; 
    259332      } 
     
    262335        return; 
    263336      } 
    264       if(Integer.parseInt(x_tf.getText())+Integer.parseInt(width_tf.getText())>parent.image.getWidth()) { 
     337      if(Integer.parseInt(x_tf.getText())+Integer.parseInt(height_tf.getText())>parent.image.getHeight()) { 
    265338        JOptionPane.showMessageDialog(frame,"Specified dimensions are outside the parent bitmap!","Dimension not valid",JOptionPane.INFORMATION_MESSAGE); 
    266339        return; 
     
    303376    x_tf.removeKeyListener(sbew); 
    304377    y_tf.removeKeyListener(sbew); 
    305     width_tf.removeKeyListener(sbew); 
     378    height_tf.removeKeyListener(sbew); 
    306379    height_tf.removeKeyListener(sbew); 
    307380    frame.removeWindowListener(sbew); 
     
    312385  public String returnCode(String indent) { 
    313386    String code=indent+"<SubBitmap id=\""+id+"\" x=\""+String.valueOf(x)+"\" y=\""+String.valueOf(y)+"\""; 
    314     code+=" width=\""+String.valueOf(width)+"\"  height=\""+String.valueOf(height)+"\""; 
     387    code+=" height=\""+String.valueOf(height)+"\"  height=\""+String.valueOf(height)+"\""; 
    315388    if (nbframes!=NBFRAMES_DEFAULT) code+=" nbframes=\""+String.valueOf(nbframes)+"\""; 
    316389    if (fps!=FPS_DEFAULT) code+=" fps=\""+String.valueOf(fps)+"\"";