/**
   * Create a new tab to the FlexiBar, with the specified title and the specified component inside
   * the tab.
   *
   * @param title the title of the tab to be added
   * @param comp the component inserted in the tab
   */
  public void add(String title, JComponent comp) {
    JButton button = new JButton(title);
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            System.out.println("click");
            setSelected((JButton) arg0.getSource());
          }
        });
    button.setMinimumSize(new Dimension(this.B_WIDTH, this.B_HEIGHT));
    button.setMaximumSize(new Dimension(this.B_WIDTH, this.B_HEIGHT));
    button.setPreferredSize(new Dimension(this.B_WIDTH, this.B_HEIGHT));
    button.setAlignmentX(LEFT_ALIGNMENT);
    comp.setMinimumSize(new Dimension(this.P_WIDTH, this.P_HEIGHT));
    comp.setMaximumSize(new Dimension(this.P_WIDTH, this.P_HEIGHT));
    // comp.setPreferredSize(new Dimension(this.P_WIDTH,this.P_HEIGHT));
    comp.setAlignmentX(LEFT_ALIGNMENT);
    if (currentSelected == -1) {
      comp.setVisible(true);
      currentSelected = 0;
    } else comp.setVisible(false);

    listComponent.add(button);
    listComponent.add(comp);

    panel.add(button);
    panel.add(comp);
  }
示例#2
0
  /**
   * Creates body of the dialog. You can redefine getDialogTitle(), getDescription(), getInputPane()
   * methods to customize this body.
   */
  protected final JPanel body() {
    final JPanel pane = new JPanel();
    pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
    final JEditorPane descPane =
        new JEditorPane(
            Tools.MIME_TYPE_TEXT_HTML,
            "<span style='font:bold italic;font-family:Dialog; font-size:"
                + Tools.getConfigData().scaled(14)
                + ";'>"
                + getDialogTitle()
                + "</span><br>"
                + "<span style='font-family:Dialog; font-size:"
                + Tools.getConfigData().scaled(12)
                + ";'>"
                + getDescription()
                + "</span>");
    descPane.setSize(300, Integer.MAX_VALUE);

    descPane.setBackground(Tools.getDefaultColor("ConfigDialog.Background"));
    descPane.setEditable(false);
    final JScrollPane descSP = new JScrollPane(descPane);
    descSP.setBorder(null);
    descSP.setAlignmentX(Component.LEFT_ALIGNMENT);
    descSP.setMinimumSize(new Dimension(0, 50));
    pane.add(descSP);
    final JComponent inputPane = getInputPane();
    if (inputPane != null) {
      inputPane.setMinimumSize(new Dimension(Short.MAX_VALUE, INPUT_PANE_HEIGHT));
      inputPane.setBackground(Tools.getDefaultColor("ConfigDialog.Background"));
      inputPane.setAlignmentX(Component.LEFT_ALIGNMENT);
      pane.add(inputPane);
    }
    pane.setBackground(Tools.getDefaultColor("ConfigDialog.Background.Light"));
    return pane;
  }
 public static JComponent constrainHeight(JComponent component) {
   int preferredWidth = component.getPreferredSize().width;
   component.setPreferredSize(new Dimension(preferredWidth, s_maxButtonHeight));
   component.setMaximumSize(new Dimension(2048, s_maxButtonHeight));
   component.setMinimumSize(new Dimension(preferredWidth, s_maxButtonHeight));
   return component;
 }
示例#4
0
 public static void sizeIt(JComponent c, int width, int height) {
   if (height < 0) {
     height = c.getPreferredSize().height;
   }
   Dimension myDimension = new Dimension(width, height);
   c.setMaximumSize(myDimension);
   c.setMinimumSize(myDimension);
   c.setPreferredSize(myDimension);
 }
 @Override
 public void setMinimumSize(final Dimension DIM) {
   int width = DIM.width < 64 ? 64 : DIM.width;
   int height = DIM.height < 32 ? 32 : DIM.height;
   super.setMinimumSize(new Dimension(width, height));
   calcInnerBounds();
   init(getInnerBounds().width, getInnerBounds().height);
   invalidate();
   repaint();
 }
示例#6
0
 public static JComponent setSize(JComponent comp, int height, int width) {
   Dimension size = comp.getMaximumSize();
   if (height != 0) {
     size.height = height;
   } else if (width != 0) {
     size.width = width;
   }
   comp.setMinimumSize(size);
   comp.setMaximumSize(size);
   comp.setPreferredSize(size);
   return comp;
 }
  /**
   * Creates a new {@code SwingTerminalImplementation}
   *
   * @param component JComponent that is the Swing terminal surface
   * @param fontConfiguration Font configuration to use
   * @param initialTerminalSize Initial size of the terminal
   * @param deviceConfiguration Device configuration
   * @param colorConfiguration Color configuration
   * @param scrollController Controller to be used when inspecting scroll status
   */
  SwingTerminalImplementation(
      JComponent component,
      SwingTerminalFontConfiguration fontConfiguration,
      TerminalSize initialTerminalSize,
      TerminalEmulatorDeviceConfiguration deviceConfiguration,
      TerminalEmulatorColorConfiguration colorConfiguration,
      TerminalScrollController scrollController) {

    super(initialTerminalSize, deviceConfiguration, colorConfiguration, scrollController);
    this.component = component;
    this.fontConfiguration = fontConfiguration;

    // Prevent us from shrinking beyond one character
    component.setMinimumSize(
        new Dimension(fontConfiguration.getFontWidth(), fontConfiguration.getFontHeight()));

    //noinspection unchecked
    component.setFocusTraversalKeys(
        KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, Collections.<AWTKeyStroke>emptySet());
    //noinspection unchecked
    component.setFocusTraversalKeys(
        KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, Collections.<AWTKeyStroke>emptySet());

    // Make sure the component is double-buffered to prevent flickering
    component.setDoubleBuffered(true);

    component.addKeyListener(new TerminalInputListener());
    component.addMouseListener(
        new TerminalMouseListener() {
          @Override
          public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);
            SwingTerminalImplementation.this.component.requestFocusInWindow();
          }
        });
    component.addHierarchyListener(
        new HierarchyListener() {
          @Override
          public void hierarchyChanged(HierarchyEvent e) {
            if (e.getChangeFlags() == HierarchyEvent.DISPLAYABILITY_CHANGED) {
              if (e.getChanged().isDisplayable()) {
                onCreated();
              } else {
                onDestroyed();
              }
            }
          }
        });
  }
示例#8
0
  /**
   * Create the GUI and show it. For thread safety, this method should be invoked from the
   * event-dispatching thread.
   */
  private static void createAndShowGUI() {
    // Create and set up the window.
    JFrame frame = new JFrame("ListDataEventDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create and set up the content pane.
    JComponent newContentPane = new ListDataEventDemo();
    newContentPane.setOpaque(true); // content panes must be opaque
    frame.setContentPane(newContentPane);

    // Don't let the content pane get too small.
    // (Works if the Java look and feel provides
    // the window decorations.)
    newContentPane.setMinimumSize(new Dimension(newContentPane.getPreferredSize().width, 100));

    // Display the window.
    frame.pack();
    frame.setVisible(true);
  }
  protected JComponent createCenterPanel() {
    myList.setCellRenderer(new CvsListCellRenderer());

    myCenterPanelLayout.setHgap(6);

    myCenterPanel.add(createActionsPanel(), BorderLayout.NORTH);
    JComponent listPanel = createListPanel();

    myCenterPanel.add(listPanel, BorderLayout.CENTER);
    myCenterPanel.add(createCvsConfigurationPanel(), BorderLayout.EAST);
    myCenterPanel.add(new JSeparator(JSeparator.HORIZONTAL), BorderLayout.SOUTH);

    myList.setModel(myModel);

    addSelectionListener();

    int minWidth = myList.getFontMetrics(myList.getFont()).stringWidth(SAMPLE_CVSROOT) + 40;
    Dimension minSize = new Dimension(minWidth, myList.getMaximumSize().height);
    listPanel.setMinimumSize(minSize);
    listPanel.setPreferredSize(minSize);
    return myCenterPanel;
  }
 private void setComponentSize(JComponent component, int w, int h) {
   component.setMinimumSize(new Dimension(w, h));
   component.setMaximumSize(new Dimension(w, h));
   component.setPreferredSize(new Dimension(w, h));
   component.setAlignmentX(Component.LEFT_ALIGNMENT);
 }
示例#11
0
  @SuppressWarnings("deprecation")
  public RanglistenDialog(final Vector<Runde> runden, JFrame parent) {
    super(parent);
    setModalExclusionType(ModalExclusionType.TOOLKIT_EXCLUDE);
    setBackground(new Color(0x00000000, true));
    try {
      obenLinks = loadImage(new File("obenLinks.png"));
      obenRechts = loadImage(new File("obenRechts.png"));
    } catch (Exception e) {
      e.printStackTrace();
    }
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    setBounds(50, 50, (int) screenSize.getWidth() - 100, (int) screenSize.getHeight() - 100);
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] {0, 0, 0, 0};
    gridBagLayout.rowHeights = new int[] {0, 0, 0, 0};
    gridBagLayout.columnWeights = new double[] {0.0, 1.0, 0.0, Double.MIN_VALUE};
    gridBagLayout.rowWeights = new double[] {0.0, 1.0, 0.0, Double.MIN_VALUE};
    getContentPane().setLayout(gridBagLayout);
    {
      Font font = new Font("SansSerif", Font.PLAIN, 37);
      JComponent compontent =
          new JComponent() {
            @Override
            public void paint(Graphics g) {
              super.paint(g);
              setSize(RanglistenDialog.this.getWidth(), 44);
              g.drawImage(obenLinks, 0, 0, obenLinks.getWidth(), obenLinks.getHeight(), this);
              g.drawImage(
                  obenRechts,
                  getWidth() - obenRechts.getWidth(),
                  0,
                  obenRechts.getWidth(),
                  obenRechts.getHeight(),
                  this);

              g.setColor(new Color(Farben.ANZEIGE_RAND));
              g.fillRect(
                  obenLinks.getWidth(),
                  0,
                  getWidth() - 2 * obenLinks.getWidth(),
                  obenLinks.getHeight());
              g.fillRect(
                  obenLinks.getWidth(), getWidth() - 6, getWidth() - 2 * obenLinks.getWidth(), 6);
              g.fillRect(0, obenLinks.getWidth(), 6, getWidth() - 2 * obenLinks.getHeight());
              g.fillRect(
                  getWidth() - 6, obenLinks.getHeight(), 6, getWidth() - 2 * obenLinks.getHeight());
              g.fillRect(6, obenLinks.getHeight(), getWidth() - 12, 44 - obenLinks.getHeight());
              paintComponents(g);
            }
          };
      compontent.setLayout(null);
      compontent.setBounds(0, 0, getWidth(), 44);
      compontent.setMinimumSize(new Dimension(44, 44));
      JLabel label = new JLabel("Rangliste");
      label.setBounds(22, 0, getWidth() - 24, 44);
      label.setFont(font);
      label.setForeground(Color.WHITE);
      JButton button = new JButton("Close");
      button.setBounds(getWidth() - 120, 12, 100, 20);
      compontent.add(button);
      button.addActionListener(
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
              ((Startmenu) RanglistenDialog.this.getParent()).enable();
              dispose();
            }
          });
      compontent.add(label);
      GridBagConstraints gbc_component = new GridBagConstraints();
      gbc_component.gridwidth = 3;
      gbc_component.insets = new Insets(0, 0, 43, 5);
      gbc_component.anchor = GridBagConstraints.FIRST_LINE_START;
      gbc_component.fill = GridBagConstraints.BOTH;
      gbc_component.gridx = 0;
      gbc_component.gridy = 0;
      getContentPane().add(compontent, gbc_component);
    }
    {
      JComponent compontent =
          new JComponent() {
            @Override
            public void paint(Graphics g) {
              super.paint(g);
              setBackground(Color.BLACK);
              setSize(6, getHeight());
              g.setColor(new Color(Farben.ANZEIGE_RAND));
              g.fillRect(0, 0, getWidth(), getHeight());
            }
          };
      compontent.setLayout(null);
      GridBagConstraints gbc_component = new GridBagConstraints();
      gbc_component.insets = new Insets(0, 0, 0, 5);
      gbc_component.fill = GridBagConstraints.BOTH;
      gbc_component.gridx = 0;
      gbc_component.gridy = 1;
      getContentPane().add(compontent, gbc_component);
    }
    {
      JComponent compontent =
          new JComponent() {
            @Override
            public void paint(Graphics g) {
              super.paint(g);
              setSize(6, getHeight());
              g.setColor(new Color(Farben.ANZEIGE_RAND));
              g.fillRect(0, 0, getWidth(), getHeight());
            }
          };
      compontent.setLayout(null);
      GridBagConstraints gbc_component2 = new GridBagConstraints();
      gbc_component2.insets = new Insets(0, 0, 0, 5);
      gbc_component2.fill = GridBagConstraints.BOTH;
      gbc_component2.gridx = 2;
      gbc_component2.gridy = 1;
      getContentPane().add(compontent, gbc_component2);
    }
    {
      JScrollPane scrollPane = new JScrollPane();
      GridBagConstraints gbc_scrollPane = new GridBagConstraints();
      gbc_scrollPane.insets = new Insets(0, 0, 0, 0);
      gbc_scrollPane.fill = GridBagConstraints.BOTH;
      gbc_scrollPane.gridx = 1;
      gbc_scrollPane.gridy = 1;
      scrollPane.setBackground(new Color(Farben.ANZEIGE_KOERPER));
      getContentPane().add(scrollPane, gbc_scrollPane);
      panel =
          new JPanel() {
            @Override
            public void paint(Graphics g) {
              super.paint(g);
              for (int i = 0; i < runden.size(); i++) {
                zeitLabels[i].setBounds(panel.getWidth() - 110, i * 40, 106, 40);
                nameLabels[i].setBounds(55, i * 40, panel.getWidth() - 210, 40);
              }
            }
          };
      panel.setSize(new Dimension(scrollPane.getWidth(), runden.size() * 40));
      panel.setLayout(null);
      panel.setPreferredSize(new Dimension(scrollPane.getWidth(), runden.size() * 40));
      panel.setBackground(new Color(Farben.ANZEIGE_KOERPER));
      scrollPane.setViewportView(panel);
    }
    {
      JComponent compontent =
          new JComponent() {
            @Override
            public void paint(Graphics g) {
              super.paint(g);
              setSize(getWidth(), 6);
              setBackground(Color.BLACK);
              g.setColor(new Color(Farben.ANZEIGE_RAND));
              g.fillRect(0, 0, getWidth(), getHeight());
            }
          };
      compontent.setLayout(null);
      GridBagConstraints gbc_component2 = new GridBagConstraints();
      gbc_component2.insets = new Insets(0, 0, 5, 0);
      gbc_component2.fill = GridBagConstraints.BOTH;
      gbc_component2.gridx = 0;
      gbc_component2.gridy = 2;
      gbc_component2.gridwidth = 3;
      getContentPane().add(compontent, gbc_component2);
    }
    Font font = new Font("SansSerif", Font.PLAIN, 24);
    zeitLabels = new JLabel[runden.size()];
    nameLabels = new JLabel[runden.size()];
    for (int i = 0; i < runden.size(); i++) {
      JLabel positionsLabel = new JLabel("" + i);
      positionsLabel.setFont(font);
      positionsLabel.setBounds(10, i * 40, 45, 40);
      panel.add(positionsLabel);
      zeitLabels[i] = new JLabel(Runde.zeitToString(runden.get(i).getEndzeit()));
      zeitLabels[i].setFont(font);
      zeitLabels[i].setBounds(panel.getWidth() - 110, i * 40, 106, 40);
      zeitLabels[i].setForeground(Color.WHITE);
      panel.add(zeitLabels[i]);
      nameLabels[i] = new JLabel(runden.get(i).getName());
      nameLabels[i].setFont(font);
      nameLabels[i].setBounds(55, i * 40, panel.getWidth() - 210, 40);
      nameLabels[i].setForeground(Color.WHITE);
      panel.add(nameLabels[i]);
    }
    setVisible(true);
    requestFocus();
  }