Note that there are some explanatory texts on larger screens.

plurals
  1. POComponent not updating on my jpanel
    text
    copied!<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/13314336/jlabel-only-shows-if-initcomponents-is-deleted">JLabel only shows if initComponents() is deleted</a> </p> </blockquote> <p>JavaApplication1.java </p> <p>this is where Im calling my separate Panel.</p> <pre><code>/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package javaapplication1; import javax.swing.JFrame; /** * * @author Aires */ public class JavaApplication1 { /** * @param args the command line arguments */ public static void main(String[] args) { JFrame f = new JFrame(); NewJPanel n1 = new NewJPanel(); f.add(n1); f.pack(); f.show(); } } </code></pre> <p>newJPanel.java im creating new JLabel to add in my current panel, but when I run the program, its not showing up. </p> <pre><code>/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * NewJPanel.java * * Created on Nov 10, 2012, 3:07:31 PM */ package javaapplication1; import javax.swing.JLabel; /** * * @author Aires */ public class NewJPanel extends javax.swing.JPanel { /** Creates new form NewJPanel */ public NewJPanel() { //pag kinoment ko ito, tsaka lang lamalabas yung jlabel. initComponents(); //dito Sir, di siya nalalagay sa panel. JLabel n = new JLabel(); n.setText("asdasdasd"); this.add(n); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // &lt;editor-fold defaultstate="collapsed" desc="Generated Code"&gt; private void initComponents() { jLabel1 = new javax.swing.JLabel(); jLabel1.setText("jLabel1"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(175, 175, 175) .addComponent(jLabel1) .addContainerGap(191, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(127, 127, 127) .addComponent(jLabel1) .addContainerGap(159, Short.MAX_VALUE)) ); }// &lt;/editor-fold&gt; // Variables declaration - do not modify private javax.swing.JLabel jLabel1; // End of variables declaration } </code></pre> <p>The JLabel that I coded to create is not showing, it only shows when I comment out the //initComponents(); Any solution to this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload