首页 \ 问答 \ JTextArea没有显示(JTextArea not showing)

JTextArea没有显示(JTextArea not showing)

为什么JTextArea不能在GUI显示?

public class AddMovie extends JTextField {

    static JFrame frame;
    private JLabel description;
    JTextArea movieDescription;

    public JPanel createContentPane() throws IOException
    {

        JPanel totalGUI = new JPanel();
        totalGUI.setLayout(null);
        totalGUI.setBackground(Color.WHITE);

        description = new JLabel("Description  ");
            description.setLocation(15,285);
            description.setSize(120, 25);
            description.setFont(new java.awt.Font("Tahoma", 0, 12));
            movieDescription=new JTextArea();
          movieDescription.setLocation(15,320);
          movieDescription.setSize(420, 110);

        JScrollPane scrollPane = new JScrollPane(movieDescription);    
        totalGUI.add(description);
        totalGUI.add(movieDescription);
        totalGUI.add(cancel);
        totalGUI.add(scrollPane);                   
        return totalGUI;
    }


    static void createAndShowGUI() throws IOException
    {

        JFrame.setDefaultLookAndFeelDecorated(true);
        frame = new JFrame("New Movie");
        //Create and set up the content pane.
        AddMovie demo = new AddMovie();
        frame.setContentPane(demo.createContentPane());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(515, 520);
        frame.setLocation(480,120);
        frame.setVisible(true);
    }

    public void setVisible(boolean b) {
        // TODO Auto-generated method stub

    }

}

Why JTextArea not showing in GUI ?

public class AddMovie extends JTextField {

    static JFrame frame;
    private JLabel description;
    JTextArea movieDescription;

    public JPanel createContentPane() throws IOException
    {

        JPanel totalGUI = new JPanel();
        totalGUI.setLayout(null);
        totalGUI.setBackground(Color.WHITE);

        description = new JLabel("Description  ");
            description.setLocation(15,285);
            description.setSize(120, 25);
            description.setFont(new java.awt.Font("Tahoma", 0, 12));
            movieDescription=new JTextArea();
          movieDescription.setLocation(15,320);
          movieDescription.setSize(420, 110);

        JScrollPane scrollPane = new JScrollPane(movieDescription);    
        totalGUI.add(description);
        totalGUI.add(movieDescription);
        totalGUI.add(cancel);
        totalGUI.add(scrollPane);                   
        return totalGUI;
    }


    static void createAndShowGUI() throws IOException
    {

        JFrame.setDefaultLookAndFeelDecorated(true);
        frame = new JFrame("New Movie");
        //Create and set up the content pane.
        AddMovie demo = new AddMovie();
        frame.setContentPane(demo.createContentPane());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(515, 520);
        frame.setLocation(480,120);
        frame.setVisible(true);
    }

    public void setVisible(boolean b) {
        // TODO Auto-generated method stub

    }

}

原文:https://stackoverflow.com/questions/38279321
更新时间:2022-10-23 22:10

最满意答案

您必须更改tr s display属性: http : //jsfiddle.net/Fw3fz/4/

​#Checkboxlist1 tr{
    display:inline-block;
    margin-right:20px;
}​

或者,使用floathttp : //jsfiddle.net/Fw3fz/10/

#Checkboxlist1 tr{
    float:left;
    margin-right:20px;
}​

如果您想在复选框和标签之间留出一些空白,请添加以下代码片段:

#Checkboxlist1 tr label{
    margin-left:5px;
}

但是,内联显示表格行或将它们浮动很不常见。 如果可能,请更改HTML结构。


You have to change the trs display property: http://jsfiddle.net/Fw3fz/4/

​#Checkboxlist1 tr{
    display:inline-block;
    margin-right:20px;
}​

Or, use float: http://jsfiddle.net/Fw3fz/10/

#Checkboxlist1 tr{
    float:left;
    margin-right:20px;
}​

If you want some space between the checkboxes and the labels, add this snippet:

#Checkboxlist1 tr label{
    margin-left:5px;
}

However, it's very uncommon to display table rows inline or to float them. If possible, change the HTML structure.

相关问答

更多