----Publicwindowset of Students ' course selection system

Source: Internet
Author: User

/** * @author Li Pei * * @version v1 * * @time 2016/12/7 22:55 * * @program This class is mainly for some windows often write duplicate code package * */package Com.csms.win Dows;import java.awt.borderlayout;import java.awt.color;import Java.awt.dimension;import java.awt.Font;import Java.awt.image;import Java.awt.toolkit;import Javax.swing.icon;import Javax.swing.imageicon;import Javax.swing.jframe;import Javax.swing.jlabel;import Javax.swing.joptionpane;import Javax.swing.JPanel;import Javax.swing.jscrollpane;import Javax.swing.jtable;import Javax.swing.jtextfield;import Javax.swing.table.abstracttablemodel;import Javax.swing.table.defaulttablemodel;public class PublicWindowSet { private static JTable table = null;private static DefaultTableModel tablemodel;//tagging method encapsulates public static void AddLabel (Jfra Me jfr, int size, int x, int y, int wide, int high, String str) {font font = null;//font settings, use bold in some special cases, use normal font if in some cases ( Str.equals ("Administrator Info") | | Str.equals ("Student Information entry") | | Str.equals ("Teacher Information entry") | | Str.equals ("Row Lesson Information entry") | | Str.equals ("Delete student Information") | | STr.equals ("delete teacher info") | | Str.equals ("Delete Course info")) {font = new font ("Italic", font.bold, size),} else {font = new font ("Italic", font.plain, size);} JLabel Adminlabel = new JLabel (str);//Set the label font adminlabel.setfont (fonts); if (str.equals ("admin info") | | str.equals ("Student Information Entry") || Str.equals ("Teacher Information entry") | | Str.equals ("Row Lesson Information entry") | | Str.equals ("Delete student Information") | | Str.equals ("delete teacher info") | | Str.equals ("Delete Course information") {Adminlabel.setforeground (color.white);} else {adminlabel.setforeground (color.black);} Sets the position of the label adminlabel.setbounds (x, Y, wide, high); Jfr.add (Adminlabel);} Add avatar public static void Addphotolabel (JFrame jfr, int x, int y, int. wide, int high, String URL) {icon icon = new Imageic On (URL);//Add the image to the label JLabel Photolabel = new JLabel (icon);p hotolabel.setbounds (x, Y, wide, high); Jfr.add (Photolabel);} Window properties public static void Windowattribute (JFrame JFR, int. wide, int high, string backurl, string title) {//Set window icon WINDOWSI Con (JFR);//Window Center display Windowiscenter (wide, high, JFR);//Set window background windowsbackground (Backurl, JFR);//Set Window caption Jfr.settiTle (title);//Set window size jfr.setsize (wide, high);//Set window visible jfr.setvisible (TRUE);//Set window size cannot change jfr.setresizable (false);} Window icon set public static void Windowsicon (JFrame jfr) {String url = "Src//images//icons//loginicon1.png"; Image icon = new Im Ageicon (URL). GetImage (); Jfr.seticonimage (icon);} Window Center display public static void Windowiscenter (int windowwide, int windowhigh, JFrame frame) {//Get screen width int screenwide = Toolk It.getdefaulttoolkit (). Getscreensize (). Width;int Screenhigh = Toolkit.getdefaulttoolkit (). GetScreenSize (). Height ;//Calculate center scale int x = SCREENWIDE/2-Windowwide/2;int y = screenhigh/2-windowhigh/2;//Set Window center frame.setlocation (x, y) ;} Setting the window background shows public static void Windowsbackground (String url, JFrame jfr) {icon icon = new ImageIcon (URL); JLabel BackLabel = new JLabel (icon); Jfr.add (BackLabel);} Set label public static void Addtextfield (JTextField tf, int x, int y, int wide, int. high, JFrame JFR) {tf.setbounds (x, Y, WI DE, high);//Set Label transparent Tf.setopaque (FALSE); Jfr.add (TF);} Prompt pop-up box public static Void promptpopup (string content, string title, JFrame jfr) {Joptionpane.showmessagedialog (Jfr.getcontentpane (), content, Title, joptionpane.information_message);} Add list public static DefaultTableModel addtablelist (JFrame jfr, string[] str) {//Set Jtabel default Type TableModel = new DefaultTab Lemodel (new Courselist (str). UserInfo, new Courselist (str). titles);//Add JLabel Component table = new JTable (TableModel);// Prevents JLabel components from changing with the size of the window Table.setautoresizemode (jtable.auto_resize_off); Jtabel Component Table display size table.setpreferredscrollableviewportsize (new Dimension (600, 0));// Make the list unavailable for the whole column to move table.gettableheader (). setreorderingallowed (false);//Make the list box not editable table.enable (false);// Add the slider bar JScrollPane scr = new JScrollPane (table) to the Jtabel component,//Add the Tabel component with the scrollbar to the eastern area of the panel jfr.add (SCR, borderlayout.center); return TableModel;}} Table Implementation Class Courselist extends Abstracttablemodel {public string[] titles = Null;public object[][] userInfo = {};// Define data public courselist (string[] str) {titles = str;} public int GetRowCount () {return 0;} public intgetColumnCount () {return 0;} Public Object getvalueat (int rowIndex, int columnindex) {return null;}}

  

----Publicwindowset of Students ' course selection system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.