import java.awt.*
import javax.swing.*
public class JPanelDemo {
public static void main(String args[]) {
JFrameDemoa jf = new JFrameDemoa()
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
jf.setVisible(true)
}
}
class JFrameDemoa extends JFrame {
public JFrameDemoa() {
this.setTitle("nihao")
this.setBounds(100, 100, 200, 200)
Jpanelscreena jll = new Jpanelscreena()
add(jll)
}
}
class Jpanelscreena extends JPanel {
private int width = 20
private int height = 20
public void paintComponnet() {
}
public void paint(Graphics g) {
super.paintComponent(g)
g.drawString("Java is money", 20, 20)
}
}
记得给我分哦^_^
import java.awt.Containerimport java.awt.event.ActionEvent
import java.awt.event.ActionListener
import javax.swing.JButton
import javax.swing.JFrame
import javax.swing.JTextArea
public class RemoveAllFrame extends JFrame implements ActionListener {
private static final long 渣卖蔽serialVersionUID = 20111111111L
private JButton removeAllButton = new JButton("RemoveAll")
private JTextArea textArea = 配碧new JTextArea("点击RemoveAll....")
public RemoveAllFrame() {
super("RemoveAll Demo")
try {
init()
} catch (Exception e) {
e.printStackTrace()
}
}
private void init() {
removeAllButton.setBounds(220, 50, 100, 25)
textArea.setBounds(10, 10, 200, 200)
removeAllButton.addActionListener(this)
Container c = getContentPane()
c.setLayout(null)
c.add(removeAllButton)
c.add(textArea)
this.setSize(400, 300)
this.setResizable(false)
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
this.setLocationRelativeTo(null)
this.setVisible(true)
}
public static void main(String[] args) {
new RemoveAllFrame()
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == removeAllButton) {
System.out.println("ok")
getContentPane().removeAll()
getContentPane().repaint()
}
如州 }
}
import javax.swing.*public class Swing {
JFrame frame
JPanel panel
JLabel jla1,jla2,jla3
JButton jbu
JTextField jtf1,jtf2
JComboBox box
static final String[] email={"正滑263.net","163.com","qq.com"}
public Swing(){
frame=new JFrame()
frame.setSize(600,300)
frame.setLocation(200,100)
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
frame.setVisible(true)
jla1=new JLabel("邮举做腊箱胡配")
jla2=new JLabel("@")
jla3=new JLabel("密码")
jtf1=new JTextField("用户名",10)
jtf2=new JTextField("密码",10)
box=new JComboBox(email)
jbu=new JButton("登陆")
panel=new JPanel()
panel.add(jla1)
panel.add(jtf1)
panel.add(jla2)
panel.add(box)
panel.add(jla3)
panel.add(jtf2)
panel.add(jbu)
frame.add(panel)
}
public static void main(String args[]){
new Swing()
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)