如何绘制java聊天泡泡语音?

如何绘制java聊天泡泡语音?,java,Java,大家好,请帮助我, 我正在努力 制作用于聊天的Java桌面应用程序 ,我想在我的聊天应用程序中添加聊天表示,使UI风格的消息成为语音对话的泡泡,因此我想用Java代码绘制,请帮助我绘制代码或如何用Java代码绘制, 这是我的第一篇文章 谢谢你从你的问题和你在这里的时间来看,我认为你对java不太有经验,我无意冒犯你 相反,你可以像我那样做,这在这种情况下非常有效: 我创建了一个JLabel,并为其分配了一个ImageIcon,在下面的代码示例中,您将看到我创建了两个标签,在其中用作按钮,一个向上

大家好,请帮助我, 我正在努力

制作用于聊天的Java桌面应用程序 ,我想在我的聊天应用程序中添加聊天表示,使UI风格的消息成为语音对话的泡泡,因此我想用Java代码绘制,请帮助我绘制代码或如何用Java代码绘制, 这是我的第一篇文章
谢谢你

从你的问题和你在这里的时间来看,我认为你对java不太有经验,我无意冒犯你

相反,你可以像我那样做,这在这种情况下非常有效:

我创建了一个JLabel,并为其分配了一个ImageIcon,在下面的代码示例中,您将看到我创建了两个标签,在其中用作按钮,一个向上箭头和一个向下箭头用于列表:

private void buildPair() {
    //Make an ImageIcon Array (optional)
    ImageIcon image[] = new ImageIcon[2];
    //You create a new ImageIcon with the picture from your recouses, then you the the image and scale it, in this case its scaled to 20 by 20 pixel
    Image originalDown = new ImageIcon(ExtendedList.class.getResource("/Elements/Down Arrow Button.png")).getImage().getScaledInstance(20, 20, Image.SCALE_DEFAULT);
    Image originalUp = new ImageIcon(ExtendedList.class.getResource("/Elements/Up Arrow Button.png")).getImage().getScaledInstance(20, 20, Image.SCALE_DEFAULT);
    //Then I add the scaled images to a new ImageIcon and then add it to my ImageIgon arrat
    image[0] = new ImageIcon(originalDown);
    image[1] = new ImageIcon(originalUp);
    //Using an external Jlabel array i assing it with new Jlabel with this ImageIcon
    buttonPair[0] = new JLabel(image[0]);
    //I then add a custom event class, but you can make your own method or leave this out if its not needed
    buttonPair[0].addMouseListener(events);
    //And lastly i add this to my form
    this.add(buttonPair[0]);
    //and repeat for as many times as you need
    buttonPair[1] = new JLabel(image[1]);
    buttonPair[1].addMouseListener(events);
    this.add(buttonPair[1]);
}
不要忘记导入:

import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.JLabel;

谢谢您的回答@simon jensen先生,我可以用任何方式制作图像,但我想要的是调用java graphics通过编码绘制每个图像,例如,我确实理解您希望使用代码绘制,但由于它似乎有点先进,我认为最好使用更简单的解决方案,然而,我希望你能用我的力量或者在你提供的参考链接中找到你想要的答案,祝你的项目好运。