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

📄 windowproperties.java

📁 Java source code IP Camera project for studying. Java源代碼的IP攝像頭項目的研究。
💻 JAVA
字号:
package sept.view;import java.io.BufferedWriter;import java.io.File;import java.io.FileWriter;import java.io.PrintWriter;import java.util.Scanner;/** * Class WindowProperties (ScreenPosition in class diagram) *  * A Container class that holds X,Y coordinates for screen position of the GUI. * Also contains height and width of the window. *  * @author Goran Mateski * @since v1.0 */public class WindowProperties {	/* Window position */	private int xPosition;	private int yPosition;		/* Window size */	private int width;	private int height;		/* constants for default values */	public static final int DEFAULT_X_POS = 100;	public static final int DEFAULT_Y_POS = 100;	public static final int DEFAULT_WIDTH = 500;	public static final int DEFAULT_HEIGHT = 500;		public static final String fileName = "settings.txt";	/* The file has 4 integers in the following format:	 * 	 * x	 * y	 * width	 * height	 * 	 * 	 * 	 * 	 */		/* Monitor identifier for multiple monitor setups */	//private int monitorID; 				/**	 * 	 */	    int settings[]=new int[4];	public void readSettings()	{      //Attempt to open file	  try	  {		Scanner file1=new Scanner(new File("settings.txt"));	    //Grab the first four integers from file		for(int i=0;i<4;i++)		{	      int numPass=file1.nextInt();	      settings[i]=numPass;		}	  } 	  //Print error message if one is received        catch(Exception e)	  {	    System.out.println(e.getMessage());	  }	  xPosition=settings[0];	  yPosition=settings[1];	  width=settings[2];	  height=settings[3];    }			/**	 * 	 */	public void saveSettings()	{	  try	  {		//Write to the file		PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("settings.txt")));		pw.println(xPosition);		pw.println(yPosition);		pw.println(width);		pw.println(height);		pw.close();      }	  //Print any error messages	  catch(Exception e)	  {	    System.out.println(e.getMessage());	  }    }			/**	 * Default constructor. Set window attributes to default values.	 */	public WindowProperties(){		xPosition = DEFAULT_X_POS;		yPosition = DEFAULT_Y_POS;		width = DEFAULT_WIDTH;		height = DEFAULT_HEIGHT;	}				/**	 * A Constructor that takes specific values.	 * 	 * @param xPos The horizontal position.	 * @param yPos Vertical position.	 * @param width Window Width.	 * @param height Window Height.	 */	public WindowProperties(int xPos, int yPos, int width, int height){		this.xPosition = xPos;		this.yPosition = yPos;		this.width = width;		this.height = height;	}				/**	 * Method getXPosition	 * 	 * @return Returns the x coordinate for window position.	 */	public int getXPosition(){		return this.xPosition;	}				/**	 * Method getYPosition	 * 	 * @return Returns the y coordinate for window position.	 */	public int getYPosition(){		return this.yPosition;	}				/**	 * Method getWidth	 * 	 * @return Returns window width (in pixels)	 */	public int getWidth(){		return this.width;	}				/**	 * Method getHeight	 * 	 * @return Returns window height (in pixels)	 */	public int getHeight(){		return this.height;	}			/**	 * Method setPosition	 * 	 * Mutator method to change the pixel coordinates of the window.	 * 	 * @param xPos Pixel value of x coordinate	 * @param yPos Pixel value of y coordinate	 */	public void setPosition(int xPos, int yPos){		this.xPosition = xPos;		this.yPosition = yPos;	}			/**	 * Method setSize	 * 	 * Mutator method to alter pixel values representing a window size.	 * 	 * @param width The width of the window (in pixels)	 * @param height The height of the window (in pixels)	 */	public void setSize(int width, int height){		this.width = width;		this.height = height;	}}

⌨️ 快捷键说明

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