⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 movieitemview.java

📁 一个简单的浏览器
💻 JAVA
字号:
import java.util.*;import java.awt.*;import java.awt.event.*;import javax.swing.*;public class MovieItemView extends WmvcView implements ActionListener{	protected GridBagLayout gridbag;	protected GridBagConstraints c;		private JPanel itemPanel;	private MovieModel myModel;		private static JLabel lblTitle=		new JLabel("Movie Title:");	private static JLabel fldTitle=		new JLabel();	private static JLabel lblDirector=		new JLabel("Director:");	private static JLabel fldDirector=		new JLabel();	private static JLabel lblYear=		new JLabel("Year:");	private static JLabel fldYear=		new JLabel();	private static JLabel lblRating=		new JLabel("Rating:");	private static JLabel fldRating=		new JLabel();	private static JLabel lblGenre=		new JLabel("Genre:");	private static JLabel fldGenre=		new JLabel();	private static JLabel lblFormat=		new JLabel("Format:");	private static JLabel fldFormat=		new JLabel();	private static JLabel lblLabel=		new JLabel("Label");	private static JLabel fldLabel=		new JLabel();	private static JLabel lblEvaluation=		new JLabel("My Rating:");	private static JLabel fldEvaluation=		new JLabel();	private static JLabel lblComments=		new JLabel("Comments:");	private static JTextArea textArea;	private static JButton bPrevious;	private static JButton bNext;	private static JButton bEdit;		public JPanel getPanel(){		return itemPanel;		}		protected void setAndAdd(JComponent comp,		int gx,int gy,int gheight,int gwidth,double wx){		c.anchor=c.WEST;		c.gridx=gx;		c.gridy=gy;		c.gridheight=gheight;		c.gridwidth=gwidth;		c.weightx=wx;		gridbag.setConstraints(comp,c);	}		public MovieItemView(){		myModel=(MovieModel)WmvcApp.getModel();		myModel.addView(this);				itemPanel=new JPanel();		gridbag=new GridBagLayout();		c=new GridBagConstraints();				itemPanel.setLayout(gridbag);		itemPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));				fldTitle.setForeground(Color.black);		fldDirector.setForeground(Color.black);		fldYear.setForeground(Color.black);		fldRating.setForeground(Color.black);		fldGenre.setForeground(Color.black);		fldFormat.setForeground(Color.black);		fldLabel.setForeground(Color.black);		fldEvaluation.setForeground(Color.black);		//Movie Title:		setAndAdd(lblTitle,0,0,1,1,1.0);		setAndAdd(fldTitle,1,0,1,c.REMAINDER,0.0);		//Director		setAndAdd(lblDirector,0,1,1,1,1.0);		setAndAdd(fldTitle,1,0,1,c.REMAINDER,0.0);		//Year--Genre		setAndAdd(lblYear,0,2,1,1,1.0);		setAndAdd(fldYear,1,2,1,1,0.0);		setAndAdd(lblGenre,2,2,1,c.RELATIVE,0.0);		setAndAdd(fldGenre,3,2,1,c.REMAINDER,0.0);		//Rating--Format		setAndAdd(lblRating,0,3,1,1,1.0);		setAndAdd(fldRating,1,3,1,1,0.0);		setAndAdd(lblFormat,2,3,1,c.RELATIVE,0.0);		setAndAdd(fldRating,3,3,1,c.REMAINDER,0.0);		//My Rating--Label		setAndAdd(lblEvaluation,0,4,1,1,1.0);		setAndAdd(fldEvaluation,1,4,1,1,0.0);		setAndAdd(lblLabel,2,4,1,c.RELATIVE,0.0);		setAndAdd(fldLabel,3,4,1,c.REMAINDER,0.0);		//Comment box		setAndAdd(lblComments,0,5,1,1,0.0);		textArea=new JTextArea(4,30);		JScrollPane textScroll=new JScrollPane(textArea);		setAndAdd(textScroll,1,5,4,c.REMAINDER,0.0);		//Command Buttons		bEdit=new JButton("Edit");		bEdit.setActionCommand("edit");		bEdit.addActionListener(this);		bEdit.setToolTipText("Edit current movie");		setAndAdd(bEdit,1,9,1,1,0.0);				bPrevious=new JButton("Previous");		bPrevious.setActionCommand("previous");		bPrevious.addActionListener(this);		bPrevious.setToolTipText("Go to previous movie");		setAndAdd(bPrevious,2,9,1,1,0.0);				bNext=new JButton("Next");		bNext.setActionCommand("next");		bNext.addActionListener(this);		bNext.setToolTipText("Go to next movie");		setAndAdd(bNext,3,9,1,1,0.0);		}		public void updateView(){		Movie m=myModel.getCurrentMovie();				fldTitle.setText(m.getTitle());		fldDirector.setText(m.getDirector());		fldYear.setText(m.getYear());		fldLabel.setText(m.getLabel());		textArea.setText(m.getComments());				fldRating.setText(MovieRating.stringAt(m.getRating()));		fldGenre.setText(MovieGenre.stringAt(m.getGenre()));		fldFormat.setText(MovieFormat.stringAt(m.getFormat()));		fldEvaluation.setText(MovieEvaluation.stringAt(m.getEvaluation()));	}		public void actionPerformed(ActionEvent e){		if(e.getActionCommand().equals("edit")){			Movie edited=				MovieEditor.getInstance().showDialog(					WmvcApp.getFrame(),					myModel.getCurrentMovie());							}else if(e.getActionCommand().equals("previous")){			myModel.setCurrentMovieIndex(myModel.getCurrentMovieIndex()-1);		}else if(e.getActionCommand().equals("next")){			myModel.setCurrentMovieIndex(myModel.getCurrentMovieIndex()+1);			}				}								}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -