Example usage for javax.swing BorderFactory createTitledBorder

List of usage examples for javax.swing BorderFactory createTitledBorder

Introduction

In this page you can find the example usage for javax.swing BorderFactory createTitledBorder.

Prototype

public static TitledBorder createTitledBorder(Border border) 

Source Link

Document

Creates a new titled border with an empty title, the specified border object, the default text position (determined by the current look and feel), the default justification (leading), and the default font and text color (determined by the current look and feel).

Usage

From source file:io.github.jeremgamer.editor.panels.IconFrame.java

public IconFrame(JFrame parent) {
    this.setModal(true);
    this.setResizable(false);
    ArrayList<BufferedImage> icons = new ArrayList<BufferedImage>();
    try {/*from   ww  w  .  j  a v a 2s  .  co m*/
        icons.add(ImageIO.read(ImageGetter.class.getResource("icon16.png")));
        icons.add(ImageIO.read(ImageGetter.class.getResource("icon32.png")));
        icons.add(ImageIO.read(ImageGetter.class.getResource("icon64.png")));
        icons.add(ImageIO.read(ImageGetter.class.getResource("icon128.png")));
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    this.setIconImages((List<? extends Image>) icons);
    this.setTitle("Icnes");

    this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

    JPanel content = new JPanel();
    content.setLayout(new BoxLayout(content, BoxLayout.LINE_AXIS));
    content.setBorder(BorderFactory.createTitledBorder(""));

    try {
        remove128.setIcon(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
        remove64.setIcon(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
        remove32.setIcon(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
        remove16.setIcon(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
    } catch (IOException e) {
        e.printStackTrace();
    }
    browse128.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            String path = null;
            JFileChooser chooser = new JFileChooser(Editor.lastPath);
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg",
                    "bmp");
            chooser.setFileFilter(filter);
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int option = chooser.showOpenDialog(null);
            if (option == JFileChooser.APPROVE_OPTION) {
                path = chooser.getSelectedFile().getAbsolutePath();
                Editor.lastPath = chooser.getSelectedFile().getParent();
                copyImage(new File(path), "128.png");
                try {
                    x128.repaint();
                    x128.getGraphics().drawImage(ImageIO.read(new File(path)), 0 + 10, 0 + 20, 128, 128, null);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    });
    remove128.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            File file = new File("projects/" + Editor.getProjectName() + "/128.png");
            file.delete();
            x128.repaint();
        }
    });
    browse64.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            String path = null;
            JFileChooser chooser = new JFileChooser(Editor.lastPath);
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg",
                    "bmp");
            chooser.setFileFilter(filter);
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int option = chooser.showOpenDialog(null);
            if (option == JFileChooser.APPROVE_OPTION) {
                path = chooser.getSelectedFile().getAbsolutePath();
                Editor.lastPath = chooser.getSelectedFile().getParent();
                copyImage(new File(path), "64.png");
                try {
                    x64.repaint();
                    x64.getGraphics().drawImage(ImageIO.read(new File(path)), 32 + 10, 32 + 20, 64, 64, null);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    });
    remove64.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            File file = new File("projects/" + Editor.getProjectName() + "/64.png");
            file.delete();
            x64.repaint();
        }
    });
    browse32.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            String path = null;
            JFileChooser chooser = new JFileChooser(Editor.lastPath);
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg",
                    "bmp");
            chooser.setFileFilter(filter);
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int option = chooser.showOpenDialog(null);
            if (option == JFileChooser.APPROVE_OPTION) {
                path = chooser.getSelectedFile().getAbsolutePath();
                Editor.lastPath = chooser.getSelectedFile().getParent();
                copyImage(new File(path), "32.png");
                try {
                    x32.repaint();
                    x32.getGraphics().drawImage(ImageIO.read(new File(path)), 48 + 10, 48 + 20, 32, 32, null);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    });
    remove32.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            File file = new File("projects/" + Editor.getProjectName() + "/32.png");
            file.delete();
            x32.repaint();
        }
    });
    browse16.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            String path = null;
            JFileChooser chooser = new JFileChooser(Editor.lastPath);
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg",
                    "bmp");
            chooser.setFileFilter(filter);
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int option = chooser.showOpenDialog(null);
            if (option == JFileChooser.APPROVE_OPTION) {
                path = chooser.getSelectedFile().getAbsolutePath();
                Editor.lastPath = chooser.getSelectedFile().getParent();
                copyImage(new File(path), "16.png");
                try {
                    x16.repaint();
                    x16.getGraphics().drawImage(ImageIO.read(new File(path)), 56 + 10, 56 + 20, 16, 16, null);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    });
    remove16.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            File file = new File("projects/" + Editor.getProjectName() + "/16.png");
            file.delete();
            x16.repaint();
        }
    });

    content.add(x128);
    content.add(x64);
    content.add(x32);
    content.add(x16);
    this.setContentPane(content);
    this.pack();
    this.setLocationRelativeTo(parent);
    this.setVisible(true);
}

From source file:GCWrapper.java

/**
 * Creates and lays out components in the container. See the comments below
 * for an organizational overview by panel.
 *//*  ww w .j av a  2 s  .  co m*/
private void initComponents(Container c) {
    // +=c=====================================================+
    // ++=gcPanel==============================================+
    // ++ [gcSelection] +
    // ++=capsPanel============================================+
    // +++=imageCapsPanel======================================+
    // +++ [imageAccelerated] +
    // +++ [imageTrueVolatile] +
    // +++=bufferCapsPanel=====================================+
    // ++++=bufferAccessCapsPanel==============================+
    // +++++=flippingPanel=====================================+
    // +++++ [flipping] +
    // +++++=fsPanel===========================================+
    // +++++ [indentPanel][fullScreen] +
    // +++++=mbPanel===========================================+
    // +++++ [indentPanel][multiBuffer] +
    // ++++=buffersPanel=======================================+
    // +++++=fbPanel===============+=bbPanel===================+
    // +++++ + +
    // +++++ [fbAccelerated] + [bbAccelerated] +
    // +++++ + +
    // +++++ [fbTrueVolatile] + [bbTrueVolatile] +
    // +++++ + +
    // +=======================================================+
    c.setLayout(new BorderLayout());
    // Graphics Config
    JPanel gcPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    c.add(gcPanel, BorderLayout.NORTH);
    gcSelection.setPreferredSize(new Dimension(400, 30));
    gcPanel.add(gcSelection);
    // Capabilities
    JPanel capsPanel = new JPanel(new BorderLayout());
    c.add(capsPanel, BorderLayout.CENTER);
    // Image Capabilities
    JPanel imageCapsPanel = new JPanel(new GridLayout(2, 1));
    capsPanel.add(imageCapsPanel, BorderLayout.NORTH);
    imageCapsPanel.setBorder(BorderFactory.createTitledBorder("Image Capabilities"));
    imageAccelerated.setEnabled(false);
    imageCapsPanel.add(imageAccelerated);
    imageTrueVolatile.setEnabled(false);
    imageCapsPanel.add(imageTrueVolatile);
    // Buffer Capabilities
    JPanel bufferCapsPanel = new JPanel(new BorderLayout());
    capsPanel.add(bufferCapsPanel, BorderLayout.CENTER);
    bufferCapsPanel.setBorder(BorderFactory.createTitledBorder("Buffer Capabilities"));
    // Buffer Access
    JPanel bufferAccessCapsPanel = new JPanel(new GridLayout(3, 1));
    bufferAccessCapsPanel.setPreferredSize(new Dimension(300, 88));
    bufferCapsPanel.add(bufferAccessCapsPanel, BorderLayout.NORTH);
    // Flipping
    JPanel flippingPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    bufferAccessCapsPanel.add(flippingPanel);
    flippingPanel.add(flipping);
    flipping.setEnabled(false);
    flippingPanel.add(flippingMethod);
    // Full-screen
    JPanel fsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    bufferAccessCapsPanel.add(fsPanel);
    JPanel indentPanel = new JPanel();
    indentPanel.setPreferredSize(new Dimension(30, 30));
    fsPanel.add(indentPanel);
    fsPanel.add(fullScreen);
    fullScreen.setEnabled(false);
    // Multi-buffering
    JPanel mbPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    bufferAccessCapsPanel.add(mbPanel);
    indentPanel = new JPanel();
    indentPanel.setPreferredSize(new Dimension(30, 30));
    mbPanel.add(indentPanel);
    mbPanel.add(multiBuffer);
    multiBuffer.setEnabled(false);
    // Front and Back Buffer Capabilities
    JPanel buffersPanel = new JPanel(new GridLayout(1, 2));
    bufferCapsPanel.add(buffersPanel, BorderLayout.CENTER);
    // Front Buffer
    JPanel fbPanel = new JPanel(new GridLayout(2, 1));
    fbPanel.setBorder(BorderFactory.createTitledBorder("Front Buffer"));
    buffersPanel.add(fbPanel);
    fbPanel.add(fbAccelerated);
    fbAccelerated.setEnabled(false);
    fbPanel.add(fbTrueVolatile);
    fbTrueVolatile.setEnabled(false);
    // Back Buffer
    JPanel bbPanel = new JPanel(new GridLayout(2, 1));
    bbPanel.setPreferredSize(new Dimension(250, 80));
    bbPanel.setBorder(BorderFactory.createTitledBorder("Back and Intermediate Buffers"));
    buffersPanel.add(bbPanel);
    bbPanel.add(bbAccelerated);
    bbAccelerated.setEnabled(false);
    bbPanel.add(bbTrueVolatile);
    bbTrueVolatile.setEnabled(false);
}

From source file:com.opendoorlogistics.components.reports.ReporterPanel.java

/**
 * @param title// w w w . j  a v a2s  .  c o m
 * @return
 */
private Border createBorder(String title) {
    return BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5),
            BorderFactory.createTitledBorder(title));
}

From source file:external.jung.demo.RoadEditorDemo.java

/**
 * create an instance of a simple graph with popup controls to create a
 * graph./*from   w w  w  .j  a  v a2  s . c om*/
 *
 */
public RoadEditorDemo() {
    roadGraphHelper = new RoadGraphHelper();
    this.graph = roadGraphHelper.createRoadGraph();
    this.layout = new StaticLayout<Vertex3DInfo, Edge3DInfo>(graph, new Dimension(600, 600));
    this.roadGraphHelper.setLayout(layout);

    vv = new VisualizationViewer<Vertex3DInfo, Edge3DInfo>(layout);
    vv.setBackground(Color.white);

    vv.getRenderContext().setVertexLabelTransformer(
            MapTransformer.<Vertex3DInfo, String>getInstance(LazyMap.<Vertex3DInfo, String>decorate(
                    new HashMap<Vertex3DInfo, String>(), new ToStringLabeller<Vertex3DInfo>())));
    vv.getRenderContext().setEdgeLabelTransformer(
            MapTransformer.<Edge3DInfo, String>getInstance(LazyMap.<Edge3DInfo, String>decorate(
                    new HashMap<Edge3DInfo, String>(), new ToStringLabeller<Edge3DInfo>())));
    vv.setVertexToolTipTransformer(vv.getRenderContext().getVertexLabelTransformer());
    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<Vertex3DInfo, Edge3DInfo>());

    Container content = getContentPane();
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel);

    final EditingModalGraphMouse<Vertex3DInfo, Edge3DInfo> graphMouse = new EditingModalGraphMouse<Vertex3DInfo, Edge3DInfo>(
            vv.getRenderContext(), roadGraphHelper.vertexFactory, roadGraphHelper.edgeFactory);

    // the EditingGraphMouse will pass mouse event coordinates to the
    // vertexLocations function to set the locations of the vertices as
    // they are created
    //        graphMouse.setVertexLocations(vertexLocations);
    vv.setGraphMouse(graphMouse);
    vv.addKeyListener(graphMouse.getModeKeyListener());

    graphMouse.setMode(ModalGraphMouse.Mode.EDITING);

    final ScalingControl scaler = new CrossoverScalingControl();
    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JButton help = new JButton("Build");
    help.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //edgeAngle();
            roadGraphHelper.resetExtraDraw();
            roadGraphHelper.vertexIntersect();
            vv.repaint();

        }
    });

    AnnotationControls<Vertex3DInfo, Edge3DInfo> annotationControls = new AnnotationControls<Vertex3DInfo, Edge3DInfo>(
            graphMouse.getAnnotatingPlugin());
    JPanel controls = new JPanel();
    controls.add(plus);
    controls.add(minus);
    JComboBox modeBox = graphMouse.getModeComboBox();
    controls.add(modeBox);
    controls.add(annotationControls.getAnnotationsToolBar());
    controls.add(help);

    JSlider slider2 = new JSlider();
    slider2.setBorder(BorderFactory.createTitledBorder("Size"));
    slider2.setMajorTickSpacing(20);
    slider2.setMinorTickSpacing(5);
    slider2.setPaintTicks(true);
    controls.add(slider2);
    slider2.addChangeListener(new SliderListener());

    JPanel checkBoxes = new JPanel();
    //checkBoxes.setLayout(new GridLayout(1, 5));
    layer1Check = new JCheckBox("Layer1");
    layer1Check.setSelected(true);

    layer2Check = new JCheckBox("Layer2");
    layer2Check.setSelected(true);

    layer3Check = new JCheckBox("Layer3");
    layer3Check.setSelected(true);

    layer4Check = new JCheckBox("Layer4");
    layer4Check.setSelected(true);
    layer5Check = new JCheckBox("Layer5");
    layer5Check.setSelected(true);
    checkBoxes.add(layer1Check);
    checkBoxes.add(layer2Check);
    checkBoxes.add(layer3Check);
    checkBoxes.add(layer4Check);
    checkBoxes.add(layer5Check);
    JPanel twoLine = new JPanel();
    twoLine.setLayout(new GridLayout(2, 1));
    content.add(twoLine, BorderLayout.SOUTH);
    twoLine.add(controls);
    twoLine.add(checkBoxes);
    // 
    vv.addPostRenderPaintable(new PaintRoad());
    vv.addPreRenderPaintable(new PaintRoadUnder());
    vv.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            //edgeAngle();
            roadGraphHelper.resetExtraDraw();
            roadGraphHelper.vertexIntersect();
            vv.repaint();

        }
    });

}

From source file:net.sourceforge.squirrel_sql.client.preferences.WikiTablePreferencesPanel.java

/**
 * Create the component, which shows a example.
 * The example contains a {@link JTable} and a {@link JTextField}. If the user change a element of the configuration, then the example will be updated.
 * So we can provide a feedback of the result immediately.
 *//*from  ww w  .  j  a  va  2 s .  c  o  m*/
private Component createExamplePanel() {
    JPanel jp = new JPanel(new GridBagLayout());
    jp.setBorder(
            BorderFactory.createTitledBorder(s_stringMgr.getString("WikiTablePreferencesPanel.titleExample"))); //$NON-NLS-1$

    GridBagConstraints gbc = new GridBagConstraints();

    String[][] rowData = new String[][] {
            { s_stringMgr.getString("WikiTablePreferencesPanel.austria"), //$NON-NLS-1$
                    s_stringMgr.getString("WikiTablePreferencesPanel.vienna") }, //$NON-NLS-1$
            { s_stringMgr.getString("WikiTablePreferencesPanel.italy"), //$NON-NLS-1$
                    s_stringMgr.getString("WikiTablePreferencesPanel.rome") } //$NON-NLS-1$
    };

    String[] columnNames = new String[] { s_stringMgr.getString("WikiTablePreferencesPanel.country"), //$NON-NLS-1$
            s_stringMgr.getString("WikiTablePreferencesPanel.captial") }; //$NON-NLS-1$

    exampleTable = new JTable(rowData, columnNames);
    exampleTable.setMinimumSize(new Dimension(10, 10));

    JScrollPane sp = new JScrollPane(exampleTable);
    sp.setPreferredSize(new Dimension(100, 50));

    gbc.fill = GridBagConstraints.BOTH;
    gbc.weighty = 1;
    gbc.weighty = 0.1;
    jp.add(sp, gbc);

    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weighty = 0;
    gbc.weightx = 0;
    jp.add(new JLabel(s_stringMgr.getString("WikiTablePreferencesPanel.titleResultExample")), gbc); //$NON-NLS-1$

    exampleText = new JTextArea(15, 20);
    exampleText.setWrapStyleWord(true);
    exampleText.setEditable(false);
    exampleText.setLineWrap(false);

    gbc.gridy = 2;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weighty = 1;
    gbc.weightx = 1;

    sp = new JScrollPane(exampleText);
    jp.add(sp, gbc);

    return jp;
}

From source file:net.aepik.alasca.gui.util.LoadFileFrame.java

/**
 * Initialize frame content.// www.ja  va 2s  . c  o m
 */
private void initFrame() {
    // - Panel bouton du bas -

    JPanel boutonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    boutonsPanel.add(boutonOk);
    boutonsPanel.add(boutonAnnuler);

    // - Panel nom du fichier -

    JTextArea textAreaFilename = new JTextArea(
            "Indiquez le nom du fichier contenant les dfinitions du schma LDAP que vous souhaitez charger.");
    textAreaFilename.setEditable(false);
    textAreaFilename.setLineWrap(true);
    textAreaFilename.setWrapStyleWord(true);
    textAreaFilename.setFont((new JLabel()).getFont());
    textAreaFilename.setBorder(BorderFactory.createEmptyBorder(7, 6, 12, 6));
    textAreaFilename.setBackground(new Color(240, 235, 226));

    boutonOpenFile.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createMatteBorder(0, 5, 0, 0, boutonsPanel.getBackground()),
            boutonOpenFile.getBorder()));

    JPanel filenamePanel = new JPanel(new BorderLayout());
    filenamePanel.add(textAreaFilename, BorderLayout.NORTH);
    filenamePanel.add(filename, BorderLayout.CENTER);
    filenamePanel.add(boutonOpenFile, BorderLayout.EAST);
    filenamePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 4, 1, 4),
            BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(" Schma LDAP "),
                    BorderFactory.createEmptyBorder(0, 5, 5, 5))));

    // - Panel du selecteur de syntaxes -

    JTextArea textAreaSyntaxes = new JTextArea(
            "Il vous faut appliquer un filtre sur le schma que vous voulez charger. Voici la liste des filtres disponibles :");
    textAreaSyntaxes.setEditable(false);
    textAreaSyntaxes.setLineWrap(true);
    textAreaSyntaxes.setWrapStyleWord(true);
    textAreaSyntaxes.setFont((new JLabel()).getFont());
    textAreaSyntaxes.setBorder(BorderFactory.createEmptyBorder(7, 6, 12, 6));
    textAreaSyntaxes.setBackground(new Color(240, 235, 226));

    JPanel syntaxesPanel = new JPanel(new BorderLayout());
    syntaxesPanel.add(textAreaSyntaxes, BorderLayout.NORTH);
    syntaxesPanel.add(syntaxes);
    syntaxesPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 4, 1, 4),
            BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(" Syntaxe LDAP "),
                    BorderFactory.createEmptyBorder(0, 5, 5, 5))));

    // On injecte le nom des classes de syntaxes possibles
    // dynamiquement.
    String[] syntaxesName = Schema.getSyntaxeNames();
    for (int i = 0; syntaxesName != null && i < syntaxesName.length; i++) {
        syntaxes.addItem(syntaxesName[i]);
    }

    // - Organisation gnrale -

    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(filenamePanel, BorderLayout.NORTH);
    mainPanel.add(syntaxesPanel, BorderLayout.CENTER);

    JPanel mainPanelContainer = new JPanel(new BorderLayout());
    mainPanelContainer.add(mainPanel, BorderLayout.NORTH);
    mainPanelContainer.add(boutonsPanel, BorderLayout.SOUTH);
    mainPanelContainer.setBorder(BorderFactory.createEmptyBorder(2, 1, 1, 1));

    getContentPane().add(new DescriptiveInternalFrame(mainFrame.getIconImage(),
            "Slectionner un fichier et sa syntaxe.", mainPanelContainer));

    // - Listeners -

    addWindowListener(this);
    boutonOpenFile.addActionListener(this);
    boutonOk.addActionListener(this);
    boutonAnnuler.addActionListener(this);
}

From source file:ca.phon.app.session.editor.view.segmentation.SegmentationEditorView.java

private void init() {
    segmentWindowField = new JTextField();
    SegmentWindowDocument segDoc = new SegmentWindowDocument();
    segmentWindowField.setDocument(segDoc);
    segmentWindowField.setText(DEFAULT_SEGMENT_WINDOW + "");
    segDoc.addDocumentListener(new SegmentWindowListener());

    segmentLabel = new SegmentLabel();
    segmentLabel.setSegmentWindow(DEFAULT_SEGMENT_WINDOW);
    segmentLabel.setCurrentTime(0L);//  ww  w .j a  va2 s .co m
    segmentLabel.lockSegmentStartTime(-1L);

    modeBox = new JComboBox(SegmentationMode.values());
    modeBox.setSelectedItem(SegmentationMode.INSERT_AFTER_CURRENT);

    JPanel topPanel = new JPanel();
    FormLayout topLayout = new FormLayout("right:pref, 3dlu, fill:default:grow, pref",
            "pref, pref, pref, pref");
    topPanel.setLayout(topLayout);
    CellConstraints cc = new CellConstraints();
    topPanel.add(new JLabel("Segment Window"), cc.xy(1, 1));
    topPanel.add(segmentWindowField, cc.xy(3, 1));
    topPanel.add(new JLabel("ms"), cc.xy(4, 1));

    JLabel infoLabel = new JLabel("Set to 0 for unlimited segment time");
    infoLabel.setFont(infoLabel.getFont().deriveFont(10.0f));

    topPanel.add(infoLabel, cc.xy(3, 2));
    topPanel.add(new JLabel("Current Window"), cc.xy(1, 3));
    topPanel.add(segmentLabel, cc.xy(3, 3));

    topPanel.add(new JLabel("Mode"), cc.xy(1, 4));
    topPanel.add(modeBox, cc.xyw(3, 4, 2));

    setLayout(new BorderLayout());
    add(topPanel, BorderLayout.NORTH);

    participantPanel = new JPanel();

    participantPanel.setBackground(Color.white);
    participantPanel.setOpaque(true);

    JScrollPane participantScroller = new JScrollPane(participantPanel);
    Dimension prefSize = participantScroller.getPreferredSize();
    prefSize.height = 150;
    participantScroller.setPreferredSize(prefSize);
    Dimension maxSize = participantScroller.getMaximumSize();
    maxSize.height = 200;
    participantScroller.setMaximumSize(maxSize);
    Dimension minSize = participantScroller.getMinimumSize();
    minSize.height = 100;
    participantScroller.setMinimumSize(minSize);
    participantScroller.setBorder(BorderFactory.createTitledBorder("Participants"));

    add(participantScroller, BorderLayout.CENTER);

    updateParticipantPanel();
    setupEditorActions();
}

From source file:mekhq.gui.FinancesTab.java

@Override
public void initTab() {
    resourceMap = ResourceBundle.getBundle("mekhq.resources.FinancesTab", new EncodeControl()); //$NON-NLS-1$

    GridBagConstraints gridBagConstraints;

    setLayout(new GridBagLayout());
    ChartPanel financeAmountPanel = (ChartPanel) createGraphPanel(GraphType.BALANCE_AMOUNT);
    ChartPanel financeMonthlyPanel = (ChartPanel) createGraphPanel(GraphType.MONTHLY_FINANCES);

    financeModel = new FinanceTableModel();
    financeTable = new JTable(financeModel);
    financeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    financeTable.addMouseListener(new FinanceTableMouseAdapter(getCampaignGui(), financeTable, financeModel));
    financeTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    TableColumn column = null;// w ww .java2 s.  c o m
    for (int i = 0; i < FinanceTableModel.N_COL; i++) {
        column = financeTable.getColumnModel().getColumn(i);
        column.setPreferredWidth(financeModel.getColumnWidth(i));
        column.setCellRenderer(financeModel.getRenderer());
    }
    financeTable.setIntercellSpacing(new Dimension(0, 0));
    financeTable.setShowGrid(false);

    loanModel = new LoanTableModel();
    loanTable = new JTable(loanModel);
    loanTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    loanTable.addMouseListener(new LoanTableMouseAdapter(getCampaignGui(), loanTable, loanModel));
    loanTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    column = null;
    for (int i = 0; i < LoanTableModel.N_COL; i++) {
        column = loanTable.getColumnModel().getColumn(i);
        column.setPreferredWidth(loanModel.getColumnWidth(i));
        column.setCellRenderer(loanModel.getRenderer());
    }
    loanTable.setIntercellSpacing(new Dimension(0, 0));
    loanTable.setShowGrid(false);
    JScrollPane scrollLoanTable = new JScrollPane(loanTable);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    JPanel panBalance = new JPanel(new GridBagLayout());
    panBalance.add(new JScrollPane(financeTable), gridBagConstraints);
    panBalance.setMinimumSize(new java.awt.Dimension(350, 100));
    panBalance.setBorder(BorderFactory.createTitledBorder("Balance Sheet"));
    JPanel panLoan = new JPanel(new GridBagLayout());
    panLoan.add(scrollLoanTable, gridBagConstraints);

    JTabbedPane financeTab = new JTabbedPane();
    financeTab.setMinimumSize(new java.awt.Dimension(450, 300));
    financeTab.setPreferredSize(new java.awt.Dimension(450, 300));

    JSplitPane splitFinances = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panBalance, financeTab);
    splitFinances.setOneTouchExpandable(true);
    splitFinances.setContinuousLayout(true);
    splitFinances.setResizeWeight(1.0);
    splitFinances.setName("splitFinances");

    financeTab.addTab(resourceMap.getString("activeLoans.text"), panLoan);
    financeTab.addTab(resourceMap.getString("cbillsBalanceTime.text"), financeAmountPanel);
    financeTab.addTab(resourceMap.getString("monthlyRevenueExpenditures.text"), financeMonthlyPanel);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    add(splitFinances, gridBagConstraints);

    JPanel panelFinanceRight = new JPanel(new BorderLayout());

    JPanel pnlFinanceBtns = new JPanel(new GridLayout(2, 2));
    btnAddFunds = new JButton("Add Funds (GM)");
    btnAddFunds.addActionListener(ev -> addFundsActionPerformed());
    btnAddFunds.setEnabled(getCampaign().isGM());
    pnlFinanceBtns.add(btnAddFunds);
    JButton btnGetLoan = new JButton("Get Loan");
    btnGetLoan.addActionListener(e -> showNewLoanDialog());
    pnlFinanceBtns.add(btnGetLoan);

    btnManageAssets = new JButton("Manage Assets (GM)");
    btnManageAssets.addActionListener(e -> manageAssets());
    btnManageAssets.setEnabled(getCampaign().isGM());
    pnlFinanceBtns.add(btnManageAssets);

    panelFinanceRight.add(pnlFinanceBtns, BorderLayout.NORTH);

    areaNetWorth = new JTextArea();
    areaNetWorth.setLineWrap(true);
    areaNetWorth.setWrapStyleWord(true);
    areaNetWorth.setFont(new Font("Courier New", Font.PLAIN, 12));
    areaNetWorth.setText(getCampaign().getFinancialReport());
    areaNetWorth.setEditable(false);

    JScrollPane descriptionScroll = new JScrollPane(areaNetWorth);
    panelFinanceRight.add(descriptionScroll, BorderLayout.CENTER);
    areaNetWorth.setCaretPosition(0);
    descriptionScroll.setMinimumSize(new Dimension(300, 200));

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 0.0;
    gridBagConstraints.weighty = 1.0;
    add(panelFinanceRight, gridBagConstraints);
}

From source file:TreeLayoutDemo.java

public TreeLayoutDemo() {

    // create a simple graph for the demo
    graph = new DelegateForest<String, Integer>();

    createTree();/*  ww  w  . j  a  va2 s . c  om*/

    treeLayout = new TreeLayout<String, Integer>(graph);
    radialLayout = new RadialTreeLayout<String, Integer>(graph);
    radialLayout.setSize(new Dimension(600, 600));
    vv = new VisualizationViewer<String, Integer>(treeLayout, new Dimension(600, 600));
    vv.setBackground(Color.white);
    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller());
    vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));
    rings = new Rings();

    Container content = getContentPane();
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel);

    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    vv.setGraphMouse(graphMouse);

    JComboBox modeBox = graphMouse.getModeComboBox();
    modeBox.addItemListener(graphMouse.getModeListener());
    graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JToggleButton radial = new JToggleButton("Radial");
    radial.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {

                LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, treeLayout,
                        radialLayout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.addPreRenderPaintable(rings);
            } else {
                LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, radialLayout,
                        treeLayout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.removePreRenderPaintable(rings);
            }
            vv.repaint();
        }
    });

    JPanel scaleGrid = new JPanel(new GridLayout(1, 0));
    scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));

    JPanel controls = new JPanel();
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(radial);
    controls.add(scaleGrid);
    controls.add(modeBox);

    content.add(controls, BorderLayout.SOUTH);
}

From source file:com.floreantpos.ui.views.order.modifier.TicketItemModifierTableView.java

private JPanel createItemDescriptionPanel() {
    MenuItem menuItem = modifierSelectionModel.getMenuItem();
    JPanel itemDescriptionPanel = new JPanel(new MigLayout("inset 0,center"));
    String description = menuItem.getDescription();
    if (StringUtils.isEmpty(description) && menuItem.getImage() == null) {
        return itemDescriptionPanel;
    }/*  w ww. j a  va2s . c  om*/
    itemDescriptionPanel.setBorder(BorderFactory.createTitledBorder("-"));
    JLabel lblDescription = new JLabel();
    lblDescription.setText("<html><body>" + description + "</body></html>");
    JLabel pictureLabel = new JLabel(menuItem.getImage());

    itemDescriptionPanel.add(pictureLabel);
    itemDescriptionPanel.add(lblDescription);

    return itemDescriptionPanel;
}