Я пытаюсь создать чат-бота как простой проект, поэтому мне нужно сделать разговор простым пузырем чата, я его создал, но у меня проблема с прокруткой, которая не работает, вот основной код дизайна , chattingPane.layout должен быть нулевым.
для дополнительных демонстраций, botMessage - это то, как я организовал ярлыки чата
спасибо.
private void setDesign() {
// setting design
// panel
designPanel = new JPanel();
designPanel.setLayout(null);
designPanel.setBounds(0, 0, 500, 600);
designPanel.setBackground(Color.WHITE);
this.add(designPanel);
//for chatting
chattingPane = new JPanel();
chattingPane.setBounds(0,0, 500,500);
chattingPane.setLayout(null);
chattingScroll = new JScrollPane(chattingPane);
chattingScroll.setBounds(0, 0, 500, 500);
designPanel.add(chattingScroll);
// user input
userInput = new JTextField();
userInput.setBounds(10, 510, 380, 30);
userInput.requestFocusInWindow();
userInput.setBorder(BorderFactory.createLineBorder(Color.BLACK));
designPanel.add(userInput);
// send Button
sendButton = new JButton("Send");
sendButton.setBounds(393, 510, 70, 30);
sendButton.setBackground(Color.GRAY);
designPanel.add(sendButton);
}//end setDesign
private void botMessage(String m) {
createVoiceFile(m);
readVoiceFile();
JLabel MyBot = new JLabel(m);
Dimension size = MyBot.getPreferredSize();
MyBot.setIcon(new ImageIcon("robot2.jpg"));
MyBot.setBounds(5, bY, (int)size.getWidth() + 35, 30);
botLabel = new JLabel(new ImageIcon("botChatBg.jpg"));
botLabel.setBounds(35, bY, (int)size.getWidth() + 35, 30);
chattingPane.add(MyBot);
chattingPane.add(botLabel);
SwingUtilities.updateComponentTreeUI(this);
bY += 45;
uY += 45;
}// userMessage