Dersev 0 Newbie Poster

Hello
I have a small problem with JList in external class file_tree.
What should I add, write to show this JList in panel controlArea ?
My application have a few files
Core and two external classes.


Code below
This is Core File

import javax.swing.*;
import javax.swing.JFrame.*;
import java.awt.event.*;
import java.awt.*;
import java.util.*;
public class core extends JFrame implements MouseListener{
	public static JPanel drawArea = new JPanel();
	 public static void main (String[] args){
		  new core();
	 }
	
	 public core() {
		 Container content = getContentPane();
			content.setBackground(Color.LIGHT_GRAY);
		 JPanel controlArea = new JPanel(new GridLayout(3,1));
		 			
		 controlArea.add(new ComboBoxPanel("Czcionki"));
		 controlArea.add(new file_tree("list"));
		 add(controlArea, BorderLayout.EAST);
		 		 
		 drawArea.setPreferredSize(new Dimension(400, 0));
		 drawArea.setBorder(BorderFactory.createLineBorder(Color.blue,2));
		 drawArea.setBackground(Color.white);
		 add(drawArea, BorderLayout.WEST);
		 pack();
		 setVisible(true);
	 }

	@Override
	public void mouseClicked(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}	
	 
}

Here is file_tree but I changed this to JList

import java.io.File;
import java.awt.*;
import javax.swing.*;

public class file_tree extends JPanel {
	
	private JList dataList;
	public file_tree(String title){
		
		setBackground(Color.LIGHT_GRAY);
		setBorder(BorderFactory.createTitledBorder(title));
		
		DefaultListModel model = new DefaultListModel();
		File my_dir = new File(".");
		assert(my_dir.exists()); // the directory exists
		assert(my_dir.isDirectory()); // and is actually a directory
		
	
		String[] filenames_in_dir = my_dir.list();
		
		new JList(filenames_in_dir);
		 		 		 
		 // The value of the JList model property is an object that provides
		 // a read-only view of the data.  It was constructed automatically.
		 
		 JScrollPane scrollPane = new JScrollPane(dataList);
	
		 				 		 				 		 
	}	
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.