001:/*
002: * Html.java
003: *
004: * Created on 21 September 2007, 17:38
005: *
006: * To change this template, choose Tools | Template Manager
007: * and open the template in the editor.
008: */
009:
010:package xui.samples.carousel.components;
011:
012:import com.xoetrope.swing.XHtmlText;
013:import com.xoetrope.swing.XRollupBar;
014:import java.awt.Color;
015:import java.awt.event.ActionEvent;
016:import java.awt.event.ActionListener;
017:import java.awt.event.MouseEvent;
018:import java.awt.event.MouseListener;
019:import javax.swing.BorderFactory;
020:import javax.swing.JOptionPane;
021:import net.xoetrope.optional.annotation.Find;
022:import net.xoetrope.swing.XButton;
023:import net.xoetrope.swing.XLabel;
024:import net.xoetrope.swing.XPanel;
025:import net.xoetrope.xui.XPage;
026:
027:/**
028: *
029: * @author kingsley.elmes
030: */
031:public class Html extends XPage implements MouseListener
032:{
033: @Find
034: private XPanel mainPanel;
035: @Find
036: private XRollupBar rollupBar;
037: @Find
038: private XButton rollDwnBtn, rollUpBtn;
039: @Find
040: private XHtmlText htmlText;
041: private String currentUrl;
042: private boolean down;
043:
044: /** Creates a new instance of Html */
045: public Html()
046: {
047: currentUrl = "http://www.xoetrope.com";
048: down = false;
049: }
050:
051: public void pageCreated()
052: {
053: mainPanel.setBackground( Color.white );
054: rollupBar.addButton( "Click to enter URL", "xui_icon2.png", null, new XPanel() );
055: rollupBar.getButton( 0 ).setOpaque( true );
056: rollupBar.getButton( 0 ).addMouseListener( this );
057: rollupBar.setBackground( Color.white );
058: rollupBar.setBackgroundAt( 0, Color.white );
059: rollupBar.setForegroundAt( 0, Color.blue );
060: rollupBar.getComponent( 1 ).setBackground( Color.white );
061: rollDwnBtn.setFocusable( false );
062: rollUpBtn.setFocusable( false );
063:
064: rollDwnBtn.addActionListener( new ActionListener() {
065: public void actionPerformed(ActionEvent e)
066: {
067: if( down == false ){
068: rollupBar.slide( 0, 1, 25, this , e );
069: down = true;
070: }
071: }
072: });
073:
074: rollUpBtn.addActionListener( new ActionListener() {
075: public void actionPerformed(ActionEvent e)
076: {
077: if( down ){
078: rollupBar.slide( 0, 1, 0, this , e );
079: down = false;
080: }
081: }
082: });
083: }
084:
085: public void mouseClicked(MouseEvent e)
086: {
087: String s = (String)JOptionPane.showInputDialog(
088: project.getAppFrame(),
089: "Enter website URL:\n",
090: "Enter URL",
091: JOptionPane.PLAIN_MESSAGE,
092: null,
093: null,
094: currentUrl );
095:
096: if( s != null ){
097: currentUrl = s;
098: htmlText.setAttribute( "html", currentUrl );
099: }
100: }
101:
102: public void mousePressed(MouseEvent e){}
103: public void mouseReleased(MouseEvent e){}
104: public void mouseEntered(MouseEvent e){}
105: public void mouseExited(MouseEvent e){}
106:}
|