我已经完成了学生的工作,我的任务是写一个Auto字汇编,它几乎完成了我面临的一个问题。我必须向gui添加3或4 jTextAreas
。问题是他如何编写代码我只能设法添加一个jTextArea
。
这看起来像1 Jtextarea
:
这就是我希望它拥有它的方式:
以下是管理键盘孔布局的代码:
button = new CustomJButton[button_size];
jPanel1 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
jTextArea = new javax.swing.JTextArea();
// BorderLayout
bl = new java.awt.BorderLayout();
this.setLayout(bl);
this.add(jTextArea, BorderLayout.NORTH);
Font font1 = new Font("SansSerif", Font.BOLD, 20);
jTextArea.setFont(font1);
jTextArea.setFocusable(false);
menuButtongbc = new GridBagConstraints();
// vergrößert die Buttons in BEIDE Richtungen // HORIZONTAL / VERTICAL
menuButtongbc.fill = GridBagConstraints.BOTH;
menuButtongbc.insets = new Insets(1,1,1,1);
menuButtongbc.weightx = 1;
menuButtongbc.weighty = 1;
letterButtongbc = new GridBagConstraints();
// vergrößert die Buttons in BEIDE Richtungen // HORIZONTAL / VERTICAL
letterButtongbc.fill = GridBagConstraints.BOTH;
letterButtongbc.insets = new Insets(1,1,1,1);
letterButtongbc.weightx = 1;
letterButtongbc.weighty = 1;
jPanel1.setLayout(new java.awt.GridBagLayout()); // Layout left side
jPanel2.setLayout(new java.awt.GridBagLayout()); // Layout right side
//******************************************************************************
// Button left Block / Buttonborder / Resize ButtonImage
//******************************************************************************
int xVar = 0; // Hilfvariable für X und Y Zuordnung
int yVar = 0; // Hilfvariable für X und Y Zuordnung
for ( int menuButtonArray = 0 ; menuButtonArray < 4 ; menuButtonArray++ ){
CustomJButton a = new CustomJButton(); // a : Hilfsvariable
button[menuButtonArray] = a;
button[menuButtonArray].setFont(new Font("Arial", Font.PLAIN, 40));
button[menuButtonArray].setBackground(backgroundColor);
button[menuButtonArray].setOpaque(true); // Test für MAC
button[menuButtonArray].setMinimumSize(new java.awt.Dimension(75, 75));
button[menuButtonArray].setPreferredSize(new java.awt.Dimension(100, 100));
button[menuButtonArray].setFocusable(false);
button[menuButtonArray].setBorder(BorderFactory.createLineBorder(Color.black, 4));
menuButtongbc.gridx = xVar; // X und Y Zuweisung der Button im GridbagLayout
menuButtongbc.gridy = yVar; // X und Y Zuweisung der Button im GridbagLayout
xVar++;
if(xVar == 2){ yVar++ ; xVar = 0; }
jPanel1.add( button[menuButtonArray] , menuButtongbc );
}
add(jPanel1, java.awt.BorderLayout.LINE_START); //getContentPane().
//******************************************************************************
// Array // Right side
//******************************************************************************
xVar = 0;
yVar = 0;
// ausgabe.length
for ( int letterButtonArray = 4 ; letterButtonArray < 34 ; letterButtonArray++ ){
CustomJButton a = new CustomJButton(); // a : Hilfsvariable
button[letterButtonArray] = a;
button[letterButtonArray].setFont(new Font("Arial", Font.PLAIN, Integer.parseInt(read[9])));
button[letterButtonArray].setBackground(backgroundColor);
button[letterButtonArray].setOpaque(true); // Test für MAC
button[letterButtonArray].setMinimumSize(new java.awt.Dimension(20, 20));
button[letterButtonArray].setPreferredSize(new java.awt.Dimension(100, 100));
button[letterButtonArray].setBorder(new javax.swing.border.
SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
button[letterButtonArray].setFocusable(false);
// X und Y Zuweisung der Button im GridbagLayout
letterButtongbc.gridx = xVar;
letterButtongbc.gridy = yVar;
xVar++;
if(xVar > 14){ yVar++ ; xVar = 0; } // 17 / für Buttons in einem jPanel
jPanel2.add( button[letterButtonArray] , letterButtongbc ); // jPanel2
}
add(jPanel2 , java.awt.BorderLayout.CENTER ); // getContentPane().
pack();
// Berechnung der Position über der Taskleiste
Dimension frameSize = this.getSize();
// BildschirmBreite - FensterBreite / 2
setLocation( (int)( screenSizeWidth - frameSize.width ) / 2 ,
// BildschirmHöhe - FensterHöhe - TaskbarHöhe
screenSizeHeight - frameSize.height - taskbarSize );
答案 0 :(得分:0)
创建一个水平框并在水平框中输入3个textareas。
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<Script>
getValue(5);
function getValue(id){
alert(id);
// i am trying this but not done
$.ajax({
type: "POST",
data: {id:id},
url: "http://localhost/key/index2.php/",
success: function(data){
alert(data);
}
});
}
</script>
in index2.php
<?php
session_start();
$_SESSION['id']=$_POST['id'];
echo $_SESSION['id'];
?>