Problem Netbeans Komponenten

Status
Nicht offen für weitere Antworten.
G

Gast

Gast
Netbeans Komponenten nachträglich zur GUI hinzufügen

Hallo,

ich möchte mit Netbeans eine Datenbankabfrage machen und mir die Ergebnisse in JLabel’s anzeigen. Diese sind später in einer Klasse die dann für jeden Datensatz einzeln erzeugt werden. ABER mein Problem ist das ich ja nicht immer gleich viele Komponenten benötige und somit muss ich diese Komponenten ja per Hand einfügen, aber das bekomme ich leider nicht hin.
netbeans.JPG

Ich habe jetzt zum Ausprobieren einfach eine ganze einfache Oberfläche mit einem JPanel erstellt mit dem ich testen wollte wie man so etwas am einfügt - leider aber ohne Erfolg.
Code:
package javaapplication19;
import java.awt.*;
public class NeuJFrame extends javax.swing.JFrame {
    
    /** Creates new form NeuJFrame */
    public NeuJFrame() {
        initComponents();
    }
    
    // <editor-fold defaultstate="collapsed" desc=" Erzeugter Quelltext ">
    private void initComponents() {
        javax.swing.JPanel jPanel;

        //Stelle 1--------------------

        jPanel = new javax.swing.JPanel();
        //Stelle 2 ---------------------
        //JLabel test wird erzeugt und zum Panel hinzugefügt aber nicht angezeigt
        javax.swing.JLabel test = new javax.swing.JLabel("Test");
        jPanel.add(test);
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        //Stelle 3 ---------------------
        //Stelle 4 ----------------------

        jLabel1.setText("jLabel1");

        org.jdesktop.layout.GroupLayout jPanelLayout = new org.jdesktop.layout.GroupLayout(jPanel);
        jPanel.setLayout(jPanelLayout);
        jPanelLayout.setHorizontalGroup(
            jPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanelLayout.createSequentialGroup()
                .addContainerGap(346, Short.MAX_VALUE)
                .add(jLabel1))
        );
        jPanelLayout.setVerticalGroup(
            jPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanelLayout.createSequentialGroup()
                .addContainerGap(134, Short.MAX_VALUE)
                .add(jLabel1))
        );

        [...]

        pack();
    }// </editor-fold>
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NeuJFrame().setVisible(true);
            }
        });
    }
    
    // Variablendeklaration - nicht modifizieren
    private javax.swing.JLabel jLabel1;
    // Ende der Variablendeklaration
    
}
Das in Zeile 21/22 erstellte Labelfeld ist aber leider nirgens zu sehen :(
 
G

Guest

Gast
oh ich hatte ja noch eine Zeile rausgenommen (--> Zeile 20/21), also das jLabel test mit der Beschriftung "Test" ist nicht zu sehen, das von Netbeans erstellte jLabel jLabel1 aber schon.
Also so sieht es aus:
netbeans2.JPG
 

*Hendrik

Bekanntes Mitglied
Gast hat gesagt.:
org.jdesktop.layout.GroupLayout jPanelLayout = new org.jdesktop.layout.GroupLayout(jPanel);
jPanel.setLayout(jPanelLayout);
jPanelLayout.setHorizontalGroup(
jPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanelLayout.createSequentialGroup()
.addContainerGap(346, Short.MAX_VALUE)
.add(jLabel1))
);
jPanelLayout.setVerticalGroup(
jPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanelLayout.createSequentialGroup()
.addContainerGap(134, Short.MAX_VALUE)
.add(jLabel1))
);

[...]

Bei dem verwendeten GroupLayout müsstest Du das Label (wie im Code .add(JLabel1)) dem Layout bzw. der entsprechenden Group hinzufügen - jPanel.add(test); bringt da nichts. Für Deine Problemstellung würde ich allerdings ein anderes Layout als das GroupLayout wählen.
 
Status
Nicht offen für weitere Antworten.
Ähnliche Java Themen
  Titel Forum Antworten Datum
M NetBeans und UTF8 Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
U Problem unter Netbeans 6.8 bei Farben IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
J NetBeans IDE 6.0.1 Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
V Problem mit einbinden externer Bibliotheken [NetBeans] IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
G NetBeans RCP Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
B ACHTUNG! Netbeans Update -Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
D Problem mit Freedesign unter NetBeans IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
A NetBeans GUI Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
S NetBeans IDE 5.5 Problem beim Kompilieren IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
A NetBeans 5.5 - Problem: Endlosschleife classpath scanning IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
Q Netbeans -CMP Entity Beans Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
S Netbeans 4.1 Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
E Problem Netbeans; Pfadangabe IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
M Problem mit netbeans 4.0 IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
A Problem mit NetBeans IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
A NetBeans: Layout-Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 11
R GUI-Problem mit NetBeans IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 9
MamaMia44 Ich habe problem mit Intelej Idea IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 8
U Problem mit Eclipse - WindowBuilder - memoryLeak? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 15
K Java Editor Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
B Eclipse Problem mit jar Datei? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
Robertop Eclipse EXE Icon fehlt im Explorer (Windows Problem?) IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
B Problem bei der Ausgabe IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 9
melaniemueller Eclipse Problem mit dem Debugger IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
S Problem mit BlueJ IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
1 Problem beim JavaFX installieren IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 20
Splayfer Problem mit der Eclipse Autovervollständigung... IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
R Eclipse Cursor Problem bei Eclipse IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
D Jenkins/Gradle maven-publish Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
F Eclipse Problem mit Aufhänger bei verschiedenen Prozessen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
H Selenium Problem mit Browsern IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
P Problem accessing /rap. Reason: ProxyServlet: /rap IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 0
V Eclipse:Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
P Eclipse Luna SR2 (4.4.2)- Problem bei hinzufügen von Software IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
P Eclipse Eclipse-Problem unter Debian IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 0
Tarrew Problem mit Maven und der Erkennung von generierten Antlr Files. IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 0
F Egit-Problem nach Merge-Konflikt IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 0
Y GIT remote Problem keine Synchronisation IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 0
N NetBeans Javadoc Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
E Eclipse Eclipse building workspace Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
fLooojava Eclipse Problem mit Template proposals IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
M NetBeans Problem mit eMail Programm IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 11
R Eclipse Problem beim Export als Executable Jar IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
S Problem mit Git IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
V Eclipse Eclipse Problem beim erstellen einer JAR IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
M Eclipse JavaEE IDE Problem mit Servlets IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
M Eclipse Problem mit Mac und Windows IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 9
B Eclipse SVN Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
M Eclipse Problem beim Projektimport mit user libraries IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
T Eclipse 'refreshing external folders' has encountered a problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
H NetBeans Export Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
A gdal problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
D Eclipse Autocomplete Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
M IDEA IntelliJ Subversion connection problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
F Eclipse Problem mit CVS Server IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
A Eclipse Matisse Problem ComboBoxen in real länger als in Vorschau IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
B Eclipse Eclipse Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
P Eclipse Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 14
B Eclipse Subversive + Helios Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 8
N Subclipse Problem: Blaues Rechteck! IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
U Problem mit Buttons beim Panel-Zeichnen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
T NetBeans Maven2 + IDE Variables + NB Actions: Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 7
S Problem mit javacc-Plugin für Eclipse IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 8
E Problem beim Ausführen von RCP GUI Tests mit Hudson IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
M Problem mit JSP IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
F CVS Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
Landei JDeveloper-Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
V Eclipse Galileo und Visual Editor Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 20
G Schon mal dieses Problem bei Eclipse gehabt? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
A Eclipse 3.4 Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 12
F Datenpfad problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
G Eclipse unter Ubuntu --- Problem mit deutschen Buchstaben IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
G eclipse problem beim ausführen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
W Ganymed - Encoding-Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
D problem mit Subclipse über Netzwerk IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
Y Eclipse 3.3 Problem mit Subversive(SVN) IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
I JTextArea Problem und Debugger IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
R RCP: Problem bei deklarativem LightWeightDecorator IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
P Eclipse u. CVS - Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 7
K JAVA Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
F Problem mit eclipse formatter, javadoc und generics. IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
der JoJo [eclipse]Kommunikations Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 7
B eclipse problem beim öffnen einer datei absturz IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
Q "Problem" mit SVN und (sub)Clipse IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 7
M Problem beim installieren? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
N Problem mit Integer.parseInt bei Eclipse IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 10
V Problem mit Eclipse IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
F Jasperreport - Parameterübergabe Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
C Problem mit eclipse 3.2.1 IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
D Problem mit Eclipse (throws java.io.I0Exception will nicht) IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
P BuildPath für externe JAR: Problem mit CVS IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
R parameter- problem bei iReport 1.2.5 IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
B NB - Problem mit Klassennamen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
M Problem mit SVN: BDB inkonsistent IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
T Eclipse 3.2 mag mich net (import problem) IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 8
T Problem mit Ant Script das andere Ant Scripte aufruft IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
K Ant Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
A Eclipse 3.1.2 Refresh Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
O Eclipse Linux Start Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
T Problem beim Import von Projekt IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3

Ähnliche Java Themen

Neue Themen


Oben