Search in sources :

Example 51 with EmptyBorder

use of javax.swing.border.EmptyBorder in project intellij-community by JetBrains.

the class MergedCompositeConfigurable method createPanel.

@NotNull
static JPanel createPanel(boolean isUseTitledBorder) {
    int verticalGap = TitledSeparator.TOP_INSET;
    JPanel panel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, isUseTitledBorder ? 0 : verticalGap, true, true));
    // VerticalFlowLayout incorrectly use vertical gap as top inset
    if (!isUseTitledBorder) {
        panel.setBorder(new EmptyBorder(-verticalGap, 0, 0, 0));
    }
    return panel;
}
Also used : EmptyBorder(javax.swing.border.EmptyBorder) VerticalFlowLayout(com.intellij.openapi.ui.VerticalFlowLayout) NotNull(org.jetbrains.annotations.NotNull)

Example 52 with EmptyBorder

use of javax.swing.border.EmptyBorder in project intellij-community by JetBrains.

the class ProjectConfigurable method init.

private void init(final ProjectSdksModel model) {
    myPanel = new JPanel(new GridBagLayout());
    myPanel.setPreferredSize(JBUI.size(700, 500));
    if (ProjectKt.isDirectoryBased(myProject)) {
        final JPanel namePanel = new JPanel(new BorderLayout());
        final JLabel label = new JLabel("<html><body><b>Project name:</b></body></html>", SwingConstants.LEFT);
        namePanel.add(label, BorderLayout.NORTH);
        myProjectName = new JTextField();
        myProjectName.setColumns(40);
        final JPanel nameFieldPanel = new JPanel();
        nameFieldPanel.setLayout(new BoxLayout(nameFieldPanel, BoxLayout.X_AXIS));
        nameFieldPanel.add(Box.createHorizontalStrut(4));
        nameFieldPanel.add(myProjectName);
        namePanel.add(nameFieldPanel, BorderLayout.CENTER);
        final JPanel wrapper = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
        wrapper.add(namePanel);
        wrapper.setAlignmentX(0);
        myPanel.add(wrapper, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, JBUI.insets(4, 0, 10, 0), 0, 0));
    }
    myProjectJdkConfigurable = new ProjectJdkConfigurable(myProject, model);
    myPanel.add(myProjectJdkConfigurable.createComponent(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, JBUI.insetsTop(4), 0, 0));
    myPanel.add(myWholePanel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insetsTop(4), 0, 0));
    myPanel.setBorder(new EmptyBorder(0, 10, 0, 10));
    myProjectCompilerOutput.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            if (myFreeze)
                return;
            myModulesConfigurator.processModuleCompilerOutputChanged(getCompilerOutputUrl());
        }
    });
    myProjectJdkConfigurable.addChangeListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            myLanguageLevelCombo.sdkUpdated(myProjectJdkConfigurable.getSelectedProjectJdk(), myProject.isDefault());
            LanguageLevelProjectExtensionImpl.getInstanceImpl(myProject).setCurrentLevel(myLanguageLevelCombo.getSelectedLevel());
        }
    });
    myLanguageLevelCombo.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            LanguageLevelProjectExtensionImpl.getInstanceImpl(myProject).setCurrentLevel(myLanguageLevelCombo.getSelectedLevel());
        }
    });
}
Also used : ActionEvent(java.awt.event.ActionEvent) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent) ActionListener(java.awt.event.ActionListener) EmptyBorder(javax.swing.border.EmptyBorder)

Example 53 with EmptyBorder

use of javax.swing.border.EmptyBorder in project intellij-community by JetBrains.

the class JBTabsDemo method main.

public static void main(String[] args) {
    System.out.println("JBTabs.main");
    IconLoader.activate();
    final JFrame frame = new JFrame();
    frame.getContentPane().setLayout(new BorderLayout(0, 0));
    final int[] count = new int[1];
    final JBTabsImpl tabs = new JBTabsImpl(null, ActionManager.getInstance(), null, Disposer.newDisposable());
    tabs.setTestMode(true);
    //final JPanel flow = new JPanel(new FlowLayout(FlowLayout.CENTER));
    //frame.getContentPane().add(flow);
    //flow.add(tabs.getComponent());
    frame.getContentPane().add(tabs.getComponent(), BorderLayout.CENTER);
    JPanel south = new JPanel(new FlowLayout());
    south.setOpaque(true);
    south.setBackground(Color.white);
    final JComboBox pos = new JComboBox(new Object[] { JBTabsPosition.top, JBTabsPosition.left, JBTabsPosition.right, JBTabsPosition.bottom });
    pos.setSelectedIndex(0);
    south.add(pos);
    pos.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            final JBTabsPosition p = (JBTabsPosition) pos.getSelectedItem();
            if (p != null) {
                tabs.getPresentation().setTabsPosition(p);
            }
        }
    });
    final JCheckBox bb = new JCheckBox("Buffered", true);
    bb.addItemListener(new ItemListener() {

        public void itemStateChanged(final ItemEvent e) {
            tabs.setUseBufferedPaint(bb.isSelected());
        }
    });
    south.add(bb);
    final JCheckBox f = new JCheckBox("Focused");
    f.addItemListener(new ItemListener() {

        public void itemStateChanged(final ItemEvent e) {
            tabs.setFocused(f.isSelected());
        }
    });
    south.add(f);
    final JCheckBox v = new JCheckBox("Vertical");
    v.addItemListener(new ItemListener() {

        public void itemStateChanged(final ItemEvent e) {
            tabs.setSideComponentVertical(v.isSelected());
        }
    });
    south.add(v);
    final JCheckBox row = new JCheckBox("Single row", true);
    row.addItemListener(new ItemListener() {

        public void itemStateChanged(final ItemEvent e) {
            tabs.setSingleRow(row.isSelected());
        }
    });
    south.add(row);
    final JCheckBox ghosts = new JCheckBox("Ghosts always visible", false);
    ghosts.addItemListener(new ItemListener() {

        public void itemStateChanged(final ItemEvent e) {
            tabs.setGhostsAlwaysVisible(ghosts.isSelected());
        }
    });
    south.add(ghosts);
    final JCheckBox stealth = new JCheckBox("Stealth tab", tabs.isStealthTabMode());
    stealth.addItemListener(new ItemListener() {

        public void itemStateChanged(final ItemEvent e) {
            tabs.setStealthTabMode(stealth.isSelected());
        }
    });
    south.add(stealth);
    final JCheckBox hide = new JCheckBox("Hide tabs", tabs.isHideTabs());
    hide.addItemListener(new ItemListener() {

        public void itemStateChanged(final ItemEvent e) {
            tabs.setHideTabs(hide.isSelected());
        }
    });
    south.add(hide);
    frame.getContentPane().add(south, BorderLayout.SOUTH);
    tabs.addListener(new TabsListener.Adapter() {

        public void selectionChanged(final TabInfo oldSelection, final TabInfo newSelection) {
            System.out.println("TabsWithActions.selectionChanged old=" + oldSelection + " new=" + newSelection);
        }
    });
    final JTree someTree = new Tree() {

        public void addNotify() {
            //To change body of overridden methods use File | Settings | File Templates.
            super.addNotify();
            System.out.println("JBTabs.addNotify");
        }

        public void removeNotify() {
            System.out.println("JBTabs.removeNotify");
            //To change body of overridden methods use File | Settings | File Templates.
            super.removeNotify();
        }
    };
    //someTree.setBorder(new LineBorder(Color.cyan));
    tabs.addTab(new TabInfo(someTree)).setText("Tree1").setActions(new DefaultActionGroup(), null).setIcon(AllIcons.Debugger.Frame);
    final JTree component = new Tree();
    final TabInfo toAnimate1 = new TabInfo(component);
    //toAnimate1.setIcon(IconLoader.getIcon("/debugger/console.png"));
    final JCheckBox attract1 = new JCheckBox("Attract 1");
    attract1.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            if (attract1.isSelected()) {
                toAnimate1.fireAlert();
            } else {
                toAnimate1.stopAlerting();
            }
        }
    });
    south.add(attract1);
    final JCheckBox hide1 = new JCheckBox("Hide 1", toAnimate1.isHidden());
    hide1.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            toAnimate1.setHidden(!toAnimate1.isHidden());
        }
    });
    south.add(hide1);
    final JCheckBox block = new JCheckBox("Block", false);
    block.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            tabs.setPaintBlocked(!block.isSelected(), true);
        }
    });
    south.add(block);
    final JCheckBox fill = new JCheckBox("Tab fill in", true);
    fill.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            tabs.getPresentation().setActiveTabFillIn(fill.isSelected() ? Color.white : null);
        }
    });
    south.add(fill);
    final JButton refire = new JButton("Re-fire attraction");
    refire.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            toAnimate1.fireAlert();
        }
    });
    south.add(refire);
    final JEditorPane text = new JEditorPane();
    text.setEditorKit(new HTMLEditorKit());
    StringBuffer buffer = new StringBuffer();
    for (int i = 0; i < 50; i++) {
        buffer.append("1234567890abcdefghijklmnopqrstv1234567890abcdefghijklmnopqrstv1234567890abcdefghijklmnopqrstv<br>");
    }
    text.setText(buffer.toString());
    final JLabel tb = new JLabel("Side comp");
    tb.setBorder(new LineBorder(Color.red));
    tabs.addTab(new TabInfo(ScrollPaneFactory.createScrollPane(text)).setSideComponent(tb)).setText("Text text text");
    tabs.addTab(toAnimate1).append("Tree2", new SimpleTextAttributes(SimpleTextAttributes.STYLE_WAVED, Color.black, Color.red));
    tabs.addTab(new TabInfo(new JTable())).setText("Table 1").setActions(new DefaultActionGroup(), null);
    tabs.addTab(new TabInfo(new JTable())).setText("Table 2").setActions(new DefaultActionGroup(), null);
    tabs.addTab(new TabInfo(new JTable())).setText("Table 3").setActions(new DefaultActionGroup(), null);
    tabs.addTab(new TabInfo(new JTable())).setText("Table 4").setActions(new DefaultActionGroup(), null);
    tabs.addTab(new TabInfo(new JTable())).setText("Table 5").setActions(new DefaultActionGroup(), null);
    tabs.addTab(new TabInfo(new JTable())).setText("Table 6").setActions(new DefaultActionGroup(), null);
    tabs.addTab(new TabInfo(new JTable())).setText("Table 7").setActions(new DefaultActionGroup(), null);
    tabs.addTab(new TabInfo(new JTable())).setText("Table 8").setActions(new DefaultActionGroup(), null);
    tabs.addTab(new TabInfo(new JTable())).setText("Table 9").setActions(new DefaultActionGroup(), null);
    //tabs.getComponent().setBorder(new EmptyBorder(5, 5, 5, 5));
    tabs.setTabSidePaintBorder(5);
    tabs.setPaintBorder(1, 1, 1, 1);
    tabs.getPresentation().setActiveTabFillIn(Color.white);
    tabs.setGhostsAlwaysVisible(true);
    //tabs.setBorder(new LineBorder(Color.blue, 5));
    tabs.setBorder(new EmptyBorder(30, 30, 30, 30));
    tabs.setUiDecorator(new UiDecorator() {

        public UiDecoration getDecoration() {
            return new UiDecoration(null, new Insets(0, -1, 0, -1));
        }
    });
    tabs.setStealthTabMode(true);
    frame.setBounds(1400, 200, 1000, 800);
    frame.show();
}
Also used : JBTabsPosition(com.intellij.ui.tabs.JBTabsPosition) ItemEvent(java.awt.event.ItemEvent) ActionEvent(java.awt.event.ActionEvent) LineBorder(javax.swing.border.LineBorder) TabsListener(com.intellij.ui.tabs.TabsListener) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) Tree(com.intellij.ui.treeStructure.Tree) TabInfo(com.intellij.ui.tabs.TabInfo) EmptyBorder(javax.swing.border.EmptyBorder) UiDecorator(com.intellij.ui.tabs.UiDecorator) HTMLEditorKit(javax.swing.text.html.HTMLEditorKit) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) ActionListener(java.awt.event.ActionListener) ItemListener(java.awt.event.ItemListener)

Example 54 with EmptyBorder

use of javax.swing.border.EmptyBorder in project intellij-community by JetBrains.

the class ContentLayout method updateIdLabel.

protected void updateIdLabel(BaseLabel label) {
    label.setText(myUi.myWindow.getStripeTitle() + (shouldDrawDecorations() ? ":" : ""));
    label.setBorder(new EmptyBorder(0, 2, 0, 8));
    if (myUi.myManager.getContentCount() == 1) {
        final String text = myUi.myManager.getContent(0).getDisplayName();
        if (text != null && text.trim().length() > 0) {
            label.setText(label.getText() + " ");
            label.setBorder(new EmptyBorder(0, 2, 0, 0));
        }
    }
    label.setVisible(shouldShowId());
}
Also used : EmptyBorder(javax.swing.border.EmptyBorder)

Example 55 with EmptyBorder

use of javax.swing.border.EmptyBorder in project adempiere by adempiere.

the class MiniTable method getCellRenderer.

public TableCellRenderer getCellRenderer(int row, int column) {
    Object editorClass = null;
    try {
        editorClass = this.getColumnModel().getColumn(column).getCellEditor().getClass();
    }//  Possible NPE if the table was not setup properly.
     catch (Exception e) {
    }
    boolean editable = this.isCellEditable(row, column);
    if (editable && editorClass == MiniCellEditor.class) {
        Color borderColor = AdempierePLAF.getFieldBackground_Mandatory();
        CompoundBorder cb = null;
        //  Set the borders on the editor
        MiniCellEditor jc = ((MiniCellEditor) this.getColumnModel().getColumn(column).getCellEditor());
        if (column == 0) {
            cb = new CompoundBorder(new EmptyBorder(new Insets(0, 0, 0, 1)), new MatteBorder(1, 1, 1, 0, borderColor));
            jc.setBorder(cb);
        } else if (column == this.getColumnCount() - 1) {
            cb = new CompoundBorder(new EmptyBorder(new Insets(0, 1, 0, 0)), new MatteBorder(1, 0, 1, 1, borderColor));
            jc.setBorder(cb);
        } else {
            cb = new CompoundBorder(new EmptyBorder(new Insets(0, 1, 0, 1)), new MatteBorder(1, 0, 1, 0, borderColor));
            jc.setBorder(cb);
        }
    }
    return super.getCellRenderer(row, column);
}
Also used : MatteBorder(javax.swing.border.MatteBorder) Insets(java.awt.Insets) Color(java.awt.Color) CompoundBorder(javax.swing.border.CompoundBorder) EmptyBorder(javax.swing.border.EmptyBorder) SQLException(java.sql.SQLException)

Aggregations

EmptyBorder (javax.swing.border.EmptyBorder)224 JPanel (javax.swing.JPanel)96 BorderLayout (java.awt.BorderLayout)87 JLabel (javax.swing.JLabel)70 JButton (javax.swing.JButton)44 JScrollPane (javax.swing.JScrollPane)44 Insets (java.awt.Insets)37 Dimension (java.awt.Dimension)35 Border (javax.swing.border.Border)30 GridBagLayout (java.awt.GridBagLayout)29 ActionEvent (java.awt.event.ActionEvent)27 ActionListener (java.awt.event.ActionListener)27 TitledBorder (javax.swing.border.TitledBorder)25 GridBagConstraints (java.awt.GridBagConstraints)24 Box (javax.swing.Box)22 JTextField (javax.swing.JTextField)21 CompoundBorder (javax.swing.border.CompoundBorder)20 BoxLayout (javax.swing.BoxLayout)17 FlowLayout (java.awt.FlowLayout)16 JCheckBox (javax.swing.JCheckBox)16