Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

TitlePanel.java 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. *
  3. * Copyright (c) 2006-2011 Chris Smith, Shane Mc Cormack, Gregory Holmes
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6. * of this software and associated documentation files (the "Software"), to deal
  7. * in the Software without restriction, including without limitation the rights
  8. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. * copies of the Software, and to permit persons to whom the Software is
  10. * furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in
  13. * all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. * SOFTWARE.
  22. */
  23. package com.dmdirc.installer.ui;
  24. import com.dmdirc.installer.Step;
  25. import com.dmdirc.installer.ui.EtchedLineBorder.BorderSide;
  26. import java.awt.BorderLayout;
  27. import java.awt.Color;
  28. import javax.swing.ImageIcon;
  29. import javax.swing.JLabel;
  30. import javax.swing.JPanel;
  31. import javax.swing.border.EtchedBorder;
  32. /**
  33. * Simple title panel for a wizard.
  34. */
  35. public class TitlePanel extends JPanel {
  36. private static final long serialVersionUID = 7173184984913948951L;
  37. private final JLabel title;
  38. private final JLabel image;
  39. /**
  40. * Instantiates a new title panel.
  41. *
  42. * @param step Initial title text
  43. */
  44. public TitlePanel(final Step step) {
  45. super(new BorderLayout());
  46. title = new JLabel();
  47. image = new JLabel();
  48. setStep(step);
  49. title.setFont(title.getFont().deriveFont((float) (title.getFont().
  50. getSize() * 1.5)));
  51. title.setForeground(Color.BLACK);
  52. add(title, BorderLayout.CENTER);
  53. add(image, BorderLayout.EAST);
  54. setBackground(Color.WHITE);
  55. setBorder(new EtchedLineBorder(EtchedBorder.RAISED, BorderSide.BOTTOM));
  56. }
  57. /**
  58. * Sets the title text.
  59. *
  60. * @param step new title text
  61. */
  62. public void setStep(final Step step) {
  63. if (step == null) {
  64. title.setText("");
  65. image.setIcon(null);
  66. return;
  67. }
  68. if ("".equals(step.getStepDescription())) {
  69. title.setText(step.getStepName());
  70. } else {
  71. title.setText(step.getStepName() + "\n" + step.getStepDescription());
  72. }
  73. if (step.getIcon() == null) {
  74. image.setIcon(null);
  75. } else {
  76. image.setIcon(new ImageIcon(step.getIcon()));
  77. }
  78. }
  79. }