我可以在apache POI中使用以下代码更改前景色.现在我想更改单个单元格的字体颜色.
CellStyle style = wb.createCellStyle();
style.setFillForegroundColor(IndexedColors.GREEN.getIndex());
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
cell = rowxl.createCell((short) 7);
cell.setCellValue(" <<<<ONTRACK>>>>");
cell.setCellStyle(style);
rowxl.createCell(0).setCellValue(TEAM);
Run Code Online (Sandbox Code Playgroud)
我试过这个,但它没有改变前两列的颜色
码:
public class fclr {
public static void main(String[] args) throws Exception {
InputStream inp = new FileInputStream("c:/workbook1.xls");
Workbook wb = WorkbookFactory.create(inp);
CreationHelper createHelper = wb.getCreationHelper();
Sheet sheet = wb.getSheetAt(0);
Row rowxl = sheet.createRow((short)0);
Cell cell = rowxl.createCell(0);
//apply some colors from the standard palette,
// as in the previous examples.
//we'll use red text on a lime background
CellStyle style = wb.createCellStyle(); …
Run Code Online (Sandbox Code Playgroud) 我无法使用 adb 连接到我的手机。我收到以下错误:
D:\softwares\Development\Android\android-sdk-windows\platform-tools>adb devices -l
List of devices attached
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
error: protocol fault (couldn't read status): Invalid argument
Run Code Online (Sandbox Code Playgroud)
http://s18.postimg.org/7fdc8w9dl/screenshot_97.png
以前我在 Windows 8.1 中遇到此错误,然后我安装了 Windows 10 并解决了错误,但现在我再次无法将手机与 adb 连接:(。
即使没有连接任何设备,我也会收到此错误。
日食错误:
[2015-10-24 13:25:02 - ddms] Failed to initialize Monitor Thread: Unable to establish loopback connection
[2015-10-24 13:25:02 - adb] error: protocol fault (couldn't read status): Invalid argument
[2015-10-24 13:25:02 - ddms] 'D:\softwares\Development\Android\android-sdk-windows\platform-tools\adb.exe,start-server' failed -- run …
Run Code Online (Sandbox Code Playgroud) 从这个代码我可以生成10条现在的条形图现在我想知道如何在条形图上显示每个条形的值,如附加图像:
这是代码:
public class BarChartSample extends Application {
@Override public void start(Stage stage) {
stage.setTitle("Bar Chart Sample");
final CategoryAxis xAxis = new CategoryAxis();
final NumberAxis yAxis = new NumberAxis();
final BarChart<String,Number> bc =
new BarChart<String,Number>(xAxis,yAxis);
bc.setTitle("Country Summary");
xAxis.setLabel("bars");
yAxis.setLabel("Value");
XYChart.Series series1 = new XYChart.Series();
series1.setName("...");
for(int i=0;i<10;i++)
{
//here i want to change color of bar if value of i is >5 than red if i>8 than blue
series1.getData().add(new XYChart.Data("Value", i));
}
}
public static void main(String[] args) {
launch(args); …
Run Code Online (Sandbox Code Playgroud) 这是我的代码,它生成从0到10的10个值的条形图.我想改变条形的颜色如下
如果我> 5颜色==红色,如果我> 8颜色==蓝色
所以最终输出将是0-5(默认黄色条)6-8(红色条)9(蓝色条)
请帮助我..谢谢
public class BarChartSample extends Application {
@Override
public void start(Stage stage) {
stage.setTitle("Bar Chart Sample");
final CategoryAxis xAxis = new CategoryAxis();
final NumberAxis yAxis = new NumberAxis();
final BarChart < String, Number > bc = new BarChart < String, Number > (xAxis, yAxis);
bc.setTitle("Country Summary");
xAxis.setLabel("bars");
yAxis.setLabel("Value");
XYChart.Series series1 = new XYChart.Series();
series1.setName("...");
for (int i = 0; i < 10; i++) {
//here i want to change color of bar if value of …
Run Code Online (Sandbox Code Playgroud) 在发送电子邮件时,我使用commons-email-1.3收到以下错误.
我已经下载并添加了外部jar到项目中.
请帮我解决这个问题!
package mypkg;
import org.apache.commons.mail.DefaultAuthenticator;
import org.apache.commons.mail.Email;
import org.apache.commons.mail.SimpleEmail;
public class sendingmail {
public static void main(String[] args) throws Exception {
Email email = new SimpleEmail();
email.setSmtpPort(587);
email.setAuthenticator(new DefaultAuthenticator("myid","mypwd")); //Here is the error
email.setDebug(false);
email.setHostName("smtp.gmail.com");
email.setFrom("me@gmail.com");
email.setSubject("Hi");
email.setMsg("This is a test mail ... :-)");
email.addTo("you@gmail.com");
email.setTLS(true);
email.send();
System.out.println("Mail sent!");
}
}
Run Code Online (Sandbox Code Playgroud)
给出错误的行是
email.setAuthenticator(new DefaultAuthenticator("myid","mypwd"));
Run Code Online (Sandbox Code Playgroud)
错误消息是
线程"main"中的异常java.lang.Error:未解决的编译问题:
无法解析javax.mail.Authenticator类型.它是从所需的.class文件间接引用的.来自
类型Email的方法setAuthenticator(Authenticator)是指mypkg.mailtest.main中缺少的类型Authenticator(mailtest.java:13)
我想要实现的是当用户触摸UIImageView设置Image1时,当用户抬起他的手指设置Image2时.
我只能使用此代码获取UIGestureRecognizerState.Ended
var tap = UITapGestureRecognizer(target: self, action: Selector("tappedMe:"))
imageView.addGestureRecognizer(tap)
imageView.userInteractionEnabled = true
func tappedMe(gesture: UITapGestureRecognizer)
{
if gesture.state == UIGestureRecognizerState.Began{
imageView.image=originalImage
dbgView.text="Began"
}else if gesture.state == UIGestureRecognizerState.Ended{
imageView.image=filteredImage
dbgView.text="Ended"
}else if gesture.state == UIGestureRecognizerState.Cancelled{
imageView.image=filteredImage
dbgView.text="Cancelled"
}else if gesture.state == UIGestureRecognizerState.Changed{
imageView.image=filteredImage
dbgView.text="Changed"
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试从 onOptionsItemSelected 开始一个新的活动(设置活动),但是当我点击选项二时我得到了致命的异常,它开始设置活动一段时间而不是崩溃。
如果我从其他任何地方启动 Settings Activity 而不是它开始时没有任何错误。
设置活动
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class SettingsActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
}
}
Run Code Online (Sandbox Code Playgroud)
第一个活动(Room1.java):
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_room1);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflator = getMenuInflater();
inflator.inflate(R.menu.room1, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if(item.getItemId()==R.id.menu_option_two){
Settings();
Log.d("Option","2");
}
return super.onOptionsItemSelected(item);
}
private void Settings() {
Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent) ; …
Run Code Online (Sandbox Code Playgroud)