📄 namazurdu.java
字号:
if(cit.equalsIgnoreCase("Sargodha")) city=sar1; if(cit.equalsIgnoreCase("Quetta")) city=qut1; if(cit.equalsIgnoreCase("Wah"))city=wah1; citylable.setText(city);} public void actionPerformed(ActionEvent e) { JButton button=(JButton)e.getSource(); Dialog2 d=new Dialog2(frame,"city"); if(button.equals(butcity)) { d.setVisible(true); repaint(); } if(button.equals(butdef)) { String cit=" ",lon="",lat=""; try{ int space=c.indexOf(","); cit=c.substring(0,space); lon=c.substring(space+1,c.lastIndexOf(",")); lat=c.substring(c.lastIndexOf(",")+1,c.length()); }catch(StringIndexOutOfBoundsException ex) { } city=cit; try{ longitude=Double.parseDouble(lon); latitude=Double.parseDouble(lat); } catch(NumberFormatException ex) { } convertcity2urdu(); repaint(); citylable.setText(city); } } public class Dialog2 extends Dialog implements ListSelectionListener { //namaz n = new namaz(); JLabel jLabelcity= new JLabel(); JLabel jLabellong= new JLabel(); JLabel jLabellat = new JLabel(); JLabel jLabeltit1 = new JLabel(); JLabel jLabeltit2= new JLabel(); JTextField txtcity,txtlong1,txtlat1,txtlong2,txtlat2; public Dialog2(Frame frame1,String title) { super(frame1,title,false); //frame1.setlayout(null); setBounds(200,250,400, 300); String[] cityn = { abta1,bah1,ban1,cak1,dik1,fas1,gil1,hyd1,isb1,jlm1,kar1,lah1,mul1 ,mai1,mal1,peh1,pdk1,sar1,rwp1,qut1,wah1 }; setBackground(new java.awt.Color (180,180, 150));//combomon.addItem(String.valueOf(monthc[month-1]));setLayout(null); list = new JList(cityn); list.setFont(new java.awt.Font ("Urdu Naskh Unicode",1,18)); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedValue(city,true); list. setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); list.addListSelectionListener(this); JScrollPane listScrollPane = new JScrollPane(list); list.setBackground(new java.awt.Color (0,40,20)); list.setForeground(new java.awt.Color (240,240,200)); listScrollPane.setBounds(20,60,350,220); //valueChanged(getSelectionModel(this));add(listScrollPane); //panel1.setLayout(borderLayout1); // getContentPane().add(panel1); String city1=(String)list.getSelectedValue(); ButtonHandler handler = new ButtonHandler(); jLabeltit1.setFont(new java.awt.Font ("Urdu Naskh Unicode",1,18)); jLabeltit1.setText(sel1); jLabeltit1.setForeground( new java.awt.Color (100,20, 80)); jLabeltit1.setBounds(130, 30, 150, 40); add(jLabeltit1); /* jLabeltit2.setText("Edit City / Town"); jLabeltit2.setForeground( new java.awt.Color (100,20, 80)); jLabeltit2.setBounds(240, 50, 100, 40); add(jLabeltit2); jLabelcity.setText("CITY"); jLabelcity.setForeground(java.awt.Color.black); jLabelcity.setBounds(120, 80, 100, 40); add(jLabelcity); txtcity= new JTextField(50); txtcity. setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); txtcity.setBounds(240, 90,130, 25); add(txtcity); jLabellong.setText("LONGITUDE"); jLabellong.setForeground(java.awt.Color.black); jLabellong.setBounds(160, 120, 100, 40); add(jLabellong); txtlong1= new JTextField(50); txtlong1.setBounds(280, 130,40, 25); txtlong1. setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); add(txtlong1); txtlong2= new JTextField(50); txtlong2. setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); txtlong2.setBounds(330, 130,40, 25); add(txtlong2); jLabellat.setText("LATITUDE"); jLabellat.setForeground(java.awt.Color.black); jLabellat.setBounds(150, 160, 100, 40); add(jLabellat); txtlat1= new JTextField(50); txtlat1. setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); txtlat1.setBounds(280, 170,40, 25); add(txtlat1); txtlat2= new JTextField(50); txtlat2. setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); txtlat2.setBounds(330, 170,40, 25); add(txtlat2); butok.setFont(new java.awt.Font ("Arial Black",0,15)); butok.setBounds(180,250,80, 30);butok.setForeground(new java.awt.Color (0,0,0));butok.setBackground(new java.awt.Color (240,240,200));butok.addActionListener( handler ); butcnl.setFont(new java.awt.Font ("Arial Black",0,15)); butcnl.setBounds(270,250,100,30);butcnl.setForeground(new java.awt.Color (0,0,0));butcnl.setBackground(new java.awt.Color (240,240,200));butcnl.addActionListener(handler ); add(butok); add(butcnl); */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { dispose(); } }); } public void valueChanged(ListSelectionEvent e) { String city1=(String)list.getSelectedValue(); /// "Islamabad","Dahkah","Newyork","Canberra" if(city==isb1) { longitude=73.66; latitude=33.61; } if(city==lah1) { longitude=74.32; latitude= 31.56; } if(city==kar1) { longitude=67.01; latitude=24.87; } if(city==abta1) { longitude=73.2; latitude=34.13; } if(city==bah1) { longitude=71.67; latitude=29.38; } if(city==ban1) { longitude=70.58; latitude=33.02; } if(city==cak1) { longitude=72.85; latitude=32.95; } if(city==dik1) { longitude=70.88; latitude=31.83; } if(city==gil1) { longitude=74.28; latitude=35.9; } if(city==fas1) { longitude=73.1; latitude= 31.42; } if(city==hyd1) { longitude=68.35; latitude=25.38; } if(city==isb1) { longitude=73.08; latitude=33.72; } if(city==jlm1) { longitude=73.73; latitude=32.93; } if(city==mul1) { longitude=71.47; latitude= 30.02; } if(city==mai1) { longitude=73.06; latitude=32.53; } if(city==mal1) { longitude=73.22; latitude=32.55; } if(city==rwp1) { longitude=73.05; latitude=32.06; } if(city==peh1) { longitude=71.53; latitude=34.02; } if(city==sar1) { longitude=72.66; latitude= 32.08; } if(city==qut1) { longitude=67.0; latitude= 30.25; } if(city==wah1) { longitude=72.72; latitude= 33.08; } city=city1; citylable.setText(city1); dispose(); } public class ButtonHandler implements ActionListener { public void actionPerformed( ActionEvent e ) { // Dialog1 d=new Dialog1( frame ,"city"); if ( e.getSource() == butok ) { String log = txtlong1.getText()+"."+ txtlong2.getText(); String lat = txtlat1.getText()+"."+ txtlat2.getText(); /* int check=0; / double l=Double.parseDouble(log);double t=Double.parseDouble(lat); if(l<=60.0&l<=80.0) { JOptionPane.showMessageDialog(null,l+"For Pakistan Longitude must be greater than 70 and less than 80","Warning",JOptionPane.ERROR_MESSAGE); dispose(); check=1; } else if(t<=20.0) { JOptionPane.showMessageDialog(null,"For Pakistan Latitude must be greater than 20 and less than 40","Warning",JOptionPane.ERROR_MESSAGE); dispose(); check=1; }*/ try{ //if(check==0){ longitude=Double.parseDouble(log); latitude=Double.parseDouble(lat); city = txtcity.getText();citylable.setText(txtcity.getText()); // }}catch(NumberFormatException et){JOptionPane.showMessageDialog(null,"Plz Enter Valid Longitude and Latitude","Warning",JOptionPane.ERROR_MESSAGE); } dispose(); } else if ( e.getSource() == butcnl ) dispose(); repaint(); } }} public static void main(String[] args) { frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); frame.getContentPane().add(new namazurdu(), BorderLayout.CENTER); /* Clock pane = new Clock(); frame.getContentPane().add(pane); ClockThread clock = new ClockThread(pane);*/ frame. setSize(800,500); frame.setVisible(true); } }class ClockThread2 extends Thread{ int current = 0; public ClockThread2(namazurdu thePanel) { panel = thePanel; } /** Loop forever updating current time */ public void run() { for( ; ;) { try { /*tracker.waitForAll(); JLabel image = new JLabel(img); panel.add(image); */ Thread.sleep(1000); } catch (InterruptedException e) { } panel.repaint(); } } // The clock panel private namazurdu panel;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -