DBInstallerGUI.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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.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.dbinstaller.DBOutputInterface;
  26. import com.l2jserver.images.ImagesTable;
  27. /**
  28. *
  29. * @author mrTJO
  30. */
  31. public class DBInstallerGUI extends JFrame implements DBOutputInterface
  32. {
  33. private static final long serialVersionUID = -1005504757826370170L;
  34. private JProgressBar _progBar;
  35. private JTextArea _progArea;
  36. private Connection _con;
  37. public DBInstallerGUI(Connection con)
  38. {
  39. super("L2J Database Installer");
  40. setLayout(new BorderLayout());
  41. setDefaultLookAndFeelDecorated(true);
  42. setIconImage(ImagesTable.getImage("l2j.png").getImage());
  43. _con = con;
  44. int width = 480;
  45. int height = 360;
  46. Dimension resolution = Toolkit.getDefaultToolkit().getScreenSize();
  47. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  48. setBounds((resolution.width-width)/2, (resolution.height-height)/2, width, height);
  49. setResizable(false);
  50. _progBar = new JProgressBar();
  51. _progBar.setIndeterminate(true);
  52. add(_progBar, BorderLayout.PAGE_START);
  53. _progArea = new JTextArea();
  54. JScrollPane scrollPane = new JScrollPane(_progArea);
  55. _progArea.setEditable(false);
  56. appendToProgressArea("Connected");
  57. add(scrollPane, BorderLayout.CENTER);
  58. }
  59. public void setProgressIndeterminate(boolean value)
  60. {
  61. _progBar.setIndeterminate(value);
  62. }
  63. public void setProgressMaximum(int maxValue)
  64. {
  65. _progBar.setMaximum(maxValue);
  66. }
  67. public void setProgressValue(int value)
  68. {
  69. _progBar.setValue(value);
  70. }
  71. public void appendToProgressArea(String text)
  72. {
  73. _progArea.append(text+"\n");
  74. _progArea.setCaretPosition(_progArea.getDocument().getLength());
  75. }
  76. public Connection getConnection()
  77. {
  78. return _con;
  79. }
  80. @Override
  81. public void setFrameVisible(boolean value)
  82. {
  83. setVisible(value);
  84. }
  85. @Override
  86. public int requestConfirm(String title, String message, int type)
  87. {
  88. return JOptionPane.showConfirmDialog(null, message, title, type);
  89. }
  90. @Override
  91. public void showMessage(String title, String message, int type) {
  92. JOptionPane.showMessageDialog(null, message, title, type);
  93. }
  94. }