public void testBorder() throws Exception {
   JPanel panel = (JPanel) getInstrumentedRootComponent("TestBorder.form", "BindingTest");
   assertTrue(panel.getBorder() instanceof TitledBorder);
   TitledBorder border = (TitledBorder) panel.getBorder();
   assertEquals("BorderTitle", border.getTitle());
   assertTrue(border.getBorder().toString(), border.getBorder() instanceof EtchedBorder);
 }
Example #2
0
 private static int getPanelBaseline(JPanel panel, int height) {
   Border border = panel.getBorder();
   if (border instanceof TitledBorder) {
     TitledBorder titledBorder = (TitledBorder) border;
     if (titledBorder.getTitle() != null && !"".equals(titledBorder.getTitle())) {
       Font font = titledBorder.getTitleFont();
       if (font == null) {
         font = panel.getFont();
         if (font == null) {
           font = new Font("Dialog", Font.PLAIN, 12);
         }
       }
       Border border2 = titledBorder.getBorder();
       Insets borderInsets;
       if (border2 != null) {
         borderInsets = border2.getBorderInsets(panel);
       } else {
         borderInsets = EMPTY_INSETS;
       }
       FontMetrics fm = panel.getFontMetrics(font);
       int fontHeight = fm.getHeight();
       int descent = fm.getDescent();
       int ascent = fm.getAscent();
       int y = EDGE_SPACING;
       int h = height - EDGE_SPACING * 2;
       int diff;
       switch (((TitledBorder) border).getTitlePosition()) {
         case TitledBorder.ABOVE_TOP:
           diff = ascent + descent + (Math.max(EDGE_SPACING, TEXT_SPACING * 2) - EDGE_SPACING);
           return y + diff - (descent + TEXT_SPACING);
         case TitledBorder.TOP:
         case TitledBorder.DEFAULT_POSITION:
           diff = Math.max(0, ((ascent / 2) + TEXT_SPACING) - EDGE_SPACING);
           return (y + diff - descent) + (borderInsets.top + ascent + descent) / 2;
         case TitledBorder.BELOW_TOP:
           return y + borderInsets.top + ascent + TEXT_SPACING;
         case TitledBorder.ABOVE_BOTTOM:
           return (y + h) - (borderInsets.bottom + descent + TEXT_SPACING);
         case TitledBorder.BOTTOM:
           h -= fontHeight / 2;
           return ((y + h) - descent) + ((ascent + descent) - borderInsets.bottom) / 2;
         case TitledBorder.BELOW_BOTTOM:
           h -= fontHeight;
           return y + h + ascent + TEXT_SPACING;
       }
     }
   }
   return -1;
 }
Example #3
0
 private static int getPanelBaselineResizeBehavior(JPanel panel) {
   Border b = panel.getBorder();
   if (b instanceof TitledBorder) {
     switch (((TitledBorder) b).getTitlePosition()) {
       case TitledBorder.ABOVE_TOP:
       case TitledBorder.TOP:
       case TitledBorder.DEFAULT_POSITION:
       case TitledBorder.BELOW_TOP:
         return BRB_CONSTANT_ASCENT;
       case TitledBorder.ABOVE_BOTTOM:
       case TitledBorder.BOTTOM:
       case TitledBorder.BELOW_BOTTOM:
         return BRB_CONSTANT_DESCENT;
     }
   }
   return BRB_OTHER;
 }
  protected Component createContentPane() {
    final JSplitPane expressionsPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    expressionsPane.setLeftComponent(createChartPanel());
    expressionsPane.setRightComponent(dataSourceTabbedPane);

    final JSplitPane previewPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    previewPane.setBottomComponent(expressionsPane);
    final JPanel contentPane = new JPanel();
    final Border border = contentPane.getBorder();
    final Border margin = new EmptyBorder(5, 20, 0, 0);
    contentPane.setBorder(new CompoundBorder(border, margin));
    contentPane.setLayout(new BorderLayout());
    contentPane.add(createChartSelectorButtonPane(), BorderLayout.NORTH);
    contentPane.add(previewPane, BorderLayout.CENTER);

    previewPane.setDividerLocation(300);
    expressionsPane.setDividerLocation(350);

    return contentPane;
  }
  private void updateEditorsFromProperties() {
    String propertyName = getSelectedPropertyName();
    ((CardLayout) myValuesPanel.getLayout())
        .show(myValuesPanel, propertyName == null ? NO_PROPERTY_SELECTED : VALUES);
    if (propertyName == null) return;

    for (final PropertiesFile propertiesFile : myResourceBundle.getPropertiesFiles(myProject)) {
      final EditorEx editor = (EditorEx) myEditors.get(propertiesFile);
      if (editor == null) continue;
      final IProperty property = propertiesFile.findPropertyByKey(propertyName);
      final Document document = editor.getDocument();
      CommandProcessor.getInstance()
          .executeCommand(
              null,
              new Runnable() {
                @Override
                public void run() {
                  ApplicationManager.getApplication()
                      .runWriteAction(
                          new Runnable() {
                            @Override
                            public void run() {
                              updateDocumentFromPropertyValue(
                                  getPropertyEditorValue(property), document, propertiesFile);
                            }
                          });
                }
              },
              "",
              this);

      JPanel titledPanel = myTitledPanels.get(propertiesFile);
      ((TitledBorder) titledPanel.getBorder())
          .setTitleColor(property == null ? JBColor.RED : UIUtil.getLabelTextForeground());
      titledPanel.repaint();
    }
  }
 /**
  * Gibt den Rahmen zur�ck der um das <code>JPanel</code> viewerPanel liegt.
  *
  * @return Der Rahmen um das <code>JPanel</code> viewerPanel.
  */
 public Border getBorder() {
   return viewerPanel.getBorder();
 }
Example #7
0
  private void createSwingStuff() {
    mainPanel = new JPanel();
    panel1 = new JPanel();
    panel2 = new JPanel();
    panel3 = new JPanel();
    closeButton = new JButton("Close");
    deleteButton = new JButton("Delete me!");
    ta = new JTextArea("");
    ta.setEditable(false);
    newCreatureButton = new JButton("New Creature");

    newCreatureButton.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            log.info("*** Create creature! ***");
            placeCreatureHere(x, y);
            setVisible(false);
          }
        });
    newJewelButton = new JButton("New Jewel");

    newJewelButton.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            log.info("*** Create Jewel! ***");
            placeJewelHere(x, y);
            setVisible(false);
          }
        });
    closeButton.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            setVisible(false);
          }
        });
    deleteButton.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent ev) {
            log.info("*** Food deleted! ***");
            food.removeRememberMeIcon(e);
            e.removeThing(food);
            setVisible(false);
          }
        });
    panel1.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createCompoundBorder(
                BorderFactory.createTitledBorder("Food type"),
                BorderFactory.createEmptyBorder(5, 5, 5, 5)),
            panel1.getBorder()));
    panel1.setLayout(new GridLayout(1, 1));

    String[] foodTypes = {this.e.nonPerishableFood, this.e.perishableFood};

    panel1.add(createFoodTypeButtons(foodTypes));

    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(ta, BorderLayout.PAGE_START);
    mainPanel.add(panel1, BorderLayout.LINE_START);

    panel2.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createCompoundBorder(
                BorderFactory.createTitledBorder("Visibility"),
                BorderFactory.createEmptyBorder(5, 5, 5, 5)),
            panel2.getBorder()));
    panel2.setLayout(new GridLayout(1, 1));
    hiddenObstacle = new JCheckBoxMenuItem("I'm hidden");
    hiddenObstacle.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent ae) {
            try {
              // System.out.println("======= Event command name : "+e.getActionCommand()+" and
              // params: "+e.paramString() );
              if (hiddenObstacle.isSelected()) {
                food.hideMe(e);
                hiddenObstacle.setSelected(true);

              } else {
                food.undoHideMe(e);
                hiddenObstacle.setSelected(false);
              }
              // theMainInstance.sf.gameState.ThingsRN.updateRenderState();
            } catch (Exception ex) {
              ex.printStackTrace();
              JOptionPane.showMessageDialog(
                  EditFoodFrame.this,
                  "Error in hidden obstacle execution.",
                  "ERRO",
                  JOptionPane.ERROR_MESSAGE);
            }
          }
        });
    panel2.add(hiddenObstacle);
    mainPanel.add(panel2, BorderLayout.LINE_END);

    panel3.setLayout(new GridLayout(1, 4));
    panel3.add(newCreatureButton);
    panel3.add(newJewelButton);
    panel3.add(deleteButton);
    panel3.add(closeButton);
    mainPanel.add(panel3, BorderLayout.PAGE_END);

    add(mainPanel);
    pack();
    setVisible(false);
    setResizable(false);
  }