|
|
|
Нужна помощь с простым
|
|||
|---|---|---|---|
|
#18+
Мне нужна это программа для изучения языка как пример . Не прикручиваеться к кнопке запуск класса . Не получаеться вывести часы в одном окне з кнопками . Главный класс. package test; import java.awt.BorderLayout; import java.awt.Container; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.util.Date; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JRootPane; import javax.swing.Timer; public class Test extends JFrame{ public static void main(String args[]) { JFrame frame = new JFrame("SwingDefaultButton"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ClockLabel clock = new ClockLabel(); getContentPane().add(clock, BorderLayout.NORTH); Man ourMan= new Man(); ourMan.Menit(); Test ct = new Test(); ct.setVisible(true); Container content = frame.getContentPane(); content.setLayout(new GridLayout(2, 2)); JButton button1 = new JButton("Ip"); button1.setMnemonic(KeyEvent.VK_B); content.add(button1); Icon warnIcon = new ImageIcon("Warn.gif"); JButton button2 = new JButton(warnIcon); content.add(button2); JButton button3 = new JButton("Warning", warnIcon); content.add(button3); String htmlButton = "<html><sup>HTML</sup> <sub><em>Button</em></sub><br>" + "<font color=\"#FF0080\"><u>Multi-line</u></font>"; JButton button4 = new JButton(htmlButton); content.add(button4); JRootPane rootPane = frame.getRootPane(); rootPane.setDefaultButton(button2); frame.setSize(300, 200); frame.setVisible(true); // ClockLabel clock = new ClockLabel(); // getContentPane().add(clock, BorderLayout.NORTH); } //public static void main(String args[]) { //ClockTest ct = new ClockTest(); //ct.setVisible(true); } //} class ClockLabel extends JLabel implements ActionListener { public ClockLabel() { super("" + new Date()); Timer t = new Timer(1000, this); t.start(); } public void actionPerformed(ActionEvent ae) { setText((new Date()).toString()); } } Вторичный import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.net.*; public class Man { public static void main(String [] args) { public void Menit(){ JFrame frame = new JFrame("Current IP"); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); String IP = ""; try { IP = InetAddress.getLocalHost().getHostAddress(); } catch (Exception e) { IP = "Error finding IP"; } JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createTitledBorder(" Current IP Address")); panel.add(new JLabel(" " + IP + " ")); frame.getContentPane().add(panel); frame.pack(); frame.setVisible(true); } } ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 23.05.2015, 02:21 |
|
||
|
Нужна помощь с простым
|
|||
|---|---|---|---|
|
#18+
Код: java 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. Вторичный Код: java 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 23.05.2015, 10:22 |
|
||
|
|

start [/forum/topic.php?fid=59&msg=38966956&tid=2125378]: |
0ms |
get settings: |
10ms |
get forum list: |
20ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
168ms |
get topic data: |
8ms |
get forum data: |
2ms |
get page messages: |
34ms |
get tp. blocked users: |
1ms |
| others: | 250ms |
| total: | 501ms |

| 0 / 0 |
