| .. | .. |
|---|
| 1259 | 1259 | |
|---|
| 1260 | 1260 | CreateTexturePanel(textures); |
|---|
| 1261 | 1261 | |
|---|
| 1262 | | - resourcecontainer.setSelectedIndex((int)(Math.random() * resourcecontainer.getTabCount())); |
|---|
| 1262 | + int tabCount = resourcecontainer.getTabCount(); |
|---|
| 1263 | + |
|---|
| 1264 | + if (tabCount > 0) |
|---|
| 1265 | + resourcecontainer.setSelectedIndex((int)(Math.random() * tabCount)); |
|---|
| 1263 | 1266 | |
|---|
| 1264 | 1267 | oe.toolboxPanel.add(textures); |
|---|
| 1265 | 1268 | |
|---|
| .. | .. |
|---|
| 134 | 134 | |
|---|
| 135 | 135 | try |
|---|
| 136 | 136 | { |
|---|
| 137 | | - BufferedImage image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name)); |
|---|
| 138 | | - |
|---|
| 137 | + BufferedImage image; |
|---|
| 138 | + |
|---|
| 139 | + if (name.endsWith("jpg")) |
|---|
| 140 | + // Much faster! |
|---|
| 141 | + image = new sun.awt.image.codec.JPEGImageDecoderImpl(ObjEditor.class.getClassLoader().getResourceAsStream(name)).decodeAsBufferedImage(); |
|---|
| 142 | + else |
|---|
| 143 | + image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name)); |
|---|
| 144 | + |
|---|
| 139 | 145 | // if (image.getWidth() > 48 && image.getHeight() > 48) |
|---|
| 140 | 146 | // { |
|---|
| 141 | 147 | // BufferedImage resized = new BufferedImage(48, 48, image.getType()); |
|---|