I was wondering if is possible to use JPanels without JFrames because I am making a program that is asking to write a failure report.
I am using JOptionpane for new window but every time I try to add a scroll bar to the textArea, it just disappears from the screen but if I do that in JFrames it doesn't. I need to use JPanels because I have 2 Jpanel in one frame and everyone of them has to have a scroll bar separately.
public class aa {
private static JScrollPane pane;
public static void main(String[] arg){
JPanel panel = new JPanel();
panel.setPreferredSize(new Dimension(425, 400));
panel.setLayout(null);
JLabel labelName= new JLabel("Name and Surname");
JTextField textFieldName = new JTextField();
JLabel labelFailSubject= new JLabel("Fail Subject");
JTextField textFieldFailSubject = new JTextField(15);
JLabel labelTime= new JLabel("Fail Time");
JTextField textFieldFailTime = new JTextField(8);
JLabel labelFailDate = new JLabel("Fail Date");
JTextField textFieldFailDate= new JTextField(8);
JLabel labelFailReport= new JLabel("Fail Report");
JTextArea textBoxFailReport = new JTextArea();
pane = new JScrollPane(textBoxFailReport);
panel.add(labelName);
panel.add(textFieldName);
panel.add(labelFailDate);
panel.add(textFieldFailDate);
panel.add(labelTime);
panel.add(textFieldFailTime);
panel.add(labelFailSubject);
panel.add(textFieldFailSubject);
panel.add(labelFailReport);
panel.add(textBoxFailReport);
textBoxFailReport.setLineWrap(true);
JOptionPane.showMessageDialog(null, panel, "Fail Report", JOptionPane.PLAIN_MESSAGE);
}
}