[Ajax4JSF] richfaces中怎样用a4j:mediaOutput在頁面顯示一個applet呀?
Mrpublic
2009-04-17
用a4j:mediaOutput 怎樣在頁面顯示一個applet的小運用程序呀??
头疼呀 看richfaces的demo中 <a4j:mediaOutput element="img" cacheable="false" session="true" createContent="#{mediaBean.paint}" value="#{mediaData}" mimeType="image/jpeg" /> 我把element="applet" mineType="application/x-java-applet" 就是那个createContent="#{mediaBean.paint}" 不知道怎样把一个applet out出来,我的applet 是一个计算器 请帮忙分析出绿色内的代码。。 或有很好的建议: 先谢谢。。。 |
|
Mrpublic
2009-04-17
import java.awt.*; import java.awt.event.*; import java.io.IOException; import java.io.OutputStream; import javax.swing.*; import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.AutoCreate; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Scope; @Name("calculator") @Scope(ScopeType.SESSION) @AutoCreate public class Calculator extends JFrame implements ActionListener { private static final long serialVersionUID = 1L; private JButton btnZero, btnOne, btnTwo, btnThree, btnFour, btnFive, btnSix, btnSeven, btnEight, btnNine, btnPlus, btnMinus, btnTimes, btnDivided, btnEqual, btnPoint, btnUEqual, btnMore, btnLess, btnEMore, btnELess,btnLeft,btnRight,btnAnd,btnOr,btnQuote,btnRound,btnBack; private StringBuffer str; private int start,end; public void paintCalculator(OutputStream out,Object data)throws IOException{ ... } public Calculator() { super("編輯器"); this.setSize(311, 231); // this.setLocation(300, 300); // this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLayout(new GridLayout(1, 1));// 网格布局 JPanel panel = new JPanel(new GridLayout(6, 1));// 面板 网格布局6行1列 this.add(panel); JPanel panel_1 = new JPanel(new GridLayout(1, 5)); panel.add(panel_1); btnPlus = new JButton("+"); panel_1.add(btnPlus); btnPlus.addActionListener(this); btnMinus = new JButton("-"); panel_1.add(btnMinus); btnMinus.addActionListener(this); btnTimes = new JButton("*"); panel_1.add(btnTimes); btnTimes.addActionListener(this); btnDivided = new JButton("/"); panel_1.add(btnDivided); btnDivided.addActionListener(this); btnQuote = new JButton("'"); panel_1.add(btnQuote); btnQuote.addActionListener(this); JPanel panel_2 = new JPanel(new GridLayout(1, 6)); panel.add(panel_2); btnEqual = new JButton("="); panel_2.add(btnEqual); btnEqual.addActionListener(this); btnMore = new JButton(">"); panel_2.add(btnMore); btnMore.addActionListener(this); btnEMore = new JButton(">="); panel_2.add(btnEMore); btnEMore.addActionListener(this); btnELess = new JButton("<="); panel_2.add(btnELess); btnELess.addActionListener(this); btnLess = new JButton("<"); panel_2.add(btnLess); btnLess.addActionListener(this); btnUEqual = new JButton("<>"); panel_2.add(btnUEqual); btnUEqual.addActionListener(this); JPanel panel_3 = new JPanel(new GridLayout(1, 4)); panel.add(panel_3); btnLeft = new JButton("("); panel_3.add(btnLeft); btnLeft.addActionListener(this); btnRight = new JButton(")"); panel_3.add(btnRight); btnRight.addActionListener(this); btnAnd = new JButton("and"); panel_3.add(btnAnd); btnAnd.addActionListener(this); btnOr = new JButton("or"); panel_3.add(btnOr); btnOr.addActionListener(this); JPanel panel_4 = new JPanel(new GridLayout(1, 6)); panel.add(panel_4); btnZero = new JButton("0"); panel_4.add(btnZero); btnZero.addActionListener(this); btnOne = new JButton("1"); panel_4.add(btnOne); btnOne.addActionListener(this); btnTwo = new JButton("2"); panel_4.add(btnTwo); btnTwo.addActionListener(this); btnThree = new JButton("3"); panel_4.add(btnThree); btnThree.addActionListener(this); btnFour = new JButton("4"); panel_4.add(btnFour); btnFour.addActionListener(this); btnFive = new JButton("5"); panel_4.add(btnFive); btnFive.addActionListener(this); JPanel panel_5 = new JPanel(new GridLayout(1, 5)); panel.add(panel_5); btnSix = new JButton("6"); panel_5.add(btnSix); btnSix.addActionListener(this); btnSeven = new JButton("7"); panel_5.add(btnSeven); btnSeven.addActionListener(this); btnEight = new JButton("8"); panel_5.add(btnEight); btnEight.addActionListener(this); btnNine = new JButton("9"); panel_5.add(btnNine); btnNine.addActionListener(this); btnPoint = new JButton("."); panel_5.add(btnPoint); btnPoint.addActionListener(this); JPanel panel_6 = new JPanel(new GridLayout(1, 2)); panel.add(panel_6); btnRound = new JButton("Round"); panel_6.add(btnRound); btnRound.addActionListener(this); btnBack = new JButton("Backspace"); panel_6.add(btnBack); btnBack.addActionListener(this); str = new StringBuffer(); this.setVisible(true); } public void actionPerformed(ActionEvent e) { if (e.getSource() == btnPlus) { str.append("+ "); } if (e.getSource() == btnMinus) { str.append("- "); } if (e.getSource() == btnTimes) { str.append("* "); } if (e.getSource() == btnDivided) { str.append("/ "); } if (e.getSource() == btnEqual) { str.append("= "); } if (e.getSource() == btnPoint) { str.append(". "); } if (e.getSource() == btnUEqual) { str.append("<> "); } if (e.getSource() == btnMore) { str.append("> "); } if (e.getSource() == btnLess) { str.append("< "); } if (e.getSource() == btnEMore) { str.append(">= "); } if (e.getSource() == btnELess) { str.append("<= "); } if (e.getSource() == btnQuote) { str.append("' "); } if (e.getSource() == btnZero) { str.append("0 "); } if (e.getSource() == btnOne) { str.append("1 "); } if (e.getSource() == btnTwo) { str.append("2 "); } if (e.getSource() == btnThree) { str.append("3 "); } if (e.getSource() == btnFour) { str.append("4 "); } if (e.getSource() == btnFive) { str.append("5 "); } if (e.getSource() == btnSix) { str.append("6 "); } if (e.getSource() == btnSeven) { str.append("7 "); } if (e.getSource() == btnEight) { str.append("8 "); } if (e.getSource() == btnNine) { str.append("9 "); } if (e.getSource() == btnLeft) { str.append("( "); } if (e.getSource() == btnRight) { str.append(") "); } if (e.getSource() == btnAnd) { str.append("and "); } if (e.getSource() == btnOr) { str.append("or "); } if (e.getSource() == btnRound) { str.append("Round "); } if (e.getSource() == btnBack) { if(!(str.length()==0)){ end= str.lastIndexOf(" "); start=str.lastIndexOf(" ",end ); str.delete(start, end); } } } } |
|
Mrpublic
2009-04-17
![]() |