Hello Is/how it possible to create a layout in a dialog that allows single record form entry with the labels and text edit fields left-right with a cancel/commit button AND also have below it a listing scrollpane? On the scrollpane how do I build the scrollable client dynamically from an iterator of objects? It is uniquely easy in html, but how in swing? tia.
a few nested panels should do it panel1(GridLayout) for your labels/textfields panlel2(FlowLayout) for your buttons panel3(BorderLayout) - panel1(CENTER),panel2(SOUTH) panel4(BorderLayout) - panel3(NORTH), JScrollPane(JList)(CENTER) now add panel4 to the dialog
Hello Thank you, however I cant understand why the code below is failing. All I am trying to do is add the JPanel to another JPanel. What syntax could be wrong? No matter what random cast I put before it it claims an identifier missing. I know from the jd that JPanel inherits the add method from container, but that does not help me. Can you? and more broadly what dont I understand? I created the objects and I am trying to add one object which is a descendent of a Component to another class that inherits the ability to add Components. tia.
public static void main (String[] args) { Dialog2 dlg2 = new Dialog2(); dlg2.setLocation(200,200); dlg2.setSize(250,300); dlg2.setVisible(true); } }
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
> Why does the code below display the dialog but not the panels?
you add all your components to finalPanel you add panel1 to the dialog you haven't added finalPanel to panel1 add this line to the end of the constructor panel1.add(finalPanel);
formFields.add(new JLabel("Label"),new JTextField("Data")); is this one of the newer java versions? normally the add would be formFields.add(new JLabel("Label")); formFields.add(new JTextField("Data"));
you are mixing awt/swing components (using Frame) - this could lead to problems later on - change to JFrame
I see you had an attempt at the code tags (similar to my first go at it) click the code button when the tags appear - paste your code between the tags
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.