Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Zelleninhalte

Empfohlene Antworten

Veröffentlicht

String[][] rowData = {{"Wert", "Beschreibung"},{"", ""},

{"", ""},{"", ""},{"", ""},{"", ""},

{"", ""},{"", ""},{"", ""},{"", ""},{"", ""}};

Kann man in diesen String einen Vector einfügen oder so? Da ich das ganze für eine Tabelle brauche und meine ganzen Werte in einem Vector stehen.

Wie kann ich da jetzt einen Vector benutzen?

public class SparseTableModel extends AbstractTableModel

{

//Konstruktor

public SparseTableModel()

{

data = new Hashtable();

data.put("Wert", "Beschreibung");

}

//Methoden für das TableModel-Interface

public int getRowCount()

{

return 11;

}

public int getColumnCount()

{

return 2;

}

public String getColumnName(int columnIndex)

{

return "C" + columnIndex;

}

public Class getColumnClass(int columnIndex)

{

return String.class;

}

public boolean isCellEditable(int rowIndex, int columnIndex)

{

return rowIndex < size && columnIndex < size;

}

public Object getValueAt(int rowIndex, int columnIndex)

{

String key = "[" + rowIndex + "," + columnIndex + "]";

String value = (String)data.get(key);

return value == null ? "" : value;

}

public void setValueAt(Object aValue, int rowIndex, int columnIndex)

{

String key = "[" + rowIndex + "," + columnIndex + "]";

String value = (String)aValue;

if (value.length() <= 0)

{

data.remove(key);

}

else

{

data.put(key, value);

}

}

}

Hi

Du hast doch nun schon das Array gegen eine Hashtable ausgetauscht.

Wo ist nun das Problem den Hashtable gegen einen Vector zu tauschen ? ? ?

Ich weiss nicht ob Du es Dir nur sehr einfach machst und lieber fragst bevor Du nachdenkst oder ob ich Dein Problem nicht verstehe ? ? ?

Erbeere

nein, ich habe mich falsch ausgedrückt. ich will den Vector in meiner Hashtable haben, aber das geht glaube ich nicht, da ich bei einem Vector kein Key und Value habe.

Ich strng mich schon an das ich mein Probleme selber lösen kann, aber ich programmier Java noch nicht lange.

mh...

also die API-Dok sagt folgendes bei der Methode put() bei Hashtables:

put(Object key, Object value)

Heisst also Du kannst da einen Wert von Typ Object reinpacken.

Und ein vector ist ein Object....

also ich def. mir selber eine Key und beim Value kommt mein Vector rein. Danke ich werde es gleich mal testen.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.