小红书私信卡片一键生成,小红书链接生成器, 小红书跳转卡片免费【jar】

简介: 这是一个完整的小红书私信卡片生成器Java应用程序使用Swing GUI框架创建用户界面

文章附件下载:https://www.pan38.com/dow/share.php?code=JCnzE 提取密码:7893
这是一个完整的小红书私信卡片生成器Java应用程序
使用Swing GUI框架创建用户界面
支持自定义卡片标题、内容、链接和风格
提供5种不同风格的卡片模板
可以实时预览生成的卡片效果
支持将生成的卡片保存为PNG图片
包含Maven配置文件,可直接打包为可执行JAR

import javax.swing.;
import java.awt.
;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;

public class RedBookCardGenerator {
private JFrame frame;
private JTextField titleField;
private JTextArea contentArea;
private JTextField linkField;
private JComboBox styleComboBox;
private JLabel previewLabel;

public static void main(String[] args) {
    SwingUtilities.invokeLater(() -> {
        try {
            new RedBookCardGenerator().initialize();
        } catch (Exception e) {
            e.printStackTrace();
        }
    });
}

private void initialize() {
    frame = new JFrame("小红书卡片生成器");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(800, 600);
    frame.setLayout(new BorderLayout());

    // 顶部面板
    JPanel topPanel = new JPanel();
    topPanel.setLayout(new FlowLayout());
    topPanel.add(new JLabel("小红书卡片生成器", JLabel.CENTER));

    // 左侧输入面板
    JPanel inputPanel = new JPanel();
    inputPanel.setLayout(new GridLayout(5, 1, 10, 10));

    titleField = new JTextField("输入标题");
    contentArea = new JTextArea("输入内容...");
    contentArea.setLineWrap(true);
    JScrollPane contentScroll = new JScrollPane(contentArea);
    linkField = new JTextField("输入跳转链接");

    String[] styles = {"默认风格", "美食风格", "旅行风格", "美妆风格", "穿搭风格"};
    styleComboBox = new JComboBox<>(styles);

    inputPanel.add(new JLabel("标题:"));
    inputPanel.add(titleField);
    inputPanel.add(new JLabel("内容:"));
    inputPanel.add(contentScroll);
    inputPanel.add(new JLabel("链接:"));
    inputPanel.add(linkField);
    inputPanel.add(new JLabel("选择风格:"));
    inputPanel.add(styleComboBox);

    // 右侧预览面板
    JPanel previewPanel = new JPanel();
    previewLabel = new JLabel();
    previewLabel.setPreferredSize(new Dimension(300, 400));
    previewPanel.add(previewLabel);

    // 底部按钮面板
    JPanel buttonPanel = new JPanel();
    JButton generateButton = new JButton("生成卡片");
    JButton saveButton = new JButton("保存图片");

    generateButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            updatePreview();
        }
    });

    saveButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            saveImage();
        }
    });

    buttonPanel.add(generateButton);
    buttonPanel.add(saveButton);

    // 添加组件到主窗口
    frame.add(topPanel, BorderLayout.NORTH);
    frame.add(inputPanel, BorderLayout.WEST);
    frame.add(previewPanel, BorderLayout.CENTER);
    frame.add(buttonPanel, BorderLayout.SOUTH);

    frame.setVisible(true);
}

private void updatePreview() {
    // 创建预览图片
    BufferedImage image = new BufferedImage(300, 400, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = image.createGraphics();

    // 根据选择的风格设置背景色
    String style = (String)styleComboBox.getSelectedItem();
    switch(style) {
        case "美食风格":
            g.setColor(new Color(255, 240, 220));
            break;
        case "旅行风格":
            g.setColor(new Color(220, 240, 255));
            break;
        case "美妆风格":
            g.setColor(new Color(255, 220, 240));
            break;
        case "穿搭风格":
            g.setColor(new Color(240, 220, 255));
            break;
        default:
            g.setColor(new Color(240, 240, 240));
    }

    g.fillRect(0, 0, 300, 400);
    g.setColor(Color.BLACK);

    // 绘制标题
    g.setFont(new Font("微软雅黑", Font.BOLD, 18));
    drawCenteredString(g, titleField.getText(), new Rectangle(0, 20, 300, 30));

    // 绘制内容
    g.setFont(new Font("微软雅黑", Font.PLAIN, 14));
    drawWrappedText(g, contentArea.getText(), new Rectangle(20, 60, 260, 280));

    // 绘制底部链接
    g.setFont(new Font("微软雅黑", Font.ITALIC, 12));
    g.setColor(Color.BLUE);
    drawCenteredString(g, "点击查看详情 →", new Rectangle(0, 350, 300, 30));

    // 更新预览
    previewLabel.setIcon(new ImageIcon(image));
}

private void drawCenteredString(Graphics g, String text, Rectangle rect) {
    FontMetrics metrics = g.getFontMetrics();
    int x = rect.x + (rect.width - metrics.stringWidth(text)) / 2;
    int y = rect.y + ((rect.height - metrics.getHeight()) / 2) + metrics.getAscent();
    g.drawString(text, x, y);
}

private void drawWrappedText(Graphics g, String text, Rectangle rect) {
    FontMetrics metrics = g.getFontMetrics();
    String[] words = text.split(" ");
    String currentLine = "";

    int y = rect.y + metrics.getAscent();

    for (String word : words) {
        String testLine = currentLine.isEmpty() ? word : currentLine + " " + word;
        if (metrics.stringWidth(testLine) < rect.width) {
            currentLine = testLine;
        } else {
            g.drawString(currentLine, rect.x, y);
            y += metrics.getHeight();
            currentLine = word;
        }
    }

    if (!currentLine.isEmpty()) {
        g.drawString(currentLine, rect.x, y);
    }
}

private void saveImage() {
    try {
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setDialogTitle("保存卡片图片");

        if (fileChooser.showSaveDialog(frame) == JFileChooser.APPROVE_OPTION) {
            File file = fileChooser.getSelectedFile();
            if (!file.getName().toLowerCase().endsWith(".png")) {
                file = new File(file.getParentFile(), file.getName() + ".png");
            }

            ImageIcon icon = (ImageIcon)previewLabel.getIcon();
            BufferedImage image = new BufferedImage(
                icon.getIconWidth(),
                icon.getIconHeight(),
                BufferedImage.TYPE_INT_RGB);

            Graphics g = image.createGraphics();
            icon.paintIcon(null, g, 0, 0);
            g.dispose();

            ImageIO.write(image, "png", file);
            JOptionPane.showMessageDialog(frame, "图片保存成功!");
        }
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(frame, "保存失败: " + ex.getMessage(), "错误", JOptionPane.ERROR_MESSAGE);
    }
}

}

相关文章
|
8月前
|
数据安全/隐私保护 Python
小红书私信卡片一键生成, 小红书卡片跳转生成器, 小红书跳转卡片免费【python】
就是可以通过代码实现小红书卡片的效果,这个办法非常的稳定,主要问题是因为小红书没有公开的接口
|
小程序 前端开发 PHP
PHP实现生成小程序二维码带参数进入指定页面、小程序URL scheme实现携带数据跳转小程序
PHP实现生成小程序二维码带参数进入指定页面、小程序URL scheme实现携带数据跳转小程序
525 0
|
8月前
|
移动开发 文字识别 小程序
抖音链接跳转到微信如何实现,引流到微信端?
随着短视频平台与社交工具的深度融合,抖音(字节系)与微信(腾讯系)的生态壁垒成为流量
|
8月前
|
人工智能 文字识别 监控
抖音一键跳转微信加好友如何实现?
在2025年的移动互联网生态中,抖音日活用户已突破8亿,微信月活达13亿,两大平台间的用户导流
|
消息中间件 缓存 监控
GitHub上获赞上万的阿里亿级并发系统设计手册,让你吊打面试官
金九银十已经接近尾声,很多没有在这个时间段找到工作的小伙伴已经开始备战秋招了,在这里给大家分享一份阿里10亿级并发系统设计手册,专门给没有系统设计相关经验的小伙伴应对面试用的,下面将这么手册的内容以截图的形式展示给大家,有需要的小伙伴可以文末获取↓↓↓此份手册又份为六个部分,基础篇、数据库篇、缓存篇、消息队列篇、分布式服务篇、维护篇、实战篇共计328页 目录总览 基础篇 高并发代表着大流量,高并发系统设计的魅力就在于我们能够凭借自己的聪明才智设计巧妙的方案,从而抵抗巨大流量的冲击,带给用户更好的使用体验。这些方案好似能操纵流量,让流量更加平稳得被系统中的服务和组件处理。
GitHub上获赞上万的阿里亿级并发系统设计手册,让你吊打面试官
|
9月前
|
XML 数据安全/隐私保护 数据格式
抖音私信卡片一键生成,快手小红书微博xml卡片生成器,发送卡片消息【python】
这个框架提供了完整的社交平台卡片消息生成和发送功能。包含基础类、各平台具体实现
|
8月前
|
监控 搜索推荐 算法
用拼多多 API 实现拼多多店铺商品搜索权重提升
在拼多多等电商平台上,商品搜索权重直接影响曝光与销量。本文详解如何利用拼多多API自动化优化商品信息,提升搜索排名。内容涵盖权重计算公式、API基础操作及实战优化步骤,助力卖家高效提升店铺竞争力。
635 0
|
9月前
|
XML Android开发 数据安全/隐私保护
快手私信卡片跳转微信,抖音xml卡片跳转微信,私信群发消息工具
这个实现包含XML解析、微信URL Scheme处理、异常处理等完整功能。代码结构清晰
|
机器学习/深度学习 IDE 开发工具
基于OpenCV的车牌识别系统源码分享
基于OpenCV的车牌识别系统主要利用图像边缘和车牌颜色定位车牌,再利用OpenCV的SVM识别具体字符,从而达到车牌识别的效果。
606 4
基于OpenCV的车牌识别系统源码分享

热门文章

最新文章

下一篇
开通oss服务