在线观看www成人影院-在线观看www日本免费网站-在线观看www视频-在线观看操-欧美18在线-欧美1级

您好,歡迎來電子發(fā)燒友網! ,新用戶?[免費注冊]

您的位置:電子發(fā)燒友網>源碼下載>編譯器/仿真器>

文本編輯器源碼

大小:8 人氣: 2010-08-28 需要積分:10
chumowei的空間

用戶級別:注冊會員

貢獻文章:

貢獻資料:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import javax.imageio.*;
import java.io.*;

public class EditPanel extends JPanel
{
?public EditPanel()
?{??
??JPanel FontPanel = new JPanel();
??JPanel BackColorPanel = new JPanel();
??JPanel TextAreaPanel = new JPanel();
??ImagePanel picturePanel = new ImagePanel();
??
??JtextArea = new JTextArea(20,40);
??jscrollPane = new JScrollPane(JtextArea);
??
??JPopupMenu jpopupMenu = new JPopupMenu();
??JMenuItem CopyItem = new JMenuItem("復制",new ImageIcon("copy.gif"));
??JMenuItem PastItem = new JMenuItem("粘貼",new ImageIcon("paste.gif"));
??JMenuItem CutItem = new JMenuItem("剪切",new ImageIcon("cut.gif"));
??
??Action pictureAction = new PictureAction();??
??CopyItem.addActionListener(pictureAction);
??PastItem.addActionListener(pictureAction);
??CutItem.addActionListener(pictureAction);
??
??CopyItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,InputEvent.CTRL_DOWN_MASK));
??CopyItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,InputEvent.CTRL_DOWN_MASK));
??CopyItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,InputEvent.CTRL_DOWN_MASK));

??jpopupMenu.add(CopyItem).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,InputEvent.CTRL_DOWN_MASK));
??jpopupMenu.add(PastItem).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,InputEvent.CTRL_DOWN_MASK));
??jpopupMenu.add(CutItem).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,InputEvent.CTRL_DOWN_MASK));
??
??JtextArea.setComponentPopupMenu(jpopupMenu);


??font = new Font("宋體",Font.PLAIN,12);??
??JLabel TypeLabel = new JLabel("類型:");
??JLabel SizeLabel = new JLabel("大小:");
??JLabel ModelLabel = new JLabel("樣式:");
??
??ColorSlider1 = new JSlider(0,255,0);
??ColorSlider2 = new JSlider(0,255,0);
??ColorSlider3 = new JSlider(0,255,0);
??ColorSlider1.setPaintTicks(true);
??ColorSlider2.setPaintTicks(true);
??ColorSlider3.setPaintTicks(true);
??ColorSlider1.setMajorTickSpacing(51);
??ColorSlider2.setMajorTickSpacing(51);
??ColorSlider3.setMajorTickSpacing(51);
??ColorSlider1.setMinorTickSpacing(3);
??ColorSlider2.setMinorTickSpacing(3);
??ColorSlider3.setMinorTickSpacing(3);
??ColorSlider1.setPaintTicks(true);
??ColorSlider2.setPaintTicks(true);
??ColorSlider3.setPaintTicks(true);
??ColorSlider1.setPaintLabels(true);
??ColorSlider2.setPaintLabels(true);
??ColorSlider3.setPaintLabels(true);
??
??String[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().
??getAvailableFontFamilyNames();
??ModelComboBox = new JComboBox(fonts);
??SizeSlider = new JSlider(0,100,12);
??SizeSlider.setMajorTickSpacing(20);
??SizeSlider.setMinorTickSpacing(2);
??SizeSlider.setPaintTicks(true);
??SizeSlider.setPaintLabels(true);
??TypeCheckBox1 = new JCheckBox("常規(guī)");
??TypeCheckBox2 = new JCheckBox("傾斜");
??TypeCheckBox3 = new JCheckBox("加粗");
??
??BackColorListener ColorListener = new BackColorListener();
??ActionListener listener = new FontListener();
??TypeCheckBox1.addActionListener(listener);
??TypeCheckBox2.addActionListener(listener);
??TypeCheckBox3.addActionListener(listener);
??ModelComboBox.addActionListener(listener);
??ColorSlider1.addChangeListener(ColorListener);
??ColorSlider2.addChangeListener(ColorListener);
??ColorSlider3.addChangeListener(ColorListener);
??SizeSlider.addChangeListener(new ChangeListener()
??{
???public void stateChanged(ChangeEvent event)
???{
????JtextArea.setFont(new Font((String)ModelComboBox.getSelectedItem(),font.getStyle(),SizeSlider.getValue()));????
???}???
??});
??
??setLayout(new GridBagLayout());
??FontPanel.setLayout(new GridBagLayout());
??BackColorPanel.setLayout(new GridBagLayout());
??TextAreaPanel.setLayout(new BorderLayout());

??add(FontPanel,new View(0,0).setAnchor(View.CENTER).setInsets(5,5,0,5).setIpad(2, 2).setFill(View.HORIZONTAL).setWeight(0, 0));
??add(BackColorPanel,new View(0,1).setAnchor(View.CENTER).setFill(View.HORIZONTAL).setInsets(5).setWeight(0, 0));
??add(picturePanel,new View(0,2).setAnchor(View.CENTER).setFill(View.BOTH).setInsets(5).setWeight(0,100));
??add(TextAreaPanel,new View(1,0,1,4).setWeight(100, 100).setFill(View.BOTH));
??
??TextAreaPanel.add(jscrollPane,BorderLayout.CENTER);
??
??FontPanel.add(TypeLabel,new View(0,0));
??FontPanel.add(SizeLabel,new View(0,1));
??FontPanel.add(ModelLabel,new View(0,2));
??FontPanel.add(TypeCheckBox1,new View(1,0).setAnchor(View.WEST).setInsets(10));
??FontPanel.add(TypeCheckBox2,new View(2,0).setAnchor(View.WEST).setInsets(10));
??FontPanel.add(TypeCheckBox3,new View(3,0).setAnchor(View.WEST).setInsets(10));
??FontPanel.add(SizeSlider,new View(1,1,3,1).setAnchor(View.WEST).setFill(View.HORIZONTAL).setInsets(5));
??FontPanel.add(ModelComboBox,new View(1,2,3,1).setInsets(10));
??
??BackColorPanel.add(ColorSlider1,new View(0,0).setInsets(5).setFill(View.BOTH).setWeight(100, 100).setIpad(5, 5));
??BackColorPanel.add(ColorSlider2,new View(0,1).setInsets(5).setFill(View.BOTH).setWeight(100, 100).setIpad(5, 5));
??BackColorPanel.add(ColorSlider3,new View(0,2).setInsets(5).setFill(View.BOTH).setWeight(100, 100).setIpad(5, 5));

??Border LowerBorder = BorderFactory.createLoweredBevelBorder();
??Border AreaTextTitle = BorderFactory.createTitledBorder(LowerBorder, "文本框");
??jscrollPane.setBorder(AreaTextTitle);
??
??Border EtchedBorder = BorderFactory.createEtchedBorder();
??Border FontTitle = BorderFactory.createTitledBorder(EtchedBorder, "字體");
??FontPanel.setBorder(FontTitle);
??
??Border BackColorTitle = BorderFactory.createTitledBorder(EtchedBorder, "背景");
??BackColorPanel.setBorder(BackColorTitle);
?}
?
?public JTextArea getTextArea ()
?{
??return JtextArea;??
?}
?private class FontListener implements ActionListener
?{
??public void actionPerformed(ActionEvent event)
??{
???int map = 0;
???if(TypeCheckBox1.isSelected())
???{
????map = Font.PLAIN;
????TypeCheckBox2.setSelected(false);
????TypeCheckBox3.setSelected(false);
????font = font.deriveFont(map);
???}
???if(TypeCheckBox2.isSelected())
???{
????map +=Font.ITALIC;
????TypeCheckBox1.setSelected(false);
????font = font.deriveFont(map);
???}
???if(TypeCheckBox3.isSelected())
???{
????map +=Font.BOLD;
????TypeCheckBox1.setSelected(false);?
????font = font.deriveFont(map);
???}
???JtextArea.setFont(new Font((String)ModelComboBox.getSelectedItem(),font.getStyle(),SizeSlider.getValue()));
??}??
?}
?private class BackColorListener implements ChangeListener
?{
??public void stateChanged(ChangeEvent event)
??{
???int a = ColorSlider1.getValue();
???int b = ColorSlider2.getValue();
???int c = ColorSlider3.getValue();
???JtextArea.setBackground(new Color(a,b,c));
??}??
?}
?private class PictureAction extends AbstractAction
?{
??public void actionPerformed(ActionEvent event)
??{
???System.out.println(getValue(Action.NAME) + "按鈕被選擇了!");
??}
?}
???? class ImagePanel extends JPanel
?{?
??? public ImagePanel()
??? {?
?????? // acquire the image
?????? try
?????? {
????????? image = ImageIO.read(new File("heihei.gif"));
?????? }
?????? catch (IOException e)
?????? {
????????? e.printStackTrace();
?????? }
??? }
???
??? public void paintComponent(Graphics g)
??? {?
?????? super.paintComponent(g);
?????? if (image == null) return;
???
?????? int imageWidth = image.getWidth(this);
?????? int imageHeight = image.getHeight(this);

?????? // draw the image in the upper-left corner
??????
?????? g.drawImage(image, 0, 0 ,this.getWidth(),this.getHeight(),null);
?????? // tile the image across the panel
??? }
?}

?private JTextArea JtextArea;
?private Font font;
?private JCheckBox TypeCheckBox1;
?private JCheckBox TypeCheckBox2;
?private JCheckBox TypeCheckBox3;
?private JSlider SizeSlider;
?private JComboBox ModelComboBox;
?private JSlider ColorSlider1;
?private JSlider ColorSlider2;
?private JSlider ColorSlider3;
?private JScrollPane jscrollPane;
?private Image image;

}

非常好我支持^.^

(0) 0%

不好我反對

(0) 0%

文本編輯器源碼下載

相關電子資料下載

      發(fā)表評論

      用戶評論
      評價:好評中評差評

      發(fā)表評論,獲取積分! 請遵守相關規(guī)定!

      ?
      主站蜘蛛池模板: 都市激情综合网| 天天爽夜夜爽夜夜爽| 免费一看一级毛片全播放| 制服丝袜在线一区| 日日摸夜夜爽| 亚洲欧美综合一区二区三区四区| 亚洲free| 国产乱辈通伦影片在线播放亚洲 | 天天做天天爰夜夜爽| 亚洲成a人伦理| 天堂资源在线www中文| 国产成人小视频| 1024国产基地永久免费| 天堂在线观看视频观看www| 成年人的毛片| 丁香婷婷啪啪| 日本久久久| www.最色| 成年人啪啪网站| 日本番囗| 欧美adc影院| 亚洲国产激情在线一区| 日本.www| 人人澡 人人澡 人人看| 国产午夜精品久久久久免费视| 快色视频在线观看| 国产福利免费观看| 泰国一级毛片aaa下面毛多| 新版天堂资源中文在线| 日本一卡精品视频免费| 米奇色影院| 在线视频网址免费播放| 日韩一级一欧美一级国产| 日日夜夜精品| 午夜色大片| 天天干天天射天天| 黄色网免费| 农村一级片| 456成人免费高清视频| 日韩a一级欧美一级| 精品久久久久久久免费加勒比|