小编Ale*_*tre的帖子

使用 Java FileWriter 未找到文件异常

我正在尝试从 JAVA 应用程序写入 txt 文件。我尝试过使用 Buffered Writer,然后仅使用 FileWriter 在一个可能新的子文件夹中创建一个新文件(不是无限期的,因为稍后将通过相同的方法以编程方式写入更多具有不同名称的文件)。我收到以下错误消息(实际上更长,但我认为这是它的关键部分):

java.io.FileNotFoundException:src/opinarium3/media/presentaciones/Los fantasmas del Sistema Solar/comments/2014-07-26.txt(没有这样的文件或目录)在java.io.FileOutputStream.open(本机方法)

这是引发问题的代码(当您按下按钮注册已填写自定义表单的评论时,它会激活):

private void fileCommentOnPresentation(String title, String positiveComments, String negativeComments, int grade) throws IOException{
    FileWriter bw;
    try{
        bw = new FileWriter("src/opinarium3/media/presentaciones/"+title+"/comments/"+Date.valueOf(LocalDate.now())+".txt");
        bw.write(title+"\n"+positiveComments+"\n"+negativeComments+"\n"+grade);
        bw.flush();
        bw.close();
    }catch(IOException e){
        e.printStackTrace();
    }
}
Run Code Online (Sandbox Code Playgroud)

java file-io filewriter bufferedwriter

4
推荐指数
1
解决办法
2万
查看次数

如何在PyQt5中设置PlotWidget刻度颜色?

我正在尝试设置 pyqtgraph.PlotWidget 绘图区域的轴样式。我在用着:

font = QFont()
font.setPointSize(14)
font.setBold(True)
font.setWeight(75)

myPlotWidget.getAxis('left').setPen('b')
myPlotWidget.getAxis('left').setFont(font)
Run Code Online (Sandbox Code Playgroud)

我不明白为什么刻度标签颜色不是蓝色,而轴、网格和轴标签是蓝色。

在此输入图像描述

python pyqtgraph pyqt5

4
推荐指数
1
解决办法
2804
查看次数

工具提示背景(使用JavaFX CSS)

简单的问题,但我无法在任何地方找到答案(我想我不知道到底要找什么......).如何防止我的工具提示显示一个丑陋的正方形,并将场景的背景图像作为背景图像,如图所示

这是我的CSS,我相信按钮之类的一些选项正在影响工具提示......正如它们影响我在代码的另一部分中的Datepickers.如何管理它们不会产生这种附带效应?只是为特定对象定义一个CSS,比如DatePicker或Tooltip就可以了吗?

我正在使用JDK 8u11,MAC OS Mavericks.

.root {
     -fx-background-image: url("media/background.jpg");
}

.button {
    -fx-background-color: 
        linear-gradient(#686868 0%, #232723 25%, #373837 75%, #757575 100%),
        linear-gradient(#020b02, #3a3a3a),
        linear-gradient(#9d9e9d 0%, #6b6a6b 20%, #343534 80%, #242424 100%),
        linear-gradient(#8a8a8a 0%, #6b6a6b 20%, #343534 80%, #262626 100%),
        linear-gradient(#777777 0%, #606060 50%, #505250 51%, #2a2b2a 100%);
    -fx-background-insets: 0,1,4,5,6;
    -fx-background-radius: 9,8,5,4,3;
    -fx-padding: 15 30 15 30;
    -fx-font-family: "Arial Black";
    -fx-font-size: 18px;
    -fx-font-weight: bold;
    -fx-text-fill: white;
    -fx-effect: dropshadow( three-pass-box , rgba(255,255,255,0.2) , 1, 0.0 , 0 , 1); …
Run Code Online (Sandbox Code Playgroud)

javafx tooltip

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

JavaFX将ImageView剪切为AnchorPane中的椭圆

我一直在构建一个应用程序,我想在椭圆内显示一个大图像来模仿天文馆的屋顶.剪切ImageView显示图像到椭圆与myImageView.setClip(myEllipse)优雅地工作,直到我的应用程序的最后一个版本,我添加椭圆的AnchorPane似乎不喜欢我剪切其中的图像.

我得到的错误myImageView.setClip(myEllipse)如下:

引起:

java.lang.IllegalArgumentException:节点的剪辑设置为不正确的值(节点已连接,node = ImageView @ a13b0a6,clip = ObjectProperty [bean:ImageView @ a13b0a6,name:clip,value:null]).

我的理解是我在场景图中创建了某种循环,但我无法弄清楚在哪里.

这是我的代码(整个界面是"硬编码")

package opinarium3;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import javafx.application.Application;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import static javafx.scene.layout.VBox.setMargin;
import javafx.scene.shape.Ellipse;
import javafx.scene.text.Font;
import javafx.stage.Stage;

/**
 *
 * @author Admin
 */
public class Opinarium3 extends …
Run Code Online (Sandbox Code Playgroud)

java javafx

0
推荐指数
1
解决办法
2798
查看次数