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 inGUI
?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
sdisplay
属性: http : //jsfiddle.net/Fw3fz/4/#Checkboxlist1 tr{ display:inline-block; margin-right:20px; }
或者,使用
float
: http : //jsfiddle.net/Fw3fz/10/#Checkboxlist1 tr{ float:left; margin-right:20px; }
如果您想在复选框和标签之间留出一些空白,请添加以下代码片段:
#Checkboxlist1 tr label{ margin-left:5px; }
但是,内联显示表格行或将它们浮动很不常见。 如果可能,请更改HTML结构。
You have to change the
tr
sdisplay
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.
相关问答
更多-
CSS方式水平对齐表(CSS way to horizontally align table)[2023-01-22]
在理论上 ,史蒂文是对的: 使用CSS定位桌面的“正确”方式。 如果左右边距相等,则符合浏览器的中心表格。 最简单的方法是将左右边距设置为“auto”。因此,可以在样式表中写入: table { margin-left: auto; margin-right: auto; } 但是,在这个答案开头提到的文章给了你所有其他的方式来设置一个表格。 一个优雅的css跨浏览器解决方案:这可以在MSIE 6(怪癖和标准),Mozilla,Opera甚至Netscape 4.x中工作,而不设置任何明 ... -
在使用带CSS的表格显示时,如何在表格中对齐复选框?(How can I align the checkboxes in a form when using table display with CSS?)[2022-04-11]
只需将所有input标签移到p标签之外。 这是一个工作小提琴: form { display: table; } .tableRow { display: table-row; } .tableRow p { display: table-cell; vertical-align: top; padding: 3px; } .tableRow p:first-child { text-align: left; } h1 { font- ... -
CheckBox cb = new CheckBox(this); cb.setOnClickListener(this); 创建复选框ID或标记时设置它。 cb.setTag(someIdentifier); 然后使用该方法 @Override public void onClick(View v) { if (v.getTag.equals(someIdentifier)){ //do stuff here ...
-
您只需添加CSS,如td.cstm-cls {display: flex;} body{width:40%;} label{display:inline;font-size:11px;} td.cstm-cls { display: flex; }