相关疑难解决方法(0)

简单的弹出式Java表单,至少包含两个字段

当用户单击一个按钮时,我想显示一个应该至少有两个JTextField和两个JLabel的弹出窗体,因此JOptionPane.showInputDialog不可能使用.

java user-interface swing

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

如何从右到左设置JTextArea的方向(在JOptionPane内)

JScrollPaneJTextArea里面,我试图从右侧设置的JTextArea的方向向左所以里面的文字就会从右边开始,滚动条会出现在左边

我尝试过以下但是它们并没有影响方向的方向:

txt.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
txt.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
txt.setAlignmentX(JTextArea.RIGHT_ALIGNMENT);
Run Code Online (Sandbox Code Playgroud)

编辑:

两个答案camickr和trashgod提供的工作正常但不在我的程序中我使用我的JTextArea作为对象消息并将其传递给OptionPane.

EDIT2:

我发现,setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);如果我将它应用于JOptionPane内容,则无效.是否有替代方案解决此问题?

与我的代码类似:

import java.awt.*;
import java.util.*;
import javax.swing.*;
public class TextArea extends JPanel
{
    private JTextArea txt = new JTextArea();
    public TextArea()
    {
        setLayout(new GridLayout());
        txt.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
        JScrollPane scroll = new JScrollPane(txt);
        scroll.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
        setPreferredSize(new Dimension(200,200));
        this.add(scroll);
    }
    private void display()
    {
        Object[] options = {this};
        JOptionPane pane = new JOptionPane();
        int option = pane.showOptionDialog(null, null, "Title", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]);
    }
    public static void main(String[] args) …
Run Code Online (Sandbox Code Playgroud)

java swing arabic jtextarea

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

标签 统计

java ×2

swing ×2

arabic ×1

jtextarea ×1

user-interface ×1