Unity GameObject deaktivieren?

Ich habe ein Einstellungsmenü. Wenn ich in dieses Menü komme, möchte ich das, dass Panel sound sichtbar wird und das Panel keybinds unsichtbar. Das Problem ist allerdings, dass es nicht funktioniert. Es funktioniert nur wenn ich zB. auf den Button Sound oder Keybinds drücke, dann wird das eine sichtbar und das andere unsichtbar. (Wenn ich auf den Button Sound klicke, dann wird show_hide_sound() ausgeführt).

Allerdings werden mir so, am Anfang beide Panels angezeigt, obwohl ich bei der start() funktion das eine "deaktiviere".

Was könnte da der Fehler sein?

public GameObject sound;
public GameObject keybinds;

public int sound_zahl = 1;
public int keybind_zahl = 0;

void start()
   {
       keybinds.SetActive(false);
       sound.SetActive(true);
   }
public void show_hide_sound()
   {
       keybind_zahl = 0;
       if (sound_zahl == 0)
       {
           sound.SetActive(true);
           keybinds.SetActive(false);
           sound_zahl++;
       }
   }

public void show_hide_keybinds()
   {
           sound_zahl = 0;
           if (keybind_zahl == 0)
           {
               keybinds.SetActive(true);
               sound.SetActive(false);
               keybind_zahl++;
           }
       }
Computer, programmieren, Unity
Java JTable; Tabelle begrenzen?

Mein Problem ist das die Tabelle zu weit nach unten geht.

table.setSize(); habe ich schon versucht, funktioniert aber nicht.

Hier der Code:

JPanel profilname_panel = new JPanel();

      String[][] data = {
        { "test", ""},
        { "", ""},
        { "", ""},
        { "", ""},
        { "", ""},
        { "", ""},
     };
     String[] rows = { "Name", "Picture"};
     JTable table = new JTable(data, rows);    
     table.setDefaultEditor(Object.class, null);
     table.setCellSelectionEnabled(false);
     table.setFocusable(false);
     table.setAutoscrolls(false);
     table.setRowHeight(table.getRowHeight() + 60);
     profilname_panel.setLocation(20,20);
     profilname_panel.setSize(550,180);
     profilname_panel.add(new JScrollPane(table));
     profilname_speichern.add(profilname_panel);


       profilname_speichern.setVisible(true);

Das sieht dann so aus. Ich möchte aber das, die Tabelle nur so groß ist und man nach unten scrollen kann. Weil wenn ich jetzt das JPanel größer mache, dann geht es richtig. Ist nur nicht das was ich möchte.

Eigentlich soll es so wie auf den ersten Bild aussehen, mit den Unterschied das die Tabelle, diese größe hat und man dadurch runterscrollen kann.

Wie kann man die größe der Tabelle ändern?

Bild zum Beitrag
Computer, Java, Informatik, Java Swing
Weitere Inhalte können nur Nutzer sehen, die bei uns eingeloggt sind.