/* main- frame */
import java.awt.* ; import java.awt.event.* ;
import javax.swing.* ; public class Mainframe {
public Mainframe() {
// TODO Auto-generated constructor stub
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
SimpleThread ST = new SimpleThread();
ST.start();
}
}
/* simple thread */
import java.awt.* ; import java.awt.event.* ;
import javax.swing.* ; import java.lang.Thread.*; class SimpleThread extends Thread { public SimpleThread() { // super(str); } public void run() { System.out.println("enter");
PaintDisp P= new PaintDisp();
P.init();
Mouseact MA= new Mouseact();
//MA.paint1();
//P.start();
System.out.println(" mouse exits");
System.out.println("exits");
for (int i = 0; i < 100; i++)
{
// Mouseact MA= new Mouseact();
System.out.println("hi");
try {
sleep((int)(Math.random() * 10));
} catch (InterruptedException e) {}
}
System.out.println("DONE! " + getName());
}
}
/* paint disp */
import java.awt.* ; import java.awt.event.* ; import javax.swing.* ;
import java.io.; import java.awt.image.; import java.lang.Thread.*; public class PaintDisp extends Constants implements Runnable{
public void run(){init(); }
public void init(){
setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
setSize((int)xpix,(int)ypix);
setUndecorated(true);
show();
}
public void paint(Graphics g) {
//super(paint);
Graphics2D g2=(Graphics2D)g;
g.setColor( dackground ); // background color
g.fillRect( 0, 0, getWidth(), getHeight() ); // To draw (xpix X ypix) Frame
g.setColor(Color.white);
g.drawRect( 1, 1, getWidth()-3, getHeight()-3 ); // To Draw Outer most Rect
g.drawRect( (int)(meter_border[0]*adjx), (int)(meter_border[1]*adjy), (int)(meter_border[2]*adjx),(int)(meter_border[3]*adjy)); // Static Field Boarder
g.drawRect( //System.out.println(":"+((int)(391*adjx))+":"+((int)(61*adjy))+":"+((getWidth()-401)*(int)adjx)+":"+((getHeight()-279)*(int)adjy));
// mainpower MP= new mainpower();
// To Draw Outer most Rect
ReadTest1 RD= new ReadTest1();
RD.ReadTest2(g,g2);
RD.meterpointer(g, g2,pointerset);
Subsystem SB= new Subsystem();
SB.subsystem(g,g2,subsysystatus);
mainpower MP= new mainpower();
if(rect20Clicked){
// int scr1=1;
MP.screens(g,g2);
MP.screenescape(g,g2);
//rect20Clicked=true ;
}
if(rect1Clicked ){
System.out.println(scrn);
MP.powercircuit(g,g2);
MP.escape(g,g2);
}
//}
else if(rect5Clicked){
MP.TractionMotor(g,g2);
MP.escape(g,g2);
}
else if(rect3Clicked){
MP.AuxiliaryConverter(g,g2);
MP.escape(g,g2);
}
else if(rect7Clicked){
MP.HarmonicHotel(g,g2);
MP.escape(g,g2);
s
}
else if(rect9Clicked){
MP.AuxiliaryMachines(g,g2);
MP.escape(g,g2);
}
else if(rect11Clicked){
MP.SubSystemIsolation(g,g2);
MP.escape(g,g2);
}
else if(rect18Clicked){
System.out.println ("LOCO ="+LOCO);
MP.software_version(g,g2,locono);
MP.escape(g,g2);
}
else if(rect15Clicked){
MP.BrakeSystem(g,g2);
MP.escape(g,g2);
}
else if(rect17Clicked){
MP.wheel_diameter(g,g2);
MP.escape(g,g2);
}
else if(rect19Clicked){
MP.kmearned_enery(g,g2);
MP.escape(g,g2);
}
else if(rect2Clicked){
MP.screens(g,g2);
MP.screenescape(g,g2);
}
else if(rect4Clicked){
MP.escape(g,g2);
}
else if(rect6Clicked){
MP.AuxiliaryMachines (g,g2);
MP.escape(g,g2);
}
else if(rect8Clicked){
MP.HarmonicHotel(g,g2);
MP.escape(g,g2);
}
else if(rect10Clicked){
MP.escape(g,g2);
}
else if(rect25Clicked){
repaint();
}
else if(rect14Clicked){
}
else if(rect16Clicked){
}
else if(rect18Clicked){
}
else if(rect21Clicked){
MP.traction_braking(g,g2);
MP.escape(g,g2);
}
else if(rect22Clicked){
MP.tempetature(g,g2);
MP.escape(g,g2);
}
else if(rect23Clicked){
MP.oil_pressure(g,g2);
MP.escape(g,g2);
}
else if(rect24Clicked){
MP.config_switches(g,g2);
MP.escape(g,g2);
}
}
}
/* constants */
import java.awt.Color; import java.awt.image.BufferedImage; import java.io.FileInputStream; import java.awt.* ; import java.awt.event.* ; import javax.swing.* ; import java.io.; import java.awt.image.;
public class Constants extends JFrame{
final double adjx = 1; //
final double adjy = 1; //
final double xpix = 640*adjx; // To Set the Frame X Resolution
final double ypix = 480*adjy; // To Set the Frame Y Resolution
int locodatax=280;
int locodatay=29;
int locodata_w=25;
int locodata_h=30;
final int CENTER_PIX_X = 320; // 640 800
final int CENTER_PIX_Y = 240-26; // 480 600 -26 to shift meter up
final int METER_X=470; // METER X COORDINATE
final int METER_Y=195;// METER Y COORDINATE
final int RECT_W = 300; // 310,to make equal partition
final int RECT_H = 195;
final int DEFAULT_SCREEN_X=5;
final int DEFAULT_SCREEN_Y=62;
final int DEFAULT_SCREEN_W=211;// 317 width
final int DEFAULT_SCREEN_H=307;
// variable that will be true when the user clicked i the rectangle
// the we will draw.
/*----Display Resolution-----------*/
int popwidth = 400;
int pophight = 100;
final int CENTER_OVEL_W = 25;//30
final int CENTER_OVEL_H = 25;//30
final int RADIOUS = 120; //260
final int rad = ((RADIOUS-(RADIOUS/3))/2); // 90
double half = RADIOUS/2;
double base =(Math.sqrt((2*(half*half))));
int getWidth = 640; // border width
int getHeight = 480; // border height
/* Driver Details*/
int dix = 5;//15 ;driver x coordinate
int diy = 8;//40 ; driver y coordinate
int diwidth = 627; //400 525 ; driver width
int dihight = 20; // driver height
/*locono Date and Time Details*/
final int loconox = 210; // locono table x coordinate
final int loconoy = 68; // locono table y coordinate
final int locono_w = 225; // locono table width
final int locono_h = 20; // locono table height
/* Sub system Details*/
final int subx = 8; // ;subsystem x coordinate
final int suby =69; // ;subsystem y coordinate
final int sub_w = 32; // ;subsystem width
final int sub_h = 25; // ;subsystem height
/* screens details*/
final int screens_border [] = { 219,61,412,309 };
final int screens_display [] = { 226,130,195,25 };
/* Mouse Actions*/
int mainpowerx = 224;//219+27;//260
int mainpowery=130;
int mainpowerw=195;
int mainpowerh = 25;
int xpos=-10; int ypos=-10;
int scr=0;
int scr1=0;
boolean mouseEntered;
boolean rect1Clicked;
boolean rect2Clicked;
boolean rect3Clicked;
boolean rect4Clicked;
boolean rect5Clicked;
boolean rect6Clicked;
boolean rect7Clicked;
boolean rect8Clicked;
boolean rect9Clicked;
boolean rect10Clicked;
boolean rect11Clicked;
boolean rect12Clicked;
boolean rect13Clicked;
boolean rect14Clicked;
boolean rect15Clicked;
boolean rect16Clicked;
boolean rect17Clicked;
boolean rect18Clicked;
boolean rect19Clicked;
boolean rect20Clicked;
boolean rect21Clicked;
boolean rect22Clicked;
boolean rect23Clicked;
boolean rect24Clicked;
boolean rect25Clicked;
int scrn=0;
int rect1xco = (int )((mainpowerx)*adjx);
int rect1yco = (int )((mainpowery)*adjy);
int rect1width = (int )((mainpowerw)*adjx);
int rect1height =(int )((mainpowerh)*adjy);
int rect3xco =(int )((mainpowerx)*adjx);
int rect3yco = (int )((mainpowery+27)*adjy);
int rect3width = (int )((mainpowerw)*adjx);
int rect3height =(int )((mainpowerh)*adjy);
int rect5xco = (int )((mainpowerx)*adjx);
int rect5yco =(int )((mainpowery+54)*adjy);
int rect5width = (int )((mainpowerw)*adjx);
int rect5height = (int )((mainpowerh)*adjy);
int rect7xco = (int )((mainpowerx)*adjx);
int rect7yco = (int )((mainpowery+81)*adjy);
int rect7width =(int )((mainpowerw)*adjx);
int rect7height = (int )((mainpowerh)*adjy); //mainpowerx;
int rect9xco = (int )((mainpowerx)*adjx); //mainpowery+108;
int rect9yco =(int )((mainpowery+108)*adjy);
int rect9width =(int )((mainpowerw)*adjx); //mainpowerw;
int rect9height = (int )((mainpowerh)*adjy);
int rect11xco = (int )((mainpowerx)*adjx);
int rect11yco = (int )((mainpowery+135)*adjy);
int rect11width = (int )((mainpowerw)*adjx);
int rect11height = (int )((mainpowerh)*adjy);
int rect13xco = (int )((mainpowerx)*adjx);
int rect13yco = (int )((mainpowery+162)*adjy);
int rect13width = (int )((mainpowerw)*adjx);
int rect13height = (int )((mainpowerh)*adjy);
int rect15xco = (int )((mainpowerx+205)*adjx);
int rect15yco = (int )((mainpowery)*adjy);
int rect15width = (int )((mainpowerw)*adjx);
int rect15height =(int )((mainpowerh)*adjy);
int rect17xco = (int )((mainpowerx+205)*adjx);
int rect17yco = (int )((mainpowery+108)*adjy);
int rect17width =(int )((mainpowerw)*adjx);
int rect17height = (int )((mainpowerh)*adjy);
int rect18xco = (int )((mainpowerx+205)*adjx);
int rect18yco = (int )((mainpowery+162)*adjy);
int rect18width =(int )((mainpowerw)*adjx);
int rect18height = (int )((mainpowerh)*adjy);
int rect19xco = (int )((mainpowerx+205)*adjx);
int rect19yco = (int )((mainpowery+135)*adjy);
int rect19width = (int )((mainpowerw)*adjx);
int rect19height =(int )((mainpowerh)*adjy);
int rect20xco = (int )((subx+38)*adjx);
int rect20yco = (int )((suby+270)*adjy);//suby+270;
int rect20width =(int )((sub_w)*adjx);
int rect20height = (int )((sub_h)*adjy);
int rect21xco = (int )((mainpowerx)*adjx);
int rect21yco = (int )((mainpowery+162)*adjy);
int rect21width = (int )((mainpowerw)*adjx);
int rect21height = (int )((mainpowerh)*adjy);
int rect22xco = (int )((mainpowerx+205)*adjx);
int rect22yco = (int )((mainpowery+27)*adjy);
int rect22width = (int )((mainpowerw)*adjx);
int rect22height =(int )((mainpowerh)*adjy);
int rect23xco = (int )((mainpowerx+205)*adjx);
int rect23yco =(int )((mainpowery+54)*adjy);
int rect23width = (int )((mainpowerw)*adjx);
int rect23height = (int )((mainpowerh)*adjy);
int rect24xco = (int )((mainpowerx+205)*adjx);
int rect24yco = (int )((mainpowery+81)*adjy);
int rect24width =(int )((mainpowerw)*adjx);
int rect24height = (int )((mainpowerh)*adjy);
int rect2xco = (int )((575)*adjx); //575;
int rect2yco = (int )((65)*adjy);//65;
int rect2width = (int )((50)*adjx); //50;
int rect2height = (int )((20)*adjy);//20;
int rect25xco = (int )((575)*adjx); //575;
int rect25yco = (int )((65)*adjy);//65;
int rect25width = (int )((50)*adjx); //50;
int rect25height = (int )((20)*adjy);//20;
Color dackground = new Color(0,0,0);
Color block = new Color(163,225,255,155); // for Blue Gray Color
Color Green = new Color(102,255,153,255); // for Green Color
Color Red = new Color(200,51,51,200); // for Red Color
Color Yellow = new Color(255,255,51);
Color Gray = new Color(161,161,161,205); // for Gray Color
Color pantoback = new Color(61,61,61); // for Panto Background Gray Color
Color line = new Color(224,224,224,55); // for Panto Line
Color subcolor = new Color(31,31,31); // for Subsysrem background Color
Color voltcurrentbackground = new Color(31,31,31,255); // for voltage & Current Background
Color lightpink = new Color(253,204,255,50);
/*-------Main Screen all Squre Border ---------------*/
final int meter_border [] = { 391, 61 , 240, 201 }; // Meter Border X , Y ,W ,H
final int static_field_border [] = { 220, 61, 168, 309 }; // Static Field Boarder X, Y, W ,H
final int battery_border [] = { 391, 266, 78, 104 }; // Battery Boarder X , Y ,W ,H
final int auto_brake_pressure_border [] = { 472, 266, 78, 104 }; // Auto Brake Pressure X , Y ,W ,H
final int line_frequency_border [] = { 553, 266, 78, 104 }; // Line Frequency Boarder X , Y ,W ,H
final int default_screen [] = { 5, 61, 212, 309 }; // Default_screen X , Y ,W ,H
final int lcd_Boarder [] = { 331, 373, 300, 100}; // LCD Boarder
final int screen_button []={42,336,37,29}; // screen button X,Y,W,H
/* ---------Driver Details------------------------*/
final int driver_info [] = { 10, 18, 627, 18 }; // Driver INFO X1 ,Y1, X2, Y2
final int stno = 3; // Station number Display on screen
int st = 0;
final int diff = ((int)(585*adjx))/(stno-1); // Each Station Diference
int stdiff = 0;
final int trpos = 4; // Position of the Train
int trdiff = 0;
/*---------loconodatetime, Panto UpDown, VCB, Brake Applied------------*/
// final String LOCO_NO = "E:\Pratibha\eprog\workspace\Driver Display1.2\src\loco no.txt"; FileInputStream fin; String locono ="XXXXX "; String LOCO; public static String dt; public static final String DATE_FORMAT_NOW = "dd-MM-yyyy HH:mm:ss";
final int loconodatetime [] = { 5, 29, 627, 30 }; // loconodatetime X Y W H
final int locodata [] ={ 280, 29, 25, 30 }; // For Panto VCB Brake MR Pressure
int pantoupdown = 1; // Run Time Variable
int vbconoff = 1; // Run Time Variable
int brakeapp = 1;
/* ----------------Sub system Details------------------*/
final int subw = 32;
final int subh = 25;
final int subsystem[][] = { { 8, 68, subw, subh },/*for SS01*/ { 44, 68, subw, subh },/* for SS02*/
{ 8, 98, subw, subh },/*for SS03*/ { 44, 98, subw, subh },/* for SS04*/
{ 8, 128, subw, subh },/*for SS05*/ { 44, 128, subw, subh },/* for SS06*/
{ 8, 158, subw, subh },/*for SS07*/ { 44, 158, subw, subh },/* for SS08*/
{ 8, 188, subw, subh },/*for SS09*/ { 44, 188, subw, subh },/* for SS10*/
{ 8, 218, subw, subh },/*for SS11*/ { 44, 218, subw, subh },/* for SS12*/
{ 8, 248, subw, subh },/*for SS13*/ { 44, 248, subw, subh },/* for SS14*/
{ 8, 278, subw, subh },/*for SS15*/ { 44, 278, subw, subh },/* for SS16*/
{ 8, 308, subw, subh },/*for SS17*/ { 44, 308, subw, subh },/* for SS18*/
{ 8, 338, subw, subh },/*for SS19*/ { 44, 338, subw, subh },/* for SS20*/
}; // 1 - 19 subsystem X Y W H
String subsystem_string [] = {"SS01","SS02","SS03","SS04","SS05","SS06","SS07","SS08","SS09","SS10",
"SS11","SS12","SS13","SS14","SS15","SS16","SS17","SS18","SS19"," "
};
int [] substatus = new int [20]; // subsystem Run Time Variable
int subsysystatus = 1; // Run Time Variable
/*--------------------------Voltage and Current bar Details------------------------*/
//----------------SCREEN DETAILS--------------------------
// final int screens_border [] = { 219, 61, 412, 309 }; // Screen Border X Y W H // final int screens_display [] = { 226, 130, 195, 25 }; // Screen Inner Blocks X Y W H final int screens_row [] = {97,124,151,178,205,232,259,286,313,340};// Inner Blocks Y Coordinates final int mainpowercol [] = {5,206}; // Col 1 and 2 X Coordinates String str ; int len = 0;
/*----------------traction_braking---------------------*/
String traction_braking_header [] = {"TRACTION & BRAKING"};
String traction_braking_string [] = {"Active CAB","MSC Node","Throttle Zero","Constant Speed Mode","Pressure Auto Brake Line","TE/BE","Bogie 1","Bogie 2","Loco","Demand","Actual"};
String traction_braking_onoff [] = {"ON","OFF"};
String cab[] = {"1","2"}; // Active Cab 1 or 2
int [] traction_braking_int = new int [1]; // Run Time Variable MSC Node
double [] traction_braking_float = new double[15]; // Run Time Variable
int cab1or2 = 1; // Run Time Variable
int throttle_zero = 0; // Run Time Variable
int con_speed_mode = 1; // Run Time Variable
/*---------------------Temperatures------------------------*/
String tempetature_header [] = {"TEMPERATURES"};
String tempetature_string [] = {"I/P Power","Traction Converter","Transformer","SR1","SR2","TFP1","TFP2","Traction Motors","TM1","TM2","TM3","TM4","TM5","TM6"};
double [] tempetature_float = new double[15]; // Run Time Variable
/*---------------------Oil Pressure------------------------*/
String oil_pressure_header [] = {"OIL PRESSURE"};
// String oil_pressure_string [] = {"I/P Power","Traction Converter","Transformer","SR1","SR2","TFP1","TFP2"}; double [] oil_pressure_float = new double [10]; // Run Time Variable
/*---------------------config_switches------------------------*/
String configswitches_header [] = {"CONFIG SWITCHES"};
String configswitches_string [] = {"TE Limit"," Banking","Fail Mode","BG1 Out","BG2 Out","Fail Mode","Simulation","Configuration"};
int telimit=1; // Run Time Variable
int banking=0; // Run Time Variable
int failmode=1; // Run Time Variable
int bg1out=0; // Run Time Variable
int bg2out=1; // Run Time Variable
int simulation=0; // Run Time Variable
int configuration=1; // Run Time Variable
/*--------------------wheel_diameter-----------------------*/
String wheeldiameter_header[] = {"WHEEL DIAMETERS"};
String wheeldiameter_string[] = {"1","2","3","4","5","6","7","8","9","10","11","12", };
double [] wheeldiameter_float = new double [12];
/*---------------- kmearned_enery---------------------------*/
String kmenergy_header[] = {"KM EARNED AND ENERGY"};
String kmenergy_string [] = {"Km Earned","GWh","MWh","kWh","Energy Consumed","Energy Regenerated","% of Regenerated"};
double [] kmenergy_float = new double [15]; // Run Time Variable
String [] kmenergy_unit = new String [5]; // Run Time Variable
/*------------------software version------------------------*/
String s_v_header[] = { "Software Version" };
String s_v_string[] = {"LOCO TYPE","FLG 1","FLG 2","HBB 1","HBB 2","STB 1","STB 2","SLG 1","SLG 2"}; // for LOCO TYPE
String [] s_v_unit = new String [15];
double [] s_v_float = new double [10]; // Run Time Variable
}
/mouse act/ import java.awt.* ; import java.awt.event.* ;
import javax.swing.* ; import java.io.; import java.awt.image.; import java.util.; import java.lang.Thread.;
public class Mouseact extends Constants {
public Mouseact() {
// System.out.println("mouse event starts");
// TODO Auto-generated constructor stub
addMouseListener( new MouseAdapter() {
public void mouseClicked (MouseEvent me) {
System.out.println("mouse event starts");
//Graphics2D g2=(Graphics2D)g;
// Save the coordinates of the click lke this.
xpos = me.getX();
ypos = me.getY();
System.out.println("mouse event starts");
for (int j=0;j<10;j++){
System.out.println("mouse event starts");
}
// Check if the click was inside the rectangle area.
if(xpos > rect20xco && xpos < rect20xco+rect20width && ypos >rect20yco && ypos < rect20yco+rect20height)
{
rect20Clicked = true;
System.out.println("rect20="+rect20Clicked);
scrn++;
scrn=1;
repaint();
//int scr=1;
//return true;
}
else
{
rect20Clicked = false;
repaint();
// return false;
}
// }
// } // public void mouseClicked1 (MouseEvent me) { if (xpos > rect1xco && xpos < rect1xco+rect1width && ypos >rect1yco && ypos < rect1yco+rect1height)
{ rect1Clicked = true;
repaint();
}
else
rect1Clicked = false;
repaint();
// if it was not then rect1Clicked is false;
if(xpos > rect3xco && xpos < rect3xco+rect3width && ypos >rect3yco && ypos < rect3yco+rect3height)
rect3Clicked = true;
else
rect3Clicked = false;
repaint();
//show the results of the click
if(xpos > rect25xco && xpos < rect25xco+rect3width && ypos >rect25yco && ypos < rect25yco+rect25height)
rect25Clicked = true;
else
rect25Clicked = false;
repaint();
if(xpos > rect5xco && xpos < rect5xco+rect3width && ypos >rect5yco && ypos < rect5yco+rect5height)
rect5Clicked = true;
else
rect5Clicked = false;
repaint();
if(xpos > rect7xco && xpos < rect7xco+rect7width && ypos >rect7yco && ypos < rect7yco+rect7height)
rect7Clicked = true;
else
rect7Clicked = false;
repaint();
if(xpos > rect9xco && xpos < rect9xco+rect9width && ypos >rect9yco && ypos < rect9yco+rect9height)
rect9Clicked = true;
else
rect9Clicked = false;
repaint();
if(xpos > rect11xco && xpos < rect11xco+rect11width && ypos >rect11yco && ypos < rect11yco+rect11height)
rect11Clicked = true;
else
rect11Clicked = false;
repaint();
if(xpos > rect18xco && xpos < rect18xco+rect18width && ypos >rect18yco && ypos < rect18yco+rect18height)
rect18Clicked = true;
else
rect18Clicked = false;
repaint();
//show the results of the click
if(xpos > rect15xco && xpos < rect15xco+rect15width && ypos >rect15yco && ypos < rect15yco+rect15height)
rect15Clicked = true;
else
rect15Clicked = false;
repaint();
if(xpos > rect17xco && xpos < rect17xco+rect17width && ypos >rect17yco && ypos < rect17yco+rect17height)
rect17Clicked = true;
else
rect17Clicked = false;
repaint();
if(xpos > rect19xco && xpos < rect19xco+rect19width && ypos >rect19yco && ypos < rect19yco+rect19height)
rect19Clicked = true;
else
rect19Clicked = false;
repaint();
if(xpos > rect21xco && xpos < rect21xco+rect21width && ypos >rect21yco && ypos < rect21yco+rect21height)
rect21Clicked = true;
else
rect21Clicked = false;
repaint();
if(xpos > rect22xco && xpos < rect22xco+rect22width && ypos >rect22yco && ypos < rect22yco+rect22height)
rect22Clicked = true;
else
rect22Clicked = false;
repaint();
if(xpos > rect23xco && xpos < rect23xco+rect23width && ypos >rect23yco && ypos < rect23yco+rect23height)
rect23Clicked = true;
else
rect23Clicked = false;
repaint();
if(xpos > rect24xco && xpos < rect24xco+rect24width && ypos >rect24yco && ypos < rect24yco+rect24height)
rect24Clicked = true;
else
rect24Clicked = false;
repaint();
if(xpos > rect2xco && xpos < rect2xco+rect2width && ypos >rect2yco && ypos < rect2yco+rect2height)
rect2Clicked = true;
else
rect2Clicked = false;
repaint();
}
public void mousePressed (MouseEvent me) {}
// When it has been released
// not that a click also calls these Mouse-Pressed and Released.
// since they are empty nothing hapens here.
public void mouseReleased (MouseEvent me) {}
// This is executed when the mouse enters the applet. it will only
// be executed again when the mouse has left and then re-entered.
public void mouseEntered (MouseEvent me) {
// Will draw the "inside applet message"
mouseEntered = true;
repaint();
}
// When the Mouse leaves the applet.
public void mouseExited (MouseEvent me) {
// will draw the "outside applet message
mouseEntered = false;
repaint();
}
}
);
}
/*public void paint1(){
show();
}*/
public void paint(Graphics g) {
//super(paint);
Graphics2D g2=(Graphics2D)g;
g.setColor(Color.white);
g.drawRect(230,75,40,40);
mainpower MP= new mainpower();
if(rect20Clicked){
// int scr1=1;
MP.screens(g,g2);
MP.s开发者_如何学编程creenescape(g,g2);
//rect20Clicked=true ;
}
if(rect1Clicked ){
System.out.println(scrn);
MP.powercircuit(g,g2);
MP.escape(g,g2);
}
//}
else if(rect5Clicked){
MP.TractionMotor(g,g2);
MP.escape(g,g2);
}
else if(rect3Clicked){
MP.AuxiliaryConverter(g,g2);
MP.escape(g,g2);
}
else if(rect7Clicked){
MP.HarmonicHotel(g,g2);
MP.escape(g,g2);
}
else if(rect9Clicked){
MP.AuxiliaryMachines(g,g2);
MP.escape(g,g2);
}
else if(rect11Clicked){
MP.SubSystemIsolation(g,g2);
MP.escape(g,g2);
}
else if(rect18Clicked){
System.out.println ("LOCO ="+LOCO);
MP.software_version(g,g2,locono);
MP.escape(g,g2);
}
else if(rect15Clicked){
MP.BrakeSystem(g,g2);
MP.escape(g,g2);
}
else if(rect17Clicked){
MP.wheel_diameter(g,g2);
MP.escape(g,g2);
}
else if(rect19Clicked){
MP.kmearned_enery(g,g2);
MP.escape(g,g2);
}
else if(rect2Clicked){
MP.screens(g,g2);
MP.screenescape(g,g2);
}
else if(rect4Clicked){
MP.escape(g,g2);
}
else if(rect6Clicked){
MP.AuxiliaryMachines (g,g2);
MP.escape(g,g2);
}
else if(rect8Clicked){
MP.HarmonicHotel(g,g2);
MP.escape(g,g2);
}
else if(rect10Clicked){
MP.escape(g,g2);
}
else if(rect25Clicked){
repaint();
}
else if(rect14Clicked){
}
else if(rect16Clicked){
}
else if(rect18Clicked){
}
else if(rect21Clicked){
MP.traction_braking(g,g2);
MP.escape(g,g2);
}
else if(rect22Clicked){
MP.tempetature(g,g2);
MP.escape(g,g2);
}
else if(rect23Clicked){
MP.oil_pressure(g,g2);
MP.escape(g,g2);
}
else if(rect24Clicked){
MP.config_switches(g,g2);
MP.escape(g,g2);
}
}
}
Swing is developed so that, in general, only one thread sparks events and updates the UI. There are exceptions though. I don't completely get what your asking, bur here is documentation on adding a mouse listener, and here is documentation on threading in Swing.
On mouse click, you can spawn off a thread if you need to. Be careful though, threading can get heavy, and complex fast.
精彩评论