DBInstallerGUI.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.tools.dbinstaller.gui;
  16. import java.awt.BorderLayout;
  17. import java.awt.Dimension;
  18. import java.awt.Toolkit;
  19. import java.sql.Connection;
  20. import javax.swing.JFrame;
  21. import javax.swing.JOptionPane;
  22. import javax.swing.JProgressBar;
  23. import javax.swing.JScrollPane;
  24. import javax.swing.JTextArea;
  25. import com.l2jserver.tools.dbinstaller.DBOutputInterface;
  26. import com.l2jserver.tools.images.ImagesTable;
  27. /**
  28. * @author mrTJO
  29. */
  30. public class DBInstallerGUI extends JFrame implements DBOutputInterface
  31. {
  32. private static final long serialVersionUID = -1005504757826370170L;
  33. private JProgressBar _progBar;
  34. private JTextArea _progArea;
  35. private Connection _con;
  36. public DBInstallerGUI(Connection con)
  37. {
  38. super("L2J Database Installer");
  39. setLayout(new BorderLayout());
  40. setDefaultLookAndFeelDecorated(true);
  41. setIconImage(ImagesTable.getImage("l2j.png").getImage());
  42. _con = con;
  43. int width = 480;
  44. int height = 360;
  45. Dimension resolution = Toolkit.getDefaultToolkit().getScreenSize();
  46. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  47. setBounds((resolution.width - width) / 2, (resolution.height - height) / 2, width, height);
  48. setResizable(false);
  49. _progBar = new JProgressBar();
  50. _progBar.setIndeterminate(true);
  51. add(_progBar, BorderLayout.PAGE_START);
  52. _progArea = new JTextArea();
  53. JScrollPane scrollPane = new JScrollPane(_progArea);
  54. _progArea.setEditable(false);
  55. appendToProgressArea("Connected");
  56. add(scrollPane, BorderLayout.CENTER);
  57. }
  58. @Override
  59. public void setProgressIndeterminate(boolean value)
  60. {
  61. _progBar.setIndeterminate(value);
  62. }
  63. @Override
  64. public void setProgressMaximum(int maxValue)
  65. {
  66. _progBar.setMaximum(maxValue);
  67. }
  68. @Override
  69. public void setProgressValue(int value)
  70. {
  71. _progBar.setValue(value);
  72. }
  73. @Override
  74. public void appendToProgressArea(String text)
  75. {
  76. _progArea.append(text + "\n");
  77. _progArea.setCaretPosition(_progArea.getDocument().getLength());
  78. }
  79. @Override
  80. public Connection getConnection()
  81. {
  82. return _con;
  83. }
  84. @Override
  85. public void setFrameVisible(boolean value)
  86. {
  87. setVisible(value);
  88. }
  89. @Override
  90. public int requestConfirm(String title, String message, int type)
  91. {
  92. return JOptionPane.showConfirmDialog(null, message, title, type);
  93. }
  94. @Override
  95. public void showMessage(String title, String message, int type)
  96. {
  97. JOptionPane.showMessageDialog(null, message, title, type);
  98. }
  99. }