Hallo Leute,
habe gerade ein komisches Problem.
Ich erstelle JDialog und JFrame, aber mein inhalt wird nur im Frame angezeigt warum?
Aufgerufen wird das ganze aus einer anderen Klasse..über diesen aufruf
new SearchResultDialog(resultlistOfFiles,applicationFr ame);
Das ist die klasse...
über etwaige hilfe freue ich mich sehr!
public class SearchResultDialog
extends JDialog
{
//~ Constructors .................................................. .................................................. .......
/**
* Creates a new SearchResult object.
*
* @param searchResult List of search-result files.
* @param frame Frame to show this dialog in.
*/
public SearchResultDialog( List<File> searchResult, JFrame frame )
{
super( frame );
setTitle( "Suchergebnis" );
_searchResult = searchResult;
initDialog();
}
//~ Methods .................................................. .................................................. ............
/**
* Init the searchResult frame.
*/
private void initDialog()
{
// _gl = new GridBagLayout();
// getContentPane().setLayout( _gl );
// TODO show result list here with possibility to open each file directly
JTextArea _textArea = new JTextArea();
final JScrollPane scroller = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroller.setViewportView(_textArea);
scroller.setSize(300,300);
Iterator<File> listIterator = _searchResult.iterator();
int i = 0;
while (listIterator.hasNext()) {
File f = listIterator.next();
_textArea.append(f.getAbsolutePath()+"\n\r");
i++;
}
_textArea.append("\n\r"+i+" files found");
setSize(300,300);
setMaximumSize(new Dimension(300,300));
JFrame _resultFrame = new JFrame();
_resultFrame.setSize(300,300);
_resultFrame.add(scroller);
_resultFrame.setVisible(true);
//
JPanel jp = new JPanel();
jp.add(scroller);
jp.setMaximumSize(new Dimension(300,300));
JApplicationView.centerOnScreen(_resultFrame);
JApplicationView.centerOnScreen(this);
add(jp);
pack();
setVisible(true);
} // end method initDialog
//~ Instance variables .................................................. .................................................. .
/**
* LayoutManager for search result frame.
*/
private GridBagLayout _gl;
/**
* List of search-result files to display in this dialog.
*/
private List<File> _searchResult;
} // end class SearchResultDialog
habe gerade ein komisches Problem.
Ich erstelle JDialog und JFrame, aber mein inhalt wird nur im Frame angezeigt warum?
Aufgerufen wird das ganze aus einer anderen Klasse..über diesen aufruf
new SearchResultDialog(resultlistOfFiles,applicationFr ame);
Das ist die klasse...
über etwaige hilfe freue ich mich sehr!
public class SearchResultDialog
extends JDialog
{
//~ Constructors .................................................. .................................................. .......
/**
* Creates a new SearchResult object.
*
* @param searchResult List of search-result files.
* @param frame Frame to show this dialog in.
*/
public SearchResultDialog( List<File> searchResult, JFrame frame )
{
super( frame );
setTitle( "Suchergebnis" );
_searchResult = searchResult;
initDialog();
}
//~ Methods .................................................. .................................................. ............
/**
* Init the searchResult frame.
*/
private void initDialog()
{
// _gl = new GridBagLayout();
// getContentPane().setLayout( _gl );
// TODO show result list here with possibility to open each file directly
JTextArea _textArea = new JTextArea();
final JScrollPane scroller = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroller.setViewportView(_textArea);
scroller.setSize(300,300);
Iterator<File> listIterator = _searchResult.iterator();
int i = 0;
while (listIterator.hasNext()) {
File f = listIterator.next();
_textArea.append(f.getAbsolutePath()+"\n\r");
i++;
}
_textArea.append("\n\r"+i+" files found");
setSize(300,300);
setMaximumSize(new Dimension(300,300));
JFrame _resultFrame = new JFrame();
_resultFrame.setSize(300,300);
_resultFrame.add(scroller);
_resultFrame.setVisible(true);
//
JPanel jp = new JPanel();
jp.add(scroller);
jp.setMaximumSize(new Dimension(300,300));
JApplicationView.centerOnScreen(_resultFrame);
JApplicationView.centerOnScreen(this);
add(jp);
pack();
setVisible(true);
} // end method initDialog
//~ Instance variables .................................................. .................................................. .
/**
* LayoutManager for search result frame.
*/
private GridBagLayout _gl;
/**
* List of search-result files to display in this dialog.
*/
private List<File> _searchResult;
} // end class SearchResultDialog
Comment