我如何在java中执行此操作我无法将大小设置为我的文本字段我不知道具体如何,结果必须如何:
这是我的代码的输出我必须在id和第一个textfield之后再添加2个标签和texfields Mine:
class IU extends JFrame{
public IU(){
super("Tabela mysql");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400, 400);
getContentPane().setLayout(new BorderLayout());
JToolBar myBar=new JToolBar();
getContentPane().add(myBar,BorderLayout.NORTH);
JButton btnFirst=new JButton();
JButton btnPrevious=new JButton();
JButton btnNext=new JButton();
JButton btnLast=new JButton();
JButton btnAdd=new JButton();
JButton btnEdit=new JButton();
JButton btnDelete=new JButton();
JButton btnSearch=new JButton();
JButton btnUndo=new JButton();
JButton btnSave=new JButton();
JTextField txtAfis=new JTextField();
btnFirst.setIcon(new ImageIcon("MoveFirst.png"));
btnPrevious.setIcon(new ImageIcon("MovePrevious.png"));
btnNext.setIcon(new ImageIcon("MoveNext.png"));
btnLast.setIcon(new ImageIcon("MoveLast.png"));
btnAdd.setIcon(new ImageIcon("Add.png"));
btnEdit.setIcon(new ImageIcon("Edit.png"));
btnDelete.setIcon(new ImageIcon("Delete.png"));
btnSearch.setIcon(new ImageIcon("find.jpg"));
btnUndo.setIcon(new ImageIcon("undo.jpg"));
btnSave.setIcon(new ImageIcon("save.jpg"));
JPanel panel = new JPanel();
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
JTextField t = new JTextField();
JTextField t1 = new JTextField();
JTextField t2 = new JTextField();
t.setSize(100, 20);
t1.setBounds(20,10,70,20);
t2.setBounds(20,10,70,20);
JLabel label = new JLabel("Nume");
JLabel label2 = new JLabel("Prenume");
JLabel label3 = new JLabel("Id");
getContentPane().add(panel);
panel.add(label3);
panel.add(t, BorderLayout.EAST);
panel1.add(label2);
panel1.add(t1);
panel2.add(label);
panel2.add(t2);
myBar.add(btnFirst);
myBar.add(btnPrevious);
myBar.add(txtAfis);
myBar.add(btnNext);
myBar.add(btnLast);
myBar.add(btnAdd);
myBar.add(btnEdit);
myBar.add(btnDelete);
myBar.add(btnSearch);
myBar.add(btnSave);
myBar.add(btnUndo);
add(panel);
}
}
答案 0 :(得分:2)
创建文本字段时使用:
library(data.table)
DT <- as.data.table(expand.grid(x = 1:10, t = letters[1:4]))
DT[, y := rnorm(10), by = t]
# Function to get estimates and standard error for
# each regressor.
ExtractLm <- function(model) {
a <- summary(model)
return(list(rownames(a$coefficients),
a$coefficients[, 1],
a$coefficients[, 2]))
}
DT.regression <- DT[, ExtractLm(lm(x ~ y)), by = t]
该数字将允许文本字段确定其自身的大小。在上述情况下,它将包含10个“W”字符。
然后使用布局管理器来获得所需的布局。