Welcome on MasterOf13FPS! MasterOf13FPS

Register today or sign up if you are already a member and never miss any cool content again :)

Gui Modules Ausblenden

MasterOf13FPS

Administrator
Staff member
Administrator
MasterOf13FPS
Joined
Jul 11, 2020
Messages
0
Reaction score
25
Points
0
Hallo ich habe ein externes Gui und ich möchte das Module Gui darauf ausblenden Hier ist der Code:



public class externalGui extends JFrame {





private Color titleColor = new Color(0xFFFFFF);

private Color bannerColor = new Color(0x16a085);

private Color lblColor = new Color(0x000000);

private Color txtColor = new Color(0x000033);

private Color btnColor = new Color(0x000033);

private Color bindColor = new Color(0x000000);





private JPanel contentPane;

private String name = Main.Client_NAME;



public static ArrayList<JButton> btnList = new ArrayList<JButton>();

public static ArrayList<JTextField> txtList = new ArrayList<JTextField>();



public externalGui() {



setResizable(false);



final File f = Main.saveFile;



setTitle(name);

setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);



int modules = Main.moduleManager.modules.size();



int size = (modules + 2) * 35;



int y = 45;

setBounds(100, 100, 320, size);

contentPane = new JPanel();

contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));

contentPane.setLayout(new BorderLayout(0, 0));

setContentPane(contentPane);

contentPane.setLayout(null);



JPanel panel = new JPanel();

panel.setBackground(bannerColor);

panel.setBounds(0, 0, 320, 36);

this.contentPane.add(panel);

panel.setLayout(null);



JLabel title = new JLabel(name + " Gui");

title.setForeground(titleColor);

title.setFont(new Font("Futura", Font.PLAIN, 24));

title.setBounds(10, 5, 240, 25);

panel.add(title);



for (final Module m : Main.moduleManager.modules) {



JLabel lbl = new JLabel(m.getName() + ":");

lbl.setForeground(lblColor);

lbl.setBounds(10, y, 100, 23);

contentPane.add(lbl);



final JButton btn = new JButton("false");

btn.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

Main.moduleManager.getModule(m.getClass()).toggleModule();

btn.setText(Boolean.toString(Main.moduleManager.getModule(m.getClass()).getState()));

}

});

btn.setForeground(txtColor);

btn.setBackground(btnColor);

btn.setBounds(120, y, 99, 23);

btnList.add(btn);

contentPane.add(btn);







y = y + 35;

}



}



}
 
Last edited by a moderator:
Erstmal:
1. Klassennamen schreibt man groß.
2. Bitte formatier deinen Code anständig.
3. Wieso sind manche Local Variables als final gekennzeichnet?

Dann zu deinem Problem:
In der for-Schleife überprüfst du einfach, ob der Name des Modules "GUI" ist, und wenn das nicht der Fall ist, erstellst du eben das Label und der Button.
 
shape1
shape2
shape3
shape4
shape5
shape6
Back
Top