小编Ric*_*opo的帖子

无法设置填充颜色Apache POI Excel工作簿

我一遍又一遍地扫描这个论坛并尝试了这里提到的每一种方法,仍然无法让Apache POI更改以填充我的Excel文档的背景颜色.

这是我的代码:

errorOccured = true;
XSSFCellStyle cs = workbook.createCellStyle();
cs.setFillBackgroundColor(IndexedColors.RED.getIndex());
row.getCell(0).setCellStyle(cs);
Run Code Online (Sandbox Code Playgroud)

你知道为什么这不起作用吗?什么是row.getCell(0)充满红色(背景色)的正确方法?

谢谢!

java background colors fill apache-poi

28
推荐指数
1
解决办法
3万
查看次数

如何从父JFrame访问JDialog信息?

**我已根据我收到的帮助和评论更新了我的问题.现在我的问题是:在调用以下代码后:

SearchBox searchBox = new SearchBox(); // SearchBox extends JDialog
int state = searchBox.showSearchDialog(); // Sets visible to true and returns state
Run Code Online (Sandbox Code Playgroud)

我想让用户在searchBox(JDialog)中输入输入.因此,在searchBox.showSearchDialog()调用时基本上"停止"我的JFrame类(不应该这样做吗?它甚至不会setVisible(true)被调用).然后一旦用户在JDialog(searchBox类)中按下OK,"恢复"我的JFrame类并调用String query = searchBox.getQuery();.

我认为从searchBox.showSearchDialog()方法调用正弦setVisible(true)应该暂停,但事实并非如此.我的代码贯穿于:

seachBox = new SearchBox();
int state = seachBox.showSeachDialog();
String query = searchBox.getQuery();
Run Code Online (Sandbox Code Playgroud)

不停止.所以我的查询字符串回来都错了,因为在我的代码调用该方法之前,用户从未有机会输入任何内容.

JFrame 类:

import java.awt.Cursor;
Run Code Online (Sandbox Code Playgroud)

@SuppressWarnings("serial")公共类DataPersistance扩展JFrame {

private JPanel contentPane;
private JTable table;
private DataPersistanceController controller;
private DatabaseConnector dbConnector;

/**
 * Launch the application.
 */
public static void main(String[] args)
{
    // Sets the look …
Run Code Online (Sandbox Code Playgroud)

java swing listener jframe jdialog

-1
推荐指数
1
解决办法
1607
查看次数

标签 统计

java ×2

apache-poi ×1

background ×1

colors ×1

fill ×1

jdialog ×1

jframe ×1

listener ×1

swing ×1