我在PHP中使用带有MySQL数据库的PDO库,但如果我插入以UTF-8编码的任何数据,如阿拉伯语单词,则将其插入到数据库中,但是?????????.
在我自己的框架中,在创建PDO连接后,我发送了两个查询 - SET NAMES utf8和SET CHARACTER SET utf8.它仍然无法正常工作.
例:
loadclass('PDO', array(
sprintf(
'mysql:host=%s;port=%s;dbname=%s',
confitem('database', 'host'),
confitem('database', 'port'),
confitem('database', 'name')
),
confitem('database', 'username'),
confitem('database', 'password'),
array('PDO::ATTR_PERSISTENT' => confitem('database', 'pconnect'))
));
$this->query('SET NAMES ' . confitem('database', 'charset'));
$this->query('SET CHARACTER SET ' . confitem('database', 'charset'));
Run Code Online (Sandbox Code Playgroud)
解决方法:使用json_encode函数在将数据插入数据库之前转换数据,并json_decode在获取后使用它进行解码.这就是我现在这样做的方式.
我有这个代码来制作一个带有图标图像的Jbutton,它可以工作.但问题是按钮的边框和背景不会消失.
我想只显示没有边框和按钮背景的图标图像.
我试着设置setOpaque(false),但所有按钮都消失了!
我的代码有什么问题?
_button = new JButton("Exit");
_button.setHorizontalTextPosition(SwingConstants.CENTER);
_button.setSize(200,130);
//_button.setContentAreaFilled(false);
_button.setBorderPainted(false);
//_button.setOpaque(false);
_button.setIgnoreRepaint(true);
//_button.setFocusable(false);
_button.setIcon(button_icon);
_button.setBounds(200, 200,200, 170);
_button.setRolloverEnabled(true);
_button.setRolloverIcon(button_icon_hover);
_button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
//_button.addActionListener(this);
_button.setBackground(null);
_button.setFocusable(true);
_button.setFocusPainted(true);
_button.setForeground(Color.WHITE);
_button.setFont(new Font("Times New Roman",Font.BOLD,35));
Run Code Online (Sandbox Code Playgroud) 我在javafx中进行了顺序转换,以便在两个周期之间淡入/淡出.
我的问题是当我调用.stop()顺序转换时,它会停止转换,但是它不会等到转换直到它完成它的转换周期,所以它有时会在衰落过程的一半时间内停止转换!如何让它在衰落周期结束后停止顺序转换?所以,当我回忆起它.play()或者.playfromStart()它再次正确播放时,能够让我
我的代码示例:
import javafx.animation.*;
import javafx.application.Application;
import javafx.scene.*;
import javafx.scene.shape.*;
import javafx.stage.Stage;
import javafx.util.Duration;
public class Transitions extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
Rectangle circle1 = RectangleBuilder.create()
.arcHeight(300)
.arcWidth(300)
.height(30)
.width(40)
.opacity(0.6)
.translateY(30)
.style("-fx-fill: linear-gradient(#82d24f,#398907); -fx-stroke: #4a4a4a; -fx-stroke-width: 2")
.build();
Rectangle circle2 = RectangleBuilder.create()
.arcHeight(300)
.arcWidth(300)
.height(40)
.width(50)
.opacity(0.7)
.translateX(10)
.translateY(70)
.style("-fx-fill: linear-gradient(#82d24f,#398907); -fx-stroke: #4a4a4a; -fx-stroke-width: 2.5")
.build();
FadeTransition fade1 …Run Code Online (Sandbox Code Playgroud) 我试过很多次,以保持垂直Scroll Bar的Textrea是始终处于活动状态,而不是被看见时才重点Textarea,但我不能这样做!..
请帮忙
我试图将外部样式表添加到我的JavaFX应用程序中。
例子:
scene.getStylesheets().add("http://localhost/css/style.css");
Run Code Online (Sandbox Code Playgroud)
但它不起作用,那么有什么方法可以从外部资源加载 css 文件,并将其内容添加到场景 css 类中?或将其 css 文件添加到场景样式表文件中?
我创建了一个类作为加载器,用于在后台线程中加载图像,将它们添加到JavaFX应用程序中,
我的问题是,虽然这个类可以作为一个任务,但它会导致JavaFX Apllication在图像加载过程中冻结,并在完成后再正常工作,
装载机类代码:
import javafx.concurrent.Service;
import javafx.concurrent.Task;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
public class Loader{
private String type = "";
private String url = "";
private ImageView image = new ImageView();
private class LoaderService extends Service{
@Override
protected Task createTask() {
return new LoaderTask();
}
}
private class LoaderTask extends Task{
@Override
protected Object call() throws Exception {
new LoaderClass();
return null;
}
}
private String getType(){
return this.type;
}
private String getUrl(){
return this.url;
}
public Loader type(String type){ …Run Code Online (Sandbox Code Playgroud) 我正在使用VLC和VLCJ在我的Java应用程序中播放视频和音频文件,这很好.
但播放视频时出现了一个文字; 此文本是播放视频的路径.
播放视频时我不希望它出现,那么如何使用Java禁用它?
我有这个字符串:
dsfssdsdfdsf«ظ...ط¯ظظ†طططظ...ط¯ط§ظ"ط®ظط§ط¬ط©
它是用UTF-8编码的,我从远程页面中提取它,我使用file_get_contents函数获取它的内容,远程页面编码是UTF-8,
现在我想将这个字符串插入数据库,它的表编码是latin1,将其显示到具有charset ISO-8859-1的html页面,
我多次尝试将其编码从UTF-8转换为ASCII,或者转换为ISO-8859-1以及其他编码如Windows-1256,但它没有成功,字符串出现奇怪的字符,请注意默认字符串包含阿拉伯字符,
编码失败结果的示例:
dsfssdsdfdsfÃ,Â~~~~~~~~~~~····················································································································· ·Ã······················································································································· Ã,®Ã~¸Ã<A†Ã~·Ã,§Ã~·Ã,¬Ã~·Ã,©
"我爱你"
我正在尝试MenuButton使用JavaFX而不是通过代码修改箭头的颜色CSS。
我在里面找到它caspian.css:
.menu-button > .arrow-button > .arrow {
-fx-background-insets: 1 0 -1 0, 0;
-fx-background-color: -fx-mark-highlight-color, -fx-mark-color;
-fx-padding: 0.25em; /* 3 */
-fx-shape: "M 0 -3.5 v 7 l 4 -3.5 z";
}
Run Code Online (Sandbox Code Playgroud)
我试图使用类似的东西:
menubutton.lookup(".arrow");
Run Code Online (Sandbox Code Playgroud)
但它抛出 NullPointerException
当我这样做时:
System.out.println(this.getStyleClass().toString());
它仅表明:menu-button仅。
所以任何人都可以给我一种无需使用CSS即可使用Java对其进行修改的方法吗?