import java.applet.Applet
import java.awt.Color
import java.awt.Label
public class test extends Applet {
private Label label
@Override
public void init() {
label=new Label("欢迎来到java世界!")
label.setBackground(Color.BLUE)
setBackground(Color.PINK)
add(label)
}
}
===============================第二题==============================
因为没图,所以自己设计的界面..
import java.awt.BorderLayout
import java.awt.event.ActionEvent
import java.awt.event.ActionListener
import javax.swing.JButton
import javax.swing.JFrame
import javax.swing.JLabel
import javax.swing.JPanel
import javax.swing.JScrollPane
import javax.swing.JTextArea
public class test implements ActionListener {
private JFrame frame
private JLabel label
private JTextArea jt
private JScrollPane jsp
private JButton show
public test() {
frame=new JFrame("Test")
label=new JLabel("显示内容")
jt=new JTextArea(10,20)
jsp=new JScrollPane(jt)
show = new JButton("显示给定内容")
JPanel panel=new JPanel()
panel.add(label)
panel.add(show)
frame.add(jsp,BorderLayout.NORTH)
frame.add(panel,BorderLayout.SOUTH)
show.addActionListener(this)
show()
}
public void show(){
frame.setLocation(200, 200)
frame.setSize(300, 260)
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
frame.setVisible(true)
}
@Override
public void actionPerformed(ActionEvent e) {
label.setText(jt.getText())
}
public static void main(String[] args) {
new test().show()
}
}
结果为:1 2 3
2 3 4
3 4 5
4 5 6
public class c3_4 {
public static void main(String[] args) {
int a[][] = { { 1, 2, 3, 4 }, { 2, 3, 4, 5 }, { 3, 4, 5, 6 } }
int b[][] = new int[4][3]
int i, j
for (i = 0i <3i++) {
for (j = 0j <4j++) {
b[j][i] = a[i][j]
}
}
for (i = 0i <4i++) {
for (j = 0j <3j++){
System.out.print(b[i][j] + "\t")
}
System.out.println()
}
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)