#How do I make it so that my String is above my frame and panel?

4 messages · Page 1 of 1 (latest)

daring mango
#

Hi! I have no idea why the String isn't above my frame and panel. Would appreciate some advice, please, thanks!

import javax.swing.DefaultListModel;
import javax.swing.JScrollPane;
import javax.swing.JList;
import javax.swing.JFrame;
import java.awt.Color;
import java.awt.BorderLayout;
import java.util.Random;
import javax.swing.JPanel;
import java.awt.Dimension;

public class CopyOfRaven{
    CopyOfRaven(){
     JFrame someFrame = new JFrame();
      DefaultListModel dz = new DefaultListModel();
      JList list = new JList(dz);
      JScrollPane scrollPane = new JScrollPane(list);  
     
       someFrame.add(scrollPane);
       someFrame.setTitle("."); //sets title
       someFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); //exit out of application
       someFrame.setResizable(false); //frame resizing true or false
       someFrame.setSize(500,700); //set x dimension, and y dimension of frame
       someFrame.getContentPane().setBackground(new Color(255,0,0)); //change frame bg color, by rgb
       someFrame.setLayout(new BorderLayout(10,10));
     
       someFrame.setVisible(true); //make frame visible
       
     JPanel asi = new JPanel();
     asi.setBackground(new Color(255,255,0));
     asi.setLayout(new BorderLayout(3,3));
     asi.setPreferredSize(new Dimension(500,700));
     asi.setVisible(true);
     someFrame.add(asi,BorderLayout.CENTER);
     String[] content = {"Once upon a midnight dreary, while I pondered, weak and weary,", "Over many a quaint and curious volume of forgotten lore—"," While I nodded, nearly napping, suddenly there came a tapping,"};
     
           for(String word : content) {
        dz.addElement(word);
     }
     
             
       
}
}
cedar anvilBOT
#

This post has been reserved for your question.

Hey @daring mango! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

cedar anvilBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.