Hallo,
ich bekomme beim einbauen eines Hacks drei Exceptions und weiß nicht was falsch oder eventuell zu viel ist. In der Zeile 36 wird forum rot unterstrichen, ich weis nicht warum? Ich erhalte da die Exception:
Und in den Zeilen 43 und 192 erhalte ich die Exception:
, wobei ComponentFilterer rot unterstrichen ist?
Um die Datei auszuführen braucht man von meiner Homepage das Cheat- und Konfiguratinstool ShockCfg ShockCfg 3, man muss nur noch die Datei WriteCfg.java durch diese hier ersetzen. Bitte sagt mir wie ihr im Tool erwähnt werden möchtet, wenn ihr helfen könnt, weil es ist ein seriöses Tool!? :toll:
ich bekomme beim einbauen eines Hacks drei Exceptions und weiß nicht was falsch oder eventuell zu viel ist. In der Zeile 36 wird forum rot unterstrichen, ich weis nicht warum? Ich erhalte da die Exception:
Code:
The import forum cannot be resolved
Code:
ComponentFilterer cannot be resolved
Um die Datei auszuführen braucht man von meiner Homepage das Cheat- und Konfiguratinstool ShockCfg ShockCfg 3, man muss nur noch die Datei WriteCfg.java durch diese hier ersetzen. Bitte sagt mir wie ihr im Tool erwähnt werden möchtet, wenn ihr helfen könnt, weil es ist ein seriöses Tool!? :toll:
Java:
import java.io.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.plaf.metal.MetalComboBoxButton;
import javax.swing.plaf.metal.MetalComboBoxIcon;
import java.util.ArrayList;
import java.util.Locale;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.basic.BasicComboPopup;
import javax.swing.plaf.basic.ComboPopup;
import javax.swing.plaf.metal.MetalComboBoxUI;
import javax.swing.plaf.metal.MetalScrollBarUI;
import javax.swing.plaf.metal.MetalScrollButton;
import forum.customchooser.ComponentFilterer;
public class WriteCfg
{
private final JFileChooser dir;
private int returnval;
private File shock2exe;
private BufferedWriter bufferwrite;
private SetRes setres;
private ReadCfg readcfg;
private JFrame frame;
private JButton klick;
@SuppressWarnings("rawtypes")
public WriteCfg(SetRes setres, ReadCfg readcfg)
{
this.setSetres(setres);
this.setReadcfg(readcfg);
UIManager.put("OptionPane.questionDialog.border.background", new javax.swing.plaf.ColorUIResource(Color.GREEN));
UIManager.put("activeCaption", new javax.swing.plaf.ColorUIResource(Color.black));
UIManager.put("OptionPane.questionDialog.titlePane.background", new javax.swing.plaf.ColorUIResource(Color.BLACK));
UIManager.put("OptionPane.questionDialog.titlePane.foreground", new javax.swing.plaf.ColorUIResource(Color.GREEN));
UIManager.put("activeCaptionText", new javax.swing.plaf.ColorUIResource(Color.green));
UIManager.put("OptionPane.questionDialog.titlePane.shadow", new javax.swing.plaf.ColorUIResource(Color.GREEN));
javax.swing.plaf.metal.MetalLookAndFeel.setCurrentTheme(new NoBumpsTheme());
JDialog.setDefaultLookAndFeelDecorated(true);
//Inverting Colors for pressed Buttons
try {
UIManager.setLookAndFeel( new MyLookAndFeel() );
} catch (UnsupportedLookAndFeelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
JOptionPane optPane = new JOptionPane(setres.getTxt().getString("WriteCfgDia1"));
optPane.setOptionType(JOptionPane.DEFAULT_OPTION);
JDialog dia = optPane.createDialog(null, setres.getTxt().getString("WriteCfgDia1"));
dia.getRootPane().setBorder(BorderFactory.createLineBorder(Color.green, 3));
changeColor(dia.getComponents());
dia.setModal(true);
dia.setVisible(true);
colorizeUI();
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
klick = new JButton("Klick");
klick.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e)
{
JFileChooser chooser = new JFileChooser();
for(JComboBox j : ComponentFilterer.getComponents(chooser, JComboBox.class))
{
j.setUI(new MetalComboBoxUI() {
@Override
protected JButton createArrowButton()
{
MetalComboBoxButton j = (MetalComboBoxButton)super.createArrowButton();
j.setComboIcon(new MetalComboBoxIcon() {
private static final long serialVersionUID = -6616394682227867147L;
@Override
public void paintIcon(Component c, Graphics g, int x, int y)
{
int iconWidth = getIconWidth();
g.translate( x, y );
g.setColor(Color.GREEN);
g.drawLine( 0, 0, iconWidth - 1, 0 );
g.drawLine( 1, 1, 1 + (iconWidth - 3), 1 );
g.drawLine( 2, 2, 2 + (iconWidth - 5), 2 );
g.drawLine( 3, 3, 3 + (iconWidth - 7), 3 );
g.drawLine( 4, 4, 4 + (iconWidth - 9), 4 );
g.translate( -x, -y );
}
});
return j;
}
@Override
protected ComboPopup createPopup()
{
return new BasicComboPopup(comboBox) {
private static final long serialVersionUID = -9020472635073779841L;
@Override
protected JScrollPane createScroller()
{
JScrollPane j = super.createScroller();
j.getVerticalScrollBar().setUI(getNewScrollBarUI());
return j;
}
};
}
});
}
for(JScrollBar j : ComponentFilterer.getComponents(chooser, JScrollBar.class))
{
j.setUI(getNewScrollBarUI());
}
chooser.showOpenDialog(frame);
}
});
frame.add(klick);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
//Inverting Colors
UIManager.put("Button.select", Color.green);
//Filechooser opening
dir = new JFileChooser()
{
/**
*
*/
private static final long serialVersionUID = 1L;
public JDialog createDialog(Component parent)
{
JDialog d = super.createDialog(parent);
d.getContentPane().setBackground(Color.black);
return d;
}
};
changeColor(new Component[]{dir});
colorChooser(dir);
dir.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
returnval = dir.showDialog(null, setres.getTxt().getString("WriteCfgDia2"));
if (returnval == JFileChooser.APPROVE_OPTION)
{
shock2exe = dir.getSelectedFile();
try
{
//make shockcfg.cfg
bufferwrite = new BufferedWriter( new FileWriter("ShockCfg.ini"));
readcfg.setreadpath(shock2exe.getPath());
bufferwrite.write(readcfg.getreadpath());
//thx to Al_B
bufferwrite.write("\r\n");
Locale w = Locale.getDefault();
if(w.getLanguage().equalsIgnoreCase("de_DE"))
{
bufferwrite.write("de_DE");
}
else
{
bufferwrite.write("en_EN");
}
bufferwrite.write("\r\n");
bufferwrite.close();
}
catch (IOException ex)
{
System.out.println(setres.getTxt().getString("WriteCfgErr"));
System.out.println(ex);
System.exit(0);
}
}
else
{
System.exit(0);
}
}
private void colorizeUI()
{
String containing = "color";
List<String[]> uidefaults = getAllUIDefaults(containing);
System.out.println("Alle Properties die im Value das Wort: " + containing + " enthalten:");
System.out.println();
for(String[] s : uidefaults)
{
String key = s[0];
String value = s[1];
System.out.println(key+"="+value);
}
for(String[] s : uidefaults)
{
String key = s[0];
Object value;
if(key.toLowerCase().contains("foreground"))
value = Color.GREEN;
else if(key.toLowerCase().contains("gradient"))
value = Arrays.asList(new Object[]{0.3, 0.0, Color.GREEN, Color.GREEN, Color.GRAY});
else
value = Color.BLACK;
UIManager.put(key, value);
}
}
private List<String[]> getAllUIDefaults(String contains)
{
List<String[]> list = new ArrayList<String[]>();
UIDefaults u = UIManager.getLookAndFeelDefaults();
Set<Map.Entry<Object, Object>> set = u.entrySet();
List<String> keys = new ArrayList<String>();
for(Map.Entry<Object, Object> e : set)
{
if(e.getValue().toString().toLowerCase().contains(contains.trim().toLowerCase()) || contains.trim().equals(""))
keys.add(e.getKey().toString());
}
Collections.sort(keys);
for(String s : keys)
{
for(Map.Entry<Object, Object> e : set)
{
if(e.getKey().toString().equals(s))
{
list.add(new String[]{e.getKey().toString(), e.getValue().toString()});
}
}
}
return list;
}
private MetalScrollBarUI getNewScrollBarUI()
{
return new MetalScrollBarUI() {
@Override
protected JButton createDecreaseButton(int orientation)
{
decreaseButton = new MetalScrollButton(orientation, scrollBarWidth, isFreeStanding) {
private static final long serialVersionUID = -4409521721923690274L;
@Override
public void paint(Graphics g)
{
super.paint(g);
int width = getWidth();
int height = getHeight();
int w = width;
int h = height;
int arrowHeight = (height+1) / 4;
if(getDirection() == NORTH)
{
// Draw the arrow
g.setColor(Color.GREEN);
int startY = ((h+1) - arrowHeight) / 2;
int startX = (w / 2);
for (int line = 0; line < arrowHeight; line++)
{
g.drawLine( startX-line, startY+line, startX +line+1, startY+line);
}
}
else if(getDirection() == SOUTH)
{
// Draw the arrow
g.setColor(Color.GREEN);
int startY = (((h+1) - arrowHeight) / 2)+ arrowHeight-1;
int startX = (w / 2);
for (int line = 0; line < arrowHeight; line++)
{
g.drawLine( startX-line, startY-line, startX +line+1, startY-line);
}
}
else if(getDirection() == EAST)
{
// Draw the arrow
g.setColor(Color.GREEN);
int startX = (((w+1) - arrowHeight) / 2) + arrowHeight-1;
int startY = (h / 2);
for (int line = 0; line < arrowHeight; line++)
{
g.drawLine( startX-line, startY-line, startX -line, startY+line+1);
}
}
else if(getDirection() == WEST)
{
// Draw the arrow
g.setColor(Color.GREEN);
int startX = (((w+1) - arrowHeight) / 2);
int startY = (h / 2);
for (int line = 0; line < arrowHeight; line++)
{
g.drawLine( startX+line, startY-line, startX +line, startY+line+1);
}
}
}
};
return decreaseButton;
}
@Override
protected JButton createIncreaseButton(int orientation)
{
increaseButton = new MetalScrollButton(orientation, scrollBarWidth, isFreeStanding) {
private static final long serialVersionUID = 6260378271416327198L;
@Override
public void paint(Graphics g)
{
super.paint(g);
int width = getWidth();
int height = getHeight();
int w = width;
int h = height;
int arrowHeight = (height+1) / 4;
if(getDirection() == NORTH)
{
// Draw the arrow
g.setColor(Color.GREEN);
int startY = ((h+1) - arrowHeight) / 2;
int startX = (w / 2);
for (int line = 0; line < arrowHeight; line++)
{
g.drawLine( startX-line, startY+line, startX +line+1, startY+line);
}
}
else if(getDirection() == SOUTH)
{
// Draw the arrow
g.setColor(Color.GREEN);
int startY = (((h+1) - arrowHeight) / 2)+ arrowHeight-1;
int startX = (w / 2);
for (int line = 0; line < arrowHeight; line++)
{
g.drawLine( startX-line, startY-line, startX +line+1, startY-line);
}
}
else if(getDirection() == EAST)
{
// Draw the arrow
g.setColor(Color.GREEN);
int startX = (((w+1) - arrowHeight) / 2) + arrowHeight-1;
int startY = (h / 2);
for (int line = 0; line < arrowHeight; line++)
{
g.drawLine( startX-line, startY-line, startX -line, startY+line+1);
}
}
else if(getDirection() == WEST)
{
// Draw the arrow
g.setColor(Color.GREEN);
int startX = (((w+1) - arrowHeight) / 2);
int startY = (h / 2);
for (int line = 0; line < arrowHeight; line++)
{
g.drawLine( startX+line, startY-line, startX +line, startY+line+1);
}
}
}
};
return increaseButton;
}
};
}
public void colorChooser(JFileChooser chooser){
@SuppressWarnings("rawtypes")
java.util.List<JComboBox> boxes = getComponents(chooser, JComboBox.class);
for(@SuppressWarnings("rawtypes")
JComboBox box : boxes)
{
java.util.List<JButton> buttons = getComponents(box, JButton.class);
for(JButton button : buttons)
{
MetalComboBoxButton b = (MetalComboBoxButton)button;
b.setComboIcon(new MyIcon());
}
box.setForeground(Color.GREEN);
box.setBackground(Color.BLACK);
box.setBorder(BorderFactory.createLineBorder(Color.green));
}
}
public void changeColor(Component[] comp)
{
for(int x=0; x<comp.length; x++)
{
try
{
comp[x].setBackground(Color.black);
comp[x].setForeground(Color.green);
}
catch(Exception e) {}
if(comp[x] instanceof Container)
changeColor(((Container)comp[x]).getComponents());
}
}
public class MyIcon extends MetalComboBoxIcon
{
private static final long serialVersionUID = -6616394682227867147L;
public void paintIcon(Component c, Graphics g, int x, int y)
{
int iconWidth = getIconWidth();
g.translate( x, y );
g.setColor(Color.GREEN);
g.drawLine( 0, 0, iconWidth - 1, 0 );
g.drawLine( 1, 1, 1 + (iconWidth - 3), 1 );
g.drawLine( 2, 2, 2 + (iconWidth - 5), 2 );
g.drawLine( 3, 3, 3 + (iconWidth - 7), 3 );
g.drawLine( 4, 4, 4 + (iconWidth - 9), 4 );
g.translate( -x, -y );
}
}
public static <T> java.util.List<T> getComponents(Component component, Class<T> clazz)
{
java.util.List<T> comps = new ArrayList<T>();
if(clazz.isInstance(component))
{
comps.add(clazz.cast(component));
}
else if(component instanceof Container)
{
for(Component c : ((Container)component).getComponents())
{
comps.addAll(getComponents(c, clazz));
}
}
return comps;
}
public SetRes getSetres() {
return setres;
}
public void setSetres(SetRes setres) {
this.setres = setres;
}
public ReadCfg getReadcfg() {
return readcfg;
}
public void setReadcfg(ReadCfg readcfg) {
this.readcfg = readcfg;
}
}
Zuletzt bearbeitet: