JAVA图形界面设计 在awt/swing里绘制圆形的方法是g.drawOval(x,y,width,height);x,y代表外接正方形的左顶点坐标width和height相同是就是圆形.代表直径参考代码import java.awt.Color;import java.awt.Font;import java.awt.Graphics;import javax.swing.JFrame;import javax.swing.JPanel;public class TestFrame extends JFrame {public TestFrame(){add(new CirclePanel());setSize(300,230);setLocationRelativeTo(null);setDefaultCloseOperation(EXIT_ON_CLOSE);}public static void main(String[]args){new TestFrame().setVisible(true);}绘制图形的面板class CirclePanel extends JPanel {int R=50;直径Overrideprotected void paintComponent(Graphics g){super.paintComponent(g);g.setColor(Color.BLUE);设置颜色为蓝色g.drawOval(80,30,R,R);圆形外接矩形的左顶点坐标是80,30;g.setColor(Color.BLACK);g.drawOval(120,30,R,R);g.setColor(Color.RED);g.drawOval(160,30,R,R);g.setColor(Color.YELLOW);g.drawOval(100,65,R,R);g.setColor(Color.GREEN);g.drawOval(140,65,R,R);g.setColor(Color.BLUE);设置颜色为蓝色g.setFont(new Font(\"宋体\",Font.BOLD。
关于JAVA图形界面设计的一个问题高手进 rzhrt说得很对,简单实现了个,lz自己看看吧:import javax.swing.*;import java.awt.*;import java.awt.event.*;public class DrawComponent extends JFrame{JComponent component;JPanel contPane=new JPanel();JPanel paintPane=new JPanel();JButton startButton=new JButton(\"Start to Paint\");Font font=new Font(\"宋体\",Font.PLAIN,12);boolean drawable=false;boolean beginDrawing=false;int startx;int starty;int endx;int endy;public DrawComponent(final JComponent component){super(\"Draw Component\");Dimension d=Toolkit.getDefaultToolkit().getScreenSize();setBounds((d.width-700)/2,(d.height-600)/2,700,600);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.component=component;startButton.setFont(font);contPane.setLayout(new BorderLayout());contPane.add(startButton,\"South\");contPane.add(paintPane,\"Center\");paintPane.setLayout(null);startButton.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){drawable=true;}});contPane.addMouseListener(new MouseAdapter(){public void 。
java程序设计一个最简单图形界面程序 要有注释的 一个简单的表格,就显示两行数据package cn.mff.mvc.view.studentdialog;import java.awt.Color;import javax.swing.*;import javax.swing.JTable;import javax.swing.table.*;import oracle.jdeveloper.layout.OverlayLayout2;一个测试,看JTable怎么用public class TableTest extends JFrame{private JTable table;private JScrollPane scrollPane;private JTableHeader tableh;public TableTest(){super(\"表格显示\");设置JTable的title和contentObject[][]content={{\"mafeifei\",\"12\",\"f\",\"24\"},{\"wangran\",\"4\",\"f\",\"20\"}};String[]title={\"name\",\"number\",\"sex\",\"age\"};table=new JTable(content,title);设置背景色table.setBackground(new Color(230,230,230));jtable没有选中的文字颜色table.setForeground(new Color(0,0,0));设置边线线条table.setGridColor(Color.CYAN);tableh=table.getTableHeader();设置表头背景色tableh.setBackground(Color.GREEN);scrollPane=new JScrollPane(table);getContentPane().add(scrollPane);}public static void main(String[]args){TableTest test=new TableTest();test.setSize(400,300);test.setDefaultCloseOperation。
java图形界面设计 /*因为是用long型来存储结果,所以如果你想求更大的阶乘的话换类型或者用其它的求高精度数值类*/import javax.swing.JFrame;import javax.swing.JPanel;import java.awt.BorderLayout;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JTextField;import javax.swing.JButton;import java.awt.event.ActionListener;import java.awt.event.ActionEvent;public class TestFact extends JFrame {private JTextField jtfNum;private JTextField jtfResult;public TestFact(){JPanel panel=new JPanel();getContentPane().add(panel,BorderLayout.CENTER);panel.setLayout(null);JLabel jlaInput=new JLabel(\"输入一个数:\");jlaInput.setBounds(12,94,70,28);panel.add(jlaInput);jtfNum=new JTextField();jtfNum.setBounds(121,94,114,30);panel.add(jtfNum);jtfNum.setColumns(10);JButton jbtCompute=new JButton(\"求阶乘\");jbtCompute.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){fact();}});jbtCompute.setBounds(67,151,117,24);panel.add(jbtCompute);jtfResult=new JTextField();。