急求一元多项式计算图形界面 自己做了半天没做出来 请高手帮忙采用菜单驱动方式进行执行,不要求进行计算的算法,只要操作的图形界面具体界面样子 如图所示,只需要实现图形的功能,不要求加,减,乘的算法~~~~式子1和式子2是菜单`~~

解决方案 »

  1.   

    swing? 你还是找个 与 swing相关的内容看下吧
      

  2.   

    只是SWING界面吧
    搜搜  很多的
      

  3.   

    用个JDialog或者JFrame作为主窗口。
    布局用BorderLayout就可以
    JTextArea放在center;
    装载按钮的JPanel放在south,可以设置成Flowlayout。
    菜单setJMenuBar()
      

  4.   

    package zz;import java.awt.BorderLayout;
    import java.awt.Container;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.HashMap;
    import java.util.Map;import javax.swing.Box;
    import javax.swing.BoxLayout;
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JMenuBar;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;public class CalculateUI extends JFrame { private static final long serialVersionUID = 1L; private JTextArea area; public CalculateUI() {
    super();
    JMenuBar bar = new JMenuBar(); JButton bt1 = new JButton("式子1");
    bt1.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    HashMap rsMap = ParamDialog.showDialog();
    if (rsMap != null) {
    String content1 = (String) rsMap.get("content1");
    String content2 = (String) rsMap.get("content2"); String oldContent = area.getText(); area.setText(oldContent + "<--" + content1 + "--"
    + content2 + "-->"); }
    }
    });
    JButton bt2 = new JButton("式子2");
    bar.add(bt1);
    bar.add(bt2);
    setJMenuBar(bar);
    area = new JTextArea();
    area.setLineWrap(true);
    JScrollPane jsp = new JScrollPane(area);
    add(jsp, BorderLayout.CENTER);
    add(createButtonBox(), BorderLayout.SOUTH); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(600, 400);
    setResizable(false);
    setVisible(true);
    } private Box createButtonBox() {
    Box box = new Box(BoxLayout.X_AXIS);
    JButton addButton = new JButton("加");
    JButton subButton = new JButton("减");
    JButton mulButton = new JButton("乘"); box.add(Box.createHorizontalStrut(200));
    box.add(addButton);
    box.add(Box.createHorizontalStrut(40));
    box.add(subButton);
    box.add(Box.createHorizontalStrut(40));
    box.add(mulButton);
    box.add(Box.createHorizontalStrut(40)); return box;
    } static class ParamDialog extends JDialog { private static final long serialVersionUID = 1L;
    private static ParamDialog dialog = new ParamDialog();
    HashMap resultMap = null;
    JTextField field1;
    JTextField field2; public ParamDialog() {
    Container c = getContentPane();
    GridLayout grid = new GridLayout(3, 2);
    c.setLayout(grid);
    grid.setHgap(5);
    grid.setVgap(5); JLabel lbl1 = new JLabel("输入系数格式 1,1,1");
    c.add(lbl1);
    JLabel lbl2 = new JLabel("输入指数格式 1,1,1");
    c.add(lbl2); field1 = new JTextField(20);
    c.add(field1);
    field2 = new JTextField(20);
    c.add(field2); JButton okButton = new JButton("确定");
    okButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    String content1 = field1.getText().trim();
    String content2 = field2.getText().trim(); resultMap = new HashMap();
    resultMap.put("content1", content1);
    resultMap.put("content2", content2); dialog.setVisible(false);
    }
    });
    c.add(okButton);
    JButton cancelButton = new JButton("取消");
    cancelButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    resultMap = null;
    dialog.setVisible(false);
    }
    });
    c.add(cancelButton); setModal(true);
    setSize(200, 100);
    setLocationRelativeTo(null);
    } public static HashMap showDialog() {
    dialog.resultMap = null;
    dialog.setVisible(true);
    return dialog.resultMap;
    } } public static void main(String args[]) {
    new CalculateUI();
    }}
    大概写了一下,弹出的对话框多加了个按钮。控制起来方便一些。剩下的部分你自己应该很轻松可以补充了。
    努力学习~~共同进步~~