Example usage for javax.swing Box createHorizontalGlue

List of usage examples for javax.swing Box createHorizontalGlue

Introduction

In this page you can find the example usage for javax.swing Box createHorizontalGlue.

Prototype

public static Component createHorizontalGlue() 

Source Link

Document

Creates a horizontal glue component.

Usage

From source file:net.technicpack.launcher.ui.InstallerFrame.java

private void initComponents() {
    setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
    setIconImage(resources.getImage("icon.png"));
    setLayout(new BorderLayout());

    JPanel header = new JPanel();
    header.setBackground(Color.black);
    header.setLayout(new BoxLayout(header, BoxLayout.LINE_AXIS));
    header.setBorder(BorderFactory.createEmptyBorder(4, 8, 4, 8));
    add(header, BorderLayout.PAGE_START);

    JLabel title = new JLabel(resources.getString("launcher.installer.title"));
    title.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 34));
    title.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    title.setOpaque(false);//from   w  w  w . j ava  2  s  .c  o m
    title.setIcon(resources.getIcon("options_cog.png"));
    header.add(title);

    header.add(Box.createHorizontalGlue());

    JButton closeButton = new JButton();
    closeButton.setIcon(resources.getIcon("close.png"));
    closeButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    closeButton.setContentAreaFilled(false);
    closeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    closeButton.setFocusPainted(false);
    closeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            mainFrame.setVisible(true);
            dispose();
        }
    });
    header.add(closeButton);

    SimpleTabPane centerPanel = new SimpleTabPane();
    centerPanel.setBackground(LauncherFrame.COLOR_FORMELEMENT_INTERNAL);
    centerPanel.setForeground(LauncherFrame.COLOR_GREY_TEXT);
    centerPanel.setSelectedBackground(LauncherFrame.COLOR_BLUE);
    centerPanel.setSelectedForeground(LauncherFrame.COLOR_WHITE_TEXT);
    centerPanel.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 14));
    centerPanel.setOpaque(true);
    add(centerPanel, BorderLayout.CENTER);

    JPanel standardInstallPanel = new JPanel();
    standardInstallPanel.setBackground(LauncherFrame.COLOR_CENTRAL_BACK_OPAQUE);

    setupStandardInstall(standardInstallPanel);

    JPanel portableModePanel = new JPanel();
    portableModePanel.setBackground(LauncherFrame.COLOR_CENTRAL_BACK_OPAQUE);

    setupPortableMode(portableModePanel);

    centerPanel.addTab(resources.getString("launcher.installer.standard").toUpperCase(), standardInstallPanel);
    centerPanel.addTab(resources.getString("launcher.installer.portable").toUpperCase(), portableModePanel);

    if (settings.isPortable()) {
        centerPanel.setSelectedIndex(1);
    } else
        centerPanel.setSelectedIndex(0);

    setLocationRelativeTo(null);
}

From source file:fungus.JungVisualizer.java

public JungVisualizer(String name) {
    this.name = name;

    showEdges = Configuration.getBoolean(name + "." + PAR_SHOW_EDGES);
    scaleShapes = Configuration.getBoolean(name + "." + PAR_SCALE_SHAPES);
    labelNodes = Configuration.getBoolean(name + "." + PAR_LABEL_NODES);
    imageDir = Configuration.getString(name + "." + PAR_IMAGE_DIR);
    nameFragment = Configuration.getString(PAR_TESTNAME);

    if (vt == null) {
        try {// ww  w.  j  a  va 2  s. c o  m
            Class vtClass = Configuration.getClass(name + "." + PAR_TRANSFORMERS);
            if (VisualizerTransformers.class.isAssignableFrom(vtClass)) {
                vt = (VisualizerTransformers) vtClass.newInstance();
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    graph = JungGraphObserver.getGraph();

    vt.setGraph(graph); // Have to call this manually!

    JungGraphObserver.stepBlocked = true;
    JungGraphObserver.noBlock = false;

    layout = vt.makeLayout(graph);

    Dimension preferredSize = new Dimension(660, 660);
    visualizationModel = new DefaultVisualizationModel<MycoNode, MycoEdge>(layout, preferredSize);

    relaxer = visualizationModel.getRelaxer();

    visualizer = new VisualizationViewer<MycoNode, MycoEdge>(visualizationModel, preferredSize);
    visualizer.addGraphMouseListener(new InfoFrameVertexListener());

    visualizer.setDoubleBuffered(true);

    // final Color under50VertexColor = Color.BLACK;
    // final Stroke under50VertexStroke = new BasicStroke(1.0f,
    //                                                    BasicStroke.CAP_BUTT,
    //                                                    BasicStroke.JOIN_MITER);
    // final Color over50VertexColor = Color.MAGENTA;
    // final Stroke over50VertexStroke = new BasicStroke(2.0f,
    //                                                   BasicStroke.CAP_BUTT,
    //                                                   BasicStroke.JOIN_MITER);
    // final Color over80VertexColor = Color.BLUE;
    // final Stroke over80VertexStroke = new BasicStroke(2.0f,
    //                                                   BasicStroke.CAP_BUTT,
    //                                                   BasicStroke.JOIN_MITER);
    // final Color over95VertexColor = Color.GREEN;
    // final Stroke over95VertexStroke = new BasicStroke(2.0f,
    //                                                   BasicStroke.CAP_BUTT,
    //                                                   BasicStroke.JOIN_MITER);
    // final Color over100VertexColor = Color.RED;
    // final Stroke over100VertexStroke = new BasicStroke(5.0f,
    //                                                    BasicStroke.CAP_BUTT,
    //                                                    BasicStroke.JOIN_MITER);
    // Transformer<MycoNode,Stroke> nodeStrokeRenderer =
    //     new Transformer<MycoNode, Stroke>() {
    //   public Stroke transform(MycoNode n){
    //     int capacity = n.getHyphaData().getMax();
    //     int attached = n.getHyphaLink().degree();
    //     double ratio = ((double) attached) / ((double) capacity);

    //     if (ratio > 1.0) {
    //       return over100VertexStroke;
    //     } else if (ratio > 0.95) {
    //       return over95VertexStroke;
    //     } else if (ratio > 0.80) {
    //       return over80VertexStroke;
    //     } else if (ratio > 0.50) {
    //       return over50VertexStroke;
    //     } else {
    //       return under50VertexStroke;
    //     }
    //   }
    // };
    // Transformer<MycoNode,Paint> nodeOutlineRenderer =
    //     new Transformer<MycoNode, Paint>() {
    //   public Paint transform(MycoNode n) {
    //     int capacity = n.getHyphaData().getMax();
    //     int attached = n.getHyphaLink().degree();
    //     double ratio = ((double) attached) / ((double) capacity);

    //     if (ratio > 1.0) {
    //       return over100VertexColor;
    //     } else if (ratio > 0.95) {
    //       return over95VertexColor;
    //     } else if (ratio > 0.80) {
    //       return over80VertexColor;
    //     } else if (ratio > 0.50) {
    //       return over50VertexColor;
    //     } else {
    //       return under50VertexColor;
    //     }
    //   }
    // };

    /*Transformer<MycoNode,Paint> nodeFillRenderer = new Transformer<MycoNode,Paint>() {
      public Paint transform(MycoNode n) {
      HyphaData data = n.getHyphaData();
      if (!n.isUp()) { return Color.BLACK; }
      if (data.isBiomass()) { return Color.BLUE; }
      else if (data.isExtending()) { return Color.RED; }
      else if (data.isBranching()) { return Color.YELLOW; }
      else { return Color.GREEN; }
      }
      };*/

    /*Transformer<MycoNode,Paint> nodeFillRenderer = new Transformer<MycoNode,Paint>() {
      public Paint transform(MycoNode n) {
      HyphaData data = n.getHyphaData();
      if (data.isBiomass()) { return Color.BLUE; }
      else if (data.isExtending()) { return Color.RED; }
      else if (data.isBranching()) { return Color.YELLOW; }
      else { return Color.GREEN; }
      }
      };*/

    final Color transparent = new Color(0, 0, 0, 0);

    Transformer<MycoEdge, Paint> transparentEdges = new Transformer<MycoEdge, Paint>() {
        public Paint transform(MycoEdge e) {
            return transparent;
        }
    };

    visualizer.setBackground(Color.WHITE);

    visualizer.getRenderContext().setVertexFillPaintTransformer(vt.getNodeFillRenderer());
    visualizer.getRenderContext().setVertexShapeTransformer(vt.getShapeTransformer(scaleShapes));
    if (labelNodes) {
        visualizer.getRenderContext().setVertexLabelTransformer(vt.getNodeLabeller());
    }
    visualizer.getRenderContext().setVertexStrokeTransformer(vt.getVertexStrokeTransformer());
    visualizer.getRenderContext().setVertexDrawPaintTransformer(vt.getVertexDrawPaintTransformer());
    //visualizer.setVertexToolTipTransformer(new ToStringLabeller());

    if (showEdges) {
        visualizer.getRenderContext().setEdgeStrokeTransformer(vt.getEdgeStrokeTransformer());
        visualizer.getRenderContext().setEdgeDrawPaintTransformer(vt.getEdgeDrawPaintTransformer());
        visualizer.getRenderContext().setArrowDrawPaintTransformer(vt.getEdgeDrawPaintTransformer());
        visualizer.getRenderContext().setArrowFillPaintTransformer(vt.getEdgeDrawPaintTransformer());
    } else {
        visualizer.getRenderContext().setEdgeDrawPaintTransformer(transparentEdges);
        visualizer.getRenderContext().setArrowDrawPaintTransformer(transparentEdges);
        visualizer.getRenderContext().setArrowFillPaintTransformer(transparentEdges);
    }

    frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Container c = frame.getContentPane();
    c.setLayout(new BoxLayout(c, BoxLayout.Y_AXIS));

    //JScrollPane scrollPane = new JScrollPane(visualizer);
    //c.add(scrollPane);
    c.add(visualizer);

    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS));

    final JButton captureButton = new JButton("capture");
    ActionListener capturer = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            saveAsPNG();
        }
    };
    captureButton.addActionListener(capturer);

    final JButton freezeButton = new JButton("freeze");
    ActionListener freezer = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (freezeButton.getText().equals("freeze")) {
                relaxer.pause();
                freezeButton.setText("unfreeze");
            } else {
                relaxer.resume();
                freezeButton.setText("freeze");
            }
        }
    };
    freezeButton.addActionListener(freezer);

    JButton pauseButton = new JButton("pause");
    ActionListener pauser = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //e.consume();
            JungGraphObserver.pauseAction();
        }
    };
    pauseButton.addActionListener(pauser);

    JButton stepButton = new JButton("step");
    ActionListener stepper = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("Clicked!\n");
            //e.consume();
            JungGraphObserver.stepAction();
        }
    };
    stepButton.addActionListener(stepper);

    JButton walkButton = new JButton("walk");
    ActionListener walker = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("Clicked!\n");
            //e.consume();
            JungGraphObserver.walkAction();
        }
    };
    walkButton.addActionListener(walker);

    JButton runButton = new JButton("run");
    ActionListener runner = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //e.consume();
            JungGraphObserver.runAction();
        }
    };
    runButton.addActionListener(runner);

    roundField = new JTextField("0");

    buttonPane.add(freezeButton);
    buttonPane.add(captureButton);
    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(pauseButton);
    buttonPane.add(stepButton);
    buttonPane.add(walkButton);
    buttonPane.add(runButton);
    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(roundField);
    c.add(buttonPane);

    frame.pack();
    frame.setVisible(true);

    JungGraphObserver.setVisualizer(visualizer);
}

From source file:utybo.branchingstorytree.swing.OpenBSTGUI.java

public OpenBSTGUI() {
    instance = this;
    UIManager.put("OptionPane.errorIcon", new ImageIcon(Icons.getImage("Cancel", 48)));
    UIManager.put("OptionPane.informationIcon", new ImageIcon(Icons.getImage("About", 48)));
    UIManager.put("OptionPane.questionIcon", new ImageIcon(Icons.getImage("Rename", 48)));
    UIManager.put("OptionPane.warningIcon", new ImageIcon(Icons.getImage("Error", 48)));

    BorderLayout borderLayout = new BorderLayout();
    borderLayout.setVgap(4);// w w w .j  a  va 2 s. co m
    getContentPane().setLayout(borderLayout);
    setIconImage(Icons.getImage("Logo", 48));
    setTitle("OpenBST " + OpenBST.VERSION);
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            boolean cancelled = false;
            int i = 0;
            for (Component c : container.getComponents()) {
                if (c instanceof StoryPanel) {
                    i++;
                } else if (c instanceof StoryEditor) {
                    container.setSelectedComponent(c);
                    if (((StoryEditor) c).askClose()) {
                        continue;
                    } else {
                        cancelled = true;
                        break;
                    }
                }
            }
            if (!cancelled) {
                if (i > 0) {
                    int j = Messagers.showConfirm(OpenBSTGUI.this,
                            "You are about to close " + i + " file(s). Are you sure you wish to exit OpenBST?",
                            Messagers.OPTIONS_YES_NO, Messagers.TYPE_WARNING, "Closing OpenBST");
                    if (j != Messagers.OPTION_YES)
                        cancelled = true;
                }
                if (!cancelled)
                    System.exit(0);
            }
        }

    });

    JMenuBar jmb = new JMenuBar();
    jmb.setBackground(OPENBST_BLUE);
    jmb.add(Box.createHorizontalGlue());
    jmb.add(createShortMenu());
    jmb.add(Box.createHorizontalGlue());
    this.setJMenuBar(jmb);

    addDarkModeCallback(b -> {
        jmb.setBackground(b ? OPENBST_BLUE.darker().darker() : OPENBST_BLUE);
    });

    container = new JTabbedPane();
    container.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    container.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(final MouseEvent e) {
            if (SwingUtilities.isMiddleMouseButton(e)) {
                final int i = container.indexAtLocation(e.getX(), e.getY());
                System.out.println(i);
                if (i > -1) {
                    Component c = container.getComponentAt(i);
                    if (c instanceof StoryPanel) {
                        container.setSelectedComponent(c);
                        ((StoryPanel) c).askClose();
                    } else if (c instanceof StoryEditor) {
                        container.setSelectedComponent(c);
                        ((StoryEditor) c).askClose();
                    }
                }
            }
        }
    });
    getContentPane().add(container, BorderLayout.CENTER);

    final JBackgroundPanel welcomeContentPanel = new JBackgroundPanel(Icons.getRandomBackground(),
            Image.SCALE_FAST);
    background = welcomeContentPanel;

    welcomeContentPanel.setLayout(new MigLayout("hidemode 2", "[grow,center]", "[][grow][]"));
    container.add(welcomeContentPanel);
    container.setTitleAt(0, Lang.get("welcome"));

    bannersPanel = new JPanel(new MigLayout("hidemode 2, gap 0px, fill, wrap 1, ins 0"));
    bannersPanel.setBackground(new Color(0, 0, 0, 0));
    welcomeContentPanel.add(bannersPanel, "cell 0 0,grow");

    if (OpenBST.VERSION.endsWith("u")) {
        JButton btnReportBugs = new JButton(Lang.get("welcome.reportbugs"));
        btnReportBugs.addActionListener(e -> {
            VisualsUtils.browse("https://github.com/utybo/BST/issues");
        });
        bannersPanel.add(new JBannerPanel(new ImageIcon(Icons.getImage("Experiment", 32)), Color.YELLOW,
                Lang.get("welcome.ontheedge"), btnReportBugs, false), "grow");
    } else if (OpenBST.VERSION.contains("SNAPSHOT")) {
        bannersPanel.add(new JBannerPanel(new ImageIcon(Icons.getImage("Experiment", 32)), Color.ORANGE,
                Lang.get("welcome.snapshot"), null, false), "grow");
    }

    if (System.getProperty("java.specification.version").equals("9")) {
        bannersPanel.add(new JBannerPanel(new ImageIcon(Icons.getImage("Attention", 32)),
                new Color(255, 50, 50), Lang.get("welcome.java9warning"), null, false), "grow");
    }
    if (System.getProperty("java.specification.version").equals("10")) {
        bannersPanel.add(new JBannerPanel(new ImageIcon(Icons.getImage("Attention", 32)),
                new Color(255, 50, 50), Lang.get("welcome.java10warning"), null, false), "grow");
    }

    JButton btnJoinDiscord = new JButton(Lang.get("openbst.discordjoin"));
    btnJoinDiscord.addActionListener(e -> {
        VisualsUtils.browse("https://discord.gg/6SVDCMM");
    });
    bannersPanel.add(new JBannerPanel(new ImageIcon(Icons.getImage("Discord", 48)), DISCORD_COLOR,
            Lang.get("openbst.discord"), btnJoinDiscord, true), "grow");

    JPanel panel = new JPanel();
    panel.setBackground(new Color(0, 0, 0, 0));
    welcomeContentPanel.add(panel, "flowx,cell 0 1,growx,aligny center");
    panel.setLayout(new MigLayout("", "[40%][][][][60%,growprio 50]", "[][grow]"));

    final JLabel lblOpenbst = new JLabel(new ImageIcon(Icons.getImage("FullLogo", 48)));
    addDarkModeCallback(b -> lblOpenbst
            .setIcon(new ImageIcon(b ? Icons.getImage("FullLogoWhite", 48) : Icons.getImage("FullLogo", 48))));
    panel.add(lblOpenbst, "flowx,cell 0 0 1 2,alignx trailing,aligny center");

    JSeparator separator = new JSeparator();
    separator.setOrientation(SwingConstants.VERTICAL);
    panel.add(separator, "cell 2 0 1 2,growy");

    final JLabel lblWelcomeToOpenbst = new JLabel("<html>" + Lang.get("welcome.intro"));
    lblWelcomeToOpenbst.setMaximumSize(new Dimension(350, 999999));
    panel.add(lblWelcomeToOpenbst, "cell 4 0");

    Component horizontalStrut = Box.createHorizontalStrut(10);
    panel.add(horizontalStrut, "cell 1 1");

    Component horizontalStrut_1 = Box.createHorizontalStrut(10);
    panel.add(horizontalStrut_1, "cell 3 1");

    final JButton btnOpenAFile = new JButton(Lang.get("welcome.open"));
    panel.add(btnOpenAFile, "flowx,cell 4 1");
    btnOpenAFile.setIcon(new ImageIcon(Icons.getImage("Open", 40)));
    btnOpenAFile.addActionListener(e -> {
        openStory(VisualsUtils.askForFile(this, Lang.get("file.title")));
    });

    final JButton btnOpenEditor = new JButton(Lang.get("welcome.openeditor"));
    panel.add(btnOpenEditor, "cell 4 1");
    btnOpenEditor.setIcon(new ImageIcon(Icons.getImage("Edit Property", 40)));
    btnOpenEditor.addActionListener(e -> {
        openEditor(VisualsUtils.askForFile(this, Lang.get("file.title")));
    });

    JButton btnChangeBackground = new JButton(Lang.get("welcome.changebackground"),
            new ImageIcon(Icons.getImage("Change Theme", 16)));
    btnChangeBackground.addActionListener(e -> {
        BufferedImage prev = background.getImage();
        BufferedImage next;
        do {
            next = Icons.getRandomBackground();
        } while (prev == next);
        background.setImage(next);
    });
    welcomeContentPanel.add(btnChangeBackground, "flowx,cell 0 2,alignx left");

    JButton btnWelcomepixabay = new JButton(Lang.get("welcome.pixabay"),
            new ImageIcon(Icons.getImage("External Link", 16)));
    btnWelcomepixabay.addActionListener(e -> {
        VisualsUtils.browse("https://pixabay.com");

    });
    welcomeContentPanel.add(btnWelcomepixabay, "cell 0 2");

    JLabel creds = new JLabel(Lang.get("welcome.credits"));
    creds.setEnabled(false);
    welcomeContentPanel.add(creds, "cell 0 2, gapbefore 10px");

    setSize((int) (830 * Icons.getScale()), (int) (480 * Icons.getScale()));
    setLocationRelativeTo(null);
}

From source file:org.ut.biolab.medsavant.client.view.component.SearchableTablePanel.java

public SearchableTablePanel(String pageName, String[] columnNames, Class[] columnClasses, int[] hiddenColumns,
        boolean allowSearch, boolean allowSort, int defaultRows, boolean allowPages,
        TableSelectionType selectionType, int defaultRowsRetrieved, DataRetriever<Object[]> retriever) {

    this.pageName = pageName;
    this.rowsPerPageX = defaultRows;
    this.defaultRowsRetrieved = defaultRowsRetrieved;

    this.retriever = retriever;
    this.hiddenColumns = hiddenColumns;
    table = new SortableTable() {
        @Override/* w  w w . j av a  2  s . c  o m*/
        public Component prepareRenderer(TableCellRenderer renderer, int row, int col) {
            synchronized (SearchableTablePanel.this) {
                JComponent comp = (JComponent) super.prepareRenderer(renderer, row, col);

                // Even index, selected or not selected
                if (isRowToggled(TableModelWrapperUtils.getActualRowAt(this.getSortableTableModel(), row))) { //this.getActualRowAt(this.getSortedRowAt(row)))) {
                    comp.setBackground(new Color(178, 225, 92));
                } else if (isCellSelected(row, col)) {
                    //comp.setBackground(new Color(75, 149, 229));
                    comp.setBackground(SELECTED_COLOUR);
                } else if (selectedRows != null
                        && selectedRows.contains(TableModelWrapperUtils.getActualRowAt(getModel(), row))) {
                    //comp.setBackground(SELECTED_COLOUR);
                } else if (row % 2 == 0 && !isCellSelected(row, col)) {
                    comp.setBackground(Color.WHITE);
                } else {
                    comp.setBackground(DARK_COLOUR);
                }

                comp.setBorder(BorderFactory.createEmptyBorder(0, 7, 0, 7));
                return comp;
            }
        }

        @Override
        public String getToolTipText(MouseEvent e) {
            return getToolTip(
                    TableModelWrapperUtils.getActualRowAt(table.getModel(), table.rowAtPoint(e.getPoint())));
        }
    };

    table.setToolTipText(""); //necessary to force check for tooltip text

    table.setClearSelectionOnTableDataChanges(true);
    table.setOptimized(true);
    table.setColumnAutoResizable(true);
    table.setAutoResort(false);
    table.setRowHeight(20);
    table.setSortable(allowSort);
    table.setSortingEnabled(allowSort);
    table.setFocusable(selectionType != TableSelectionType.DISABLED);
    //table.setCellSelectionEnabled(allowSelection);
    table.setCellSelectionEnabled(selectionType == TableSelectionType.CELL);
    table.setRowSelectionAllowed(selectionType == TableSelectionType.ROW);

    table.setAutoResizeMode(SortableTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);

    //column chooser
    TableHeaderPopupMenuInstaller installer = new TableHeaderPopupMenuInstaller(table);
    installer.addTableHeaderPopupMenuCustomizer(new AutoResizePopupMenuCustomizer());
    columnChooser = new ColumnChooser(table);
    installer.addTableHeaderPopupMenuCustomizer(columnChooser);

    AutoFilterTableHeader header = new AutoFilterTableHeader(table);
    header.setAutoFilterEnabled(true);
    header.setShowFilterIcon(true);
    header.setShowFilterName(true);
    table.setTableHeader(header);

    filterField = new QuickTableFilterField(model);

    if (allowPages) {
        filterField.setHintText("Search for anything on the page");
    } else {
        filterField.setHintText("Search for anything");
    }

    setLayout(new BorderLayout(3, 3));
    fieldPanel = ViewUtil.getClearPanel();

    if (allowSearch) {
        fieldPanel.add(filterField);
    }

    chooseColumnButton = new JButton("Columns");
    chooseColumnButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            columnChooser.showDialog();
        }
    });

    helpButton = ViewUtil.getHelpButton("About Variant List",
            "Variants are sorted first by DNA ID, then by position.  The list of variants within each page can be sorted by various fields by clicking the corresponding column name, but note that this will only sort the current page.");
    exportButton = new JButton("Export");
    exportButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            try {
                ExportTable.exportTable(table);
            } catch (Exception ex) {
                LOG.error("Error while exporting.", ex);
                DialogUtils.displayException("MedSavant",
                        "<HTML>A problem occurred while exporting.<BR>Make sure the output file is not already in use.</HTML>",
                        ex);
            }
        }
    });

    fieldPanel.add(helpButton);
    fieldPanel.add(chooseColumnButton);
    fieldPanel.add(exportButton);

    bottomPanel = ViewUtil.getClearPanel();
    bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.X_AXIS));

    gotoFirst = niceButton();
    gotoPrevious = niceButton();
    gotoNext = niceButton();
    gotoLast = niceButton();

    gotoFirst.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.FIRST));
    gotoPrevious.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.PREVIOUS));
    gotoNext.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.NEXT));
    gotoLast.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.LAST));

    gotoFirst.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            goToFirstPage();
        }
    });
    gotoPrevious.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            goToPreviousPage();
        }
    });
    gotoNext.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            goToNextPage();
        }
    });
    gotoLast.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            goToLastPage();
        }
    });

    pageText = new JTextField();
    ViewUtil.makeSmall(pageText);
    pageText.setColumns(5);
    pageText.setMaximumSize(new Dimension(50, 20));
    pageText.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            int key = e.getKeyCode();
            if (key == KeyEvent.VK_ENTER) {
                try {
                    setPageNumber(Integer.parseInt(pageText.getText()));
                } catch (NumberFormatException ex) {
                    setPageNumber(0);
                }
            }
        }
    });

    amountLabel = new JLabel();
    ViewUtil.makeSmall(amountLabel);
    bottomPanel.add(amountLabel);

    pageLabel1 = new JLabel("Page ");
    ViewUtil.makeSmall(pageLabel1);
    pageLabel2 = new JLabel();
    ViewUtil.makeSmall(pageLabel2);

    bottomPanel.add(Box.createHorizontalGlue());
    bottomPanel.add(gotoFirst);
    bottomPanel.add(gotoPrevious);
    strut(bottomPanel);
    bottomPanel.add(pageLabel1);
    bottomPanel.add(pageText);
    bottomPanel.add(pageLabel2);
    strut(bottomPanel);
    bottomPanel.add(gotoNext);
    bottomPanel.add(gotoLast);
    bottomPanel.add(Box.createHorizontalGlue());

    strut(bottomPanel);

    JLabel perpageL = new JLabel("Per page:");
    ViewUtil.makeSmall(perpageL);
    bottomPanel.add(perpageL);

    strut(bottomPanel);

    boolean hasDefaultRowsPerPage = true;
    if (rowsPerPageX == ROWSPERPAGE_1 || rowsPerPageX == ROWSPERPAGE_2 || rowsPerPageX == ROWSPERPAGE_3) {
        hasDefaultRowsPerPage = false;
    }
    ArrayList<Integer> rowsList = new ArrayList<Integer>();
    rowsList.add(ROWSPERPAGE_1);
    rowsList.add(ROWSPERPAGE_2);
    rowsList.add(ROWSPERPAGE_3);
    Integer[] finalList = new Integer[3];
    if (hasDefaultRowsPerPage) {
        rowsList.add(rowsPerPageX);
        Collections.sort(rowsList);
    }
    finalList = rowsList.toArray(finalList);

    rowsPerPageDropdown = new JComboBox(finalList);
    ViewUtil.makeSmall(rowsPerPageDropdown);
    rowsPerPageDropdown.setPrototypeDisplayValue(ROWSPERPAGE_3);
    if (hasDefaultRowsPerPage) {
        rowsPerPageDropdown.setSelectedIndex(rowsList.indexOf(rowsPerPageX));
    } else {
        rowsPerPageDropdown.setSelectedIndex(1);
    }
    rowsPerPageDropdown.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JComboBox cb = (JComboBox) e.getSource();
            int rowsPerPage = (Integer) cb.getSelectedItem();
            setNumRowsPerPage(rowsPerPage);
        }
    });
    rowsPerPageDropdown.setPreferredSize(new Dimension(100, 25));
    rowsPerPageDropdown.setMaximumSize(new Dimension(100, 25));
    bottomPanel.add(rowsPerPageDropdown);

    setTableModel(data, columnNames, columnClasses);

    JPanel tablePanel = new JPanel(new BorderLayout(3, 3));
    JScrollPane jsp = new JScrollPane(table);
    jsp.setBorder(null);
    tablePanel.add(jsp);

    if (allowSort) {
        add(fieldPanel, BorderLayout.NORTH);
    }

    if (allowPages) {
        add(bottomPanel, BorderLayout.SOUTH);
    }

    add(tablePanel, BorderLayout.CENTER);

    initEmpty();
}

From source file:SoundPlayer.java

void addMidiControls() {
    // Add a slider to control the tempo
    final JSlider tempo = new JSlider(50, 200);
    tempo.setValue((int) (sequencer.getTempoFactor() * 100));
    tempo.setBorder(new TitledBorder("Tempo Adjustment (%)"));
    java.util.Hashtable labels = new java.util.Hashtable();
    labels.put(new Integer(50), new JLabel("50%"));
    labels.put(new Integer(100), new JLabel("100%"));
    labels.put(new Integer(200), new JLabel("200%"));
    tempo.setLabelTable(labels);/*from   ww  w .  j a v  a  2s .c o m*/
    tempo.setPaintLabels(true);
    // The event listener actually changes the tmpo
    tempo.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            sequencer.setTempoFactor(tempo.getValue() / 100.0f);
        }
    });

    this.add(tempo);

    // Create rows of solo and checkboxes for each track
    Track[] tracks = sequence.getTracks();
    for (int i = 0; i < tracks.length; i++) {
        final int tracknum = i;
        // Two checkboxes per track
        final JCheckBox solo = new JCheckBox("solo");
        final JCheckBox mute = new JCheckBox("mute");
        // The listeners solo or mute the track
        solo.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                sequencer.setTrackSolo(tracknum, solo.isSelected());
            }
        });
        mute.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                sequencer.setTrackMute(tracknum, mute.isSelected());
            }
        });

        // Build up a row
        Box box = Box.createHorizontalBox();
        box.add(new JLabel("Track " + tracknum));
        box.add(Box.createHorizontalStrut(10));
        box.add(solo);
        box.add(Box.createHorizontalStrut(10));
        box.add(mute);
        box.add(Box.createHorizontalGlue());
        // And add it to this component
        this.add(box);
    }
}

From source file:ro.nextreports.designer.datasource.ConnectionDialog.java

private void create() {
    this.getContentPane().setLayout(new GridBagLayout());
    this.addComponentListener(new ComponentAdapter() {
        public void componentResized(ComponentEvent e) {
            resize();//from   ww  w .  ja va2s  .c  o  m
        }
    });

    JPanel p = new JPanel(new GridBagLayout());
    backColor = p.getBackground();

    mName = new JTextField();
    mDriver = new JTextField();
    //mDriver.setBackground(backColor);
    mURL = new JTextField();
    //mURL.setBackground(backColor);
    mUser = new JTextField();
    //mUser.setBackground(backColor);
    mPassword = new JPasswordField();
    mPassword.setEchoChar('*');
    //mPassword.setBackground(backColor);
    txaStatus = new JTextArea();
    txaStatus.setEditable(false);
    txaStatus.setBackground(backColor);
    scr = new JScrollPane(txaStatus);
    scr.setSize(220, 50);
    scr.setBorder(new TitledBorder(STATUS));
    types = new JComboBox();
    types.addItemListener(this);

    urlFormatLabel = new JLabel();
    Font font = urlFormatLabel.getFont().deriveFont(Font.BOLD, 10);
    urlFormatLabel.setFont(font);

    urlButton = new JButton();
    urlButton.setPreferredSize(buttonDim);
    urlButton.setMinimumSize(buttonDim);
    urlButton.setMaximumSize(buttonDim);
    urlButton.setIcon(ImageUtil.getImageIcon("url_edit"));
    urlButton.setToolTipText(I18NSupport.getString("connection.dialog.tags.tooltip"));
    urlButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            editUrl();
        }
    });

    for (DriverTemplate template : templates) {
        types.addItem(template.getType());
    }
    types.setSelectedItem(DEFAULT_DRIVER_TYPE);

    auto = new JCheckBox(I18NSupport.getString("connection.dialog.auto"));

    if (viewOnly) {
        mName.setEditable(false);
        types.setEnabled(false);
        mDriver.setEditable(false);
        mURL.setEditable(false);
        mUser.setEditable(false);
        mPassword.setEditable(false);
        urlButton.setEnabled(false);
    }

    p.add(new JLabel(I18NSupport.getString("connection.dialog.name")), new GridBagConstraints(0, 0, 1, 1, 0.0,
            0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
    p.add(mName, new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    p.add(new JLabel(I18NSupport.getString("connection.dialog.type")), new GridBagConstraints(0, 1, 1, 1, 0.0,
            0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
    p.add(types, new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    p.add(new JLabel(I18NSupport.getString("connection.dialog.driver")), new GridBagConstraints(0, 2, 1, 1, 0.0,
            0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
    p.add(mDriver, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    p.add(new JLabel(I18NSupport.getString("connection.dialog.url")), new GridBagConstraints(0, 3, 1, 1, 0.0,
            0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
    p.add(mURL, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 0), 0, 0));
    p.add(urlButton, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));

    if (!viewOnly) {
        p.add(urlFormatLabel, new GridBagConstraints(1, 4, 2, 1, 1.0, 0.0, GridBagConstraints.WEST,
                GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0));
    }

    p.add(new JLabel(I18NSupport.getString("connection.dialog.user")), new GridBagConstraints(0, 5, 1, 1, 0.0,
            0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
    p.add(mUser, new GridBagConstraints(1, 5, 2, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    p.add(new JLabel(I18NSupport.getString("connection.dialog.password")), new GridBagConstraints(0, 6, 1, 1,
            0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
    p.add(mPassword, new GridBagConstraints(1, 6, 2, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));

    if (!viewOnly) {
        p.add(auto, new GridBagConstraints(1, 7, 2, 1, 1.0, 0.0, GridBagConstraints.WEST,
                GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    }

    JButton okBtn, disBtn, drvBtn, addBtn, propBtn;
    okBtn = new JButton(I18NSupport.getString("connection.dialog.test"),
            ImageUtil.getImageIcon("database_connect"));
    okBtn.setMnemonic('T');
    okBtn.setActionCommand("ConnectOk");
    okBtn.setToolTipText(I18NSupport.getString("connection.dialog.test.tooltip"));
    okBtn.addActionListener(this);
    disBtn = new JButton(I18NSupport.getString("connection.dialog.disconnect"),
            ImageUtil.getImageIcon("database"));
    disBtn.setMnemonic('D');
    disBtn.setActionCommand("Disconnect");
    disBtn.setToolTipText(I18NSupport.getString("connection.dialog.disconnect"));
    disBtn.addActionListener(this);
    drvBtn = new JButton(I18NSupport.getString("connection.dialog.add.driver"),
            ImageUtil.getImageIcon("add_driver"));
    drvBtn.setMnemonic('A');
    drvBtn.setActionCommand("AddDriver");
    drvBtn.setToolTipText(I18NSupport.getString("connection.dialog.add.driver.tooltip"));
    drvBtn.addActionListener(this);
    propBtn = new JButton(I18NSupport.getString("connection.dialog.properties"),
            ImageUtil.getImageIcon("properties"));
    propBtn.setMnemonic('P');
    propBtn.setActionCommand("Properties");
    propBtn.setToolTipText(I18NSupport.getString("connection.dialog.properties.tooltip"));
    propBtn.addActionListener(this);
    addBtn = new JButton(ImageUtil.getImageIcon("database_export"));
    if (oldDataSource == null) {
        addBtn.setText(I18NSupport.getString("connection.dialog.save"));
        addBtn.setToolTipText(I18NSupport.getString("connection.dialog.save.tooltip"));
        addBtn.setMnemonic('S');
    } else {
        addBtn.setText(I18NSupport.getString("connection.dialog.modify"));
        addBtn.setToolTipText(I18NSupport.getString("connection.dialog.modify.tooltip"));
        addBtn.setMnemonic('M');
    }
    addBtn.setActionCommand("AddDataSource");
    addBtn.addActionListener(this);
    JPanel btnPanel = new JPanel();
    btnPanel.setLayout(new BoxLayout(btnPanel, BoxLayout.X_AXIS));
    btnPanel.add(Box.createHorizontalGlue());
    btnPanel.add(propBtn);
    btnPanel.add(Box.createRigidArea(new Dimension(5, 5)));
    btnPanel.add(okBtn);
    btnPanel.add(Box.createRigidArea(new Dimension(5, 5)));
    //btnPanel.add(disBtn);
    //btnPanel.add(Box.createRigidArea(new Dimension(5, 5)));
    btnPanel.add(addBtn);
    //        btnPanel.add(Box.createRigidArea(new Dimension(5, 5)));
    //        btnPanel.add(drvBtn);
    SwingUtil.equalizeButtonSizes(btnPanel);

    if (!viewOnly) {
        p.add(btnPanel, new GridBagConstraints(0, 8, 3, 1, 1.0, 0.0, GridBagConstraints.EAST,
                GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
        p.add(scr, new GridBagConstraints(0, 9, 3, 1, 1.0, 1.0, GridBagConstraints.EAST,
                GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
    }

    this.getContentPane().add(p, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
            GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));

    if (oldDataSource != null) {
        mName.setText(oldDataSource.getName());
        types.setSelectedItem(oldDataSource.getType());
        mDriver.setText(oldDataSource.getDriver());
        mURL.setText(oldDataSource.getUrl());
        mUser.setText(oldDataSource.getUser());
        mPassword.setText(oldDataSource.getPassword());
    }
}

From source file:uk.nhs.cfh.dsp.yasb.searchpanel.SearchPanel.java

/**
 * Creates the button panel./*  w w w .  j  a  v  a  2 s .c  o m*/
 */
private void createButtonPanel() {

    buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.PAGE_AXIS));

    JPanel fieldsPanel = new JPanel();
    fieldsPanel.add(new JLabel("Search using "));
    fieldsPanel.add(Box.createHorizontalStrut(5));
    fieldsPanel.setLayout(new BoxLayout(fieldsPanel, BoxLayout.LINE_AXIS));
    // create button group for term selection
    JRadioButton allRadioButton = new JRadioButton(new AbstractAction("Term") {

        public void actionPerformed(ActionEvent event) {
            // set search on term
            searchConceptId = false;
            doSearch();
        }
    });

    JRadioButton idRadioButton = new JRadioButton(new AbstractAction("ID") {

        public void actionPerformed(ActionEvent event) {
            // set search on id
            searchConceptId = true;
            doSearch();
        }
    });

    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(allRadioButton);
    buttonGroup.add(idRadioButton);
    buttonGroup.setSelected(allRadioButton.getModel(), true);

    // add search field terms to fields panel
    fieldsPanel.add(allRadioButton);
    fieldsPanel.add(idRadioButton);
    fieldsPanel.add(Box.createHorizontalGlue());

    // create panel that contains button that toggles display of controlsPane
    JideButton controlsButton = new JideButton(new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (controlsPane.isCollapsed()) {
                controlsPane.setCollapsed(false);
            } else {
                controlsPane.setCollapsed(true);
            }
        }
    });
    controlsButton.setIcon(new ImageIcon(SearchPanel.class.getResource("resources/configure.png")));
    controlsButton.setToolTipText("Click to display or hide configuration panel");
    JPanel panel4 = new JPanel();
    panel4.setLayout(new BoxLayout(panel4, BoxLayout.LINE_AXIS));
    panel4.add(Box.createHorizontalGlue());
    panel4.add(new JLabel("Change search and display preferences "));
    panel4.add(controlsButton);

    // add panels to button panel
    buttonsPanel.add(fieldsPanel);
    buttonsPanel.add(panel4);
}

From source file:ca.uhn.hl7v2.testpanel.ui.editor.Hl7V2MessageEditorPanel.java

/**
 * Create the panel./*from w ww .j  ava 2  s . c  o  m*/
 */
public Hl7V2MessageEditorPanel(final Controller theController) {
    setBorder(null);
    myController = theController;

    ButtonGroup encGrp = new ButtonGroup();
    setLayout(new BorderLayout(0, 0));

    mysplitPane = new JSplitPane();
    mysplitPane.setResizeWeight(0.5);
    mysplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    add(mysplitPane);

    mysplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent theEvt) {
            double ratio = (double) mysplitPane.getDividerLocation() / mysplitPane.getHeight();
            ourLog.debug("Resizing split to ratio: {}", ratio);
            Prefs.getInstance().setHl7EditorSplit(ratio);
        }
    });

    EventQueue.invokeLater(new Runnable() {
        public void run() {
            mysplitPane.setDividerLocation(Prefs.getInstance().getHl7EditorSplit());
        }
    });

    messageEditorContainerPanel = new JPanel();
    messageEditorContainerPanel.setBorder(null);
    mysplitPane.setRightComponent(messageEditorContainerPanel);
    messageEditorContainerPanel.setLayout(new BorderLayout(0, 0));

    myMessageEditor = new JEditorPane();
    Highlighter h = new UnderlineHighlighter();
    myMessageEditor.setHighlighter(h);
    // myMessageEditor.setFont(Prefs.getHl7EditorFont());
    myMessageEditor.setSelectedTextColor(Color.black);

    myMessageEditor.setCaret(new EditorCaret());

    myMessageScrollPane = new JScrollPane(myMessageEditor);
    messageEditorContainerPanel.add(myMessageScrollPane);

    JToolBar toolBar = new JToolBar();
    messageEditorContainerPanel.add(toolBar, BorderLayout.NORTH);
    toolBar.setFloatable(false);
    toolBar.setRollover(true);

    myFollowToggle = new JToggleButton("Follow");
    myFollowToggle.setToolTipText("Keep the message tree (above) and the message editor (below) in sync");
    myFollowToggle.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            theController.setMessageEditorInFollowMode(myFollowToggle.isSelected());
        }
    });
    myFollowToggle.setIcon(new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/updown.png")));
    myFollowToggle.setSelected(theController.isMessageEditorInFollowMode());
    toolBar.add(myFollowToggle);

    myhorizontalStrut = Box.createHorizontalStrut(20);
    toolBar.add(myhorizontalStrut);

    mylabel_4 = new JLabel("Encoding");
    toolBar.add(mylabel_4);

    myRdbtnEr7 = new JRadioButton("ER7");
    myRdbtnEr7.setMargin(new Insets(1, 2, 0, 1));
    toolBar.add(myRdbtnEr7);

    myRdbtnXml = new JRadioButton("XML");
    myRdbtnXml.setMargin(new Insets(1, 5, 0, 1));
    toolBar.add(myRdbtnXml);
    encGrp.add(myRdbtnEr7);
    encGrp.add(myRdbtnXml);

    treeContainerPanel = new JPanel();
    mysplitPane.setLeftComponent(treeContainerPanel);
    treeContainerPanel.setLayout(new BorderLayout(0, 0));

    mySpinnerIconOn = new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/spinner.gif"));
    mySpinnerIconOff = new ImageIcon();

    myTreePanel = new Hl7V2MessageTree(theController);
    myTreePanel.setWorkingListener(new IWorkingListener() {

        public void startedWorking() {
            mySpinner.setText("");
            mySpinner.setIcon(mySpinnerIconOn);
            mySpinnerIconOn.setImageObserver(mySpinner);
        }

        public void finishedWorking(String theStatus) {
            mySpinner.setText(theStatus);

            mySpinner.setIcon(mySpinnerIconOff);
            mySpinnerIconOn.setImageObserver(null);
        }
    });
    myTreeScrollPane = new JScrollPane(myTreePanel);

    myTopTabBar = new JTabbedPane();
    treeContainerPanel.add(myTopTabBar);
    myTopTabBar.setBorder(null);

    JPanel treeContainer = new JPanel();
    treeContainer.setLayout(new BorderLayout(0, 0));
    treeContainer.add(myTreeScrollPane);

    myTopTabBar.add("Message Tree", treeContainer);

    mytoolBar_1 = new JToolBar();
    mytoolBar_1.setFloatable(false);
    treeContainer.add(mytoolBar_1, BorderLayout.NORTH);

    mylabel_3 = new JLabel("Show");
    mytoolBar_1.add(mylabel_3);

    myShowCombo = new JComboBox();
    mytoolBar_1.add(myShowCombo);
    myShowCombo.setPreferredSize(new Dimension(130, 27));
    myShowCombo.setMinimumSize(new Dimension(130, 27));
    myShowCombo.setMaximumSize(new Dimension(130, 32767));

    collapseAllButton = new JButton();
    collapseAllButton.setBorderPainted(false);
    collapseAllButton.addMouseListener(new HoverButtonMouseAdapter(collapseAllButton));
    collapseAllButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myTreePanel.collapseAll();
        }
    });
    collapseAllButton.setToolTipText("Collapse All");
    collapseAllButton.setIcon(new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/collapse_all.png")));
    mytoolBar_1.add(collapseAllButton);

    expandAllButton = new JButton();
    expandAllButton.setBorderPainted(false);
    expandAllButton.addMouseListener(new HoverButtonMouseAdapter(expandAllButton));
    expandAllButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myTreePanel.expandAll();
        }
    });
    expandAllButton.setToolTipText("Expand All");
    expandAllButton.setIcon(new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/expand_all.png")));
    mytoolBar_1.add(expandAllButton);

    myhorizontalGlue = Box.createHorizontalGlue();
    mytoolBar_1.add(myhorizontalGlue);

    mySpinner = new JButton("");
    mySpinner.setForeground(Color.DARK_GRAY);
    mySpinner.setHorizontalAlignment(SwingConstants.RIGHT);
    mySpinner.setMaximumSize(new Dimension(200, 15));
    mySpinner.setPreferredSize(new Dimension(200, 15));
    mySpinner.setMinimumSize(new Dimension(200, 15));
    mySpinner.setBorderPainted(false);
    mySpinner.setSize(new Dimension(16, 16));
    mytoolBar_1.add(mySpinner);
    myProfileComboboxModel = new ProfileComboModel();

    myTablesComboModel = new TablesComboModel(myController);

    mytoolBar = new JToolBar();
    mytoolBar.setFloatable(false);
    mytoolBar.setRollover(true);
    treeContainerPanel.add(mytoolBar, BorderLayout.NORTH);

    myOutboundInterfaceCombo = new JComboBox();
    myOutboundInterfaceComboModel = new DefaultComboBoxModel();

    mylabel_1 = new JLabel("Send");
    mytoolBar.add(mylabel_1);
    myOutboundInterfaceCombo.setModel(myOutboundInterfaceComboModel);
    myOutboundInterfaceCombo.setMaximumSize(new Dimension(200, 32767));
    mytoolBar.add(myOutboundInterfaceCombo);

    mySendButton = new JButton("Send");
    mySendButton.addMouseListener(new HoverButtonMouseAdapter(mySendButton));
    mySendButton.setBorderPainted(false);
    mySendButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // int selectedIndex =
            // myOutboundInterfaceComboModel.getIndexOf(myOutboundInterfaceComboModel.getSelectedItem());
            int selectedIndex = myOutboundInterfaceCombo.getSelectedIndex();
            OutboundConnection connection = myController.getOutboundConnectionList().getConnections()
                    .get(selectedIndex);
            activateSendingActivityTabForConnection(connection);
            myController.sendMessages(connection, myMessage,
                    mySendingActivityTable.provideTransmissionCallback());
        }
    });

    myhorizontalStrut_2 = Box.createHorizontalStrut(20);
    myhorizontalStrut_2.setPreferredSize(new Dimension(2, 0));
    myhorizontalStrut_2.setMinimumSize(new Dimension(2, 0));
    myhorizontalStrut_2.setMaximumSize(new Dimension(2, 32767));
    mytoolBar.add(myhorizontalStrut_2);

    mySendOptionsButton = new JButton("Options");
    mySendOptionsButton.setBorderPainted(false);
    final HoverButtonMouseAdapter sendOptionsHoverAdaptor = new HoverButtonMouseAdapter(mySendOptionsButton);
    mySendOptionsButton.addMouseListener(sendOptionsHoverAdaptor);
    mySendOptionsButton.setIcon(new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/sendoptions.png")));
    mytoolBar.add(mySendOptionsButton);
    mySendOptionsButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent theE) {
            if (mySendOptionsPopupDialog != null) {
                mySendOptionsPopupDialog.doHide();
                mySendOptionsPopupDialog = null;
                return;
            }
            mySendOptionsPopupDialog = new SendOptionsPopupDialog(Hl7V2MessageEditorPanel.this, myMessage,
                    mySendOptionsButton, sendOptionsHoverAdaptor);
            Point los = mySendOptionsButton.getLocationOnScreen();
            mySendOptionsPopupDialog.setLocation(los.x, los.y + mySendOptionsButton.getHeight());
            mySendOptionsPopupDialog.setVisible(true);
        }
    });

    mySendButton.setIcon(new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/button_execute.png")));
    mytoolBar.add(mySendButton);

    myhorizontalStrut_1 = Box.createHorizontalStrut(20);
    mytoolBar.add(myhorizontalStrut_1);

    mylabel_2 = new JLabel("Validate");
    mytoolBar.add(mylabel_2);

    myProfileCombobox = new JComboBox();
    mytoolBar.add(myProfileCombobox);
    myProfileCombobox.setPreferredSize(new Dimension(200, 27));
    myProfileCombobox.setMinimumSize(new Dimension(200, 27));
    myProfileCombobox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (myHandlingProfileComboboxChange) {
                return;
            }

            myHandlingProfileComboboxChange = true;
            try {
                if (myProfileCombobox.getSelectedIndex() == 0) {
                    myMessage.setValidationContext(null);
                } else if (myProfileCombobox.getSelectedIndex() == 1) {
                    myMessage.setValidationContext(new DefaultValidation());
                } else if (myProfileCombobox.getSelectedIndex() > 0) {
                    ProfileGroup profile = myProfileComboboxModel.myProfileGroups
                            .get(myProfileCombobox.getSelectedIndex());
                    myMessage.setRuntimeProfile(profile);

                    // } else if (myProfileCombobox.getSelectedItem() ==
                    // ProfileComboModel.APPLY_CONFORMANCE_PROFILE) {
                    // IOkCancelCallback<Void> callback = new
                    // IOkCancelCallback<Void>() {
                    // public void ok(Void theArg) {
                    // myProfileComboboxModel.update();
                    // }
                    //
                    // public void cancel(Void theArg) {
                    // myProfileCombobox.setSelectedIndex(0);
                    // }
                    // };
                    // myController.chooseAndLoadConformanceProfileForMessage(myMessage,
                    // callback);
                }
            } catch (ProfileException e2) {
                ourLog.error("Failed to load profile", e2);
            } finally {
                myHandlingProfileComboboxChange = false;
            }
        }
    });
    myProfileCombobox.setMaximumSize(new Dimension(300, 32767));
    myProfileCombobox.setModel(myProfileComboboxModel);

    myhorizontalStrut_4 = Box.createHorizontalStrut(20);
    myhorizontalStrut_4.setPreferredSize(new Dimension(2, 0));
    myhorizontalStrut_4.setMinimumSize(new Dimension(2, 0));
    myhorizontalStrut_4.setMaximumSize(new Dimension(2, 32767));
    mytoolBar.add(myhorizontalStrut_4);

    // mySendingPanel = new JPanel();
    // mySendingPanel.setBorder(null);
    // myTopTabBar.addTab("Sending", null, mySendingPanel, null);
    // mySendingPanel.setLayout(new BorderLayout(0, 0));

    mySendingActivityTable = new ActivityTable();
    mySendingActivityTable.setController(myController);
    myTopTabBar.addTab("Sending", null, mySendingActivityTable, null);

    // mySendingPanelScrollPanel = new JScrollPane();
    // mySendingPanelScrollPanel.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    // mySendingPanelScrollPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    // mySendingPanelScrollPanel.setColumnHeaderView(mySendingActivityTable);
    //
    // mySendingPanel.add(mySendingPanelScrollPanel, BorderLayout.CENTER);

    bottomPanel = new JPanel();
    bottomPanel.setPreferredSize(new Dimension(10, 20));
    bottomPanel.setMinimumSize(new Dimension(10, 20));
    add(bottomPanel, BorderLayout.SOUTH);
    GridBagLayout gbl_bottomPanel = new GridBagLayout();
    gbl_bottomPanel.columnWidths = new int[] { 98, 74, 0 };
    gbl_bottomPanel.rowHeights = new int[] { 16, 0 };
    gbl_bottomPanel.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    gbl_bottomPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
    bottomPanel.setLayout(gbl_bottomPanel);

    mylabel = new JLabel("Terser Path:");
    mylabel.setHorizontalTextPosition(SwingConstants.LEFT);
    mylabel.setHorizontalAlignment(SwingConstants.LEFT);
    GridBagConstraints gbc_label = new GridBagConstraints();
    gbc_label.fill = GridBagConstraints.VERTICAL;
    gbc_label.weighty = 1.0;
    gbc_label.anchor = GridBagConstraints.NORTHWEST;
    gbc_label.gridx = 0;
    gbc_label.gridy = 0;
    bottomPanel.add(mylabel, gbc_label);

    myTerserPathTextField = new JLabel();
    myTerserPathTextField.setForeground(Color.BLUE);
    myTerserPathTextField.setFont(new Font("Lucida Console", Font.PLAIN, 13));
    myTerserPathTextField.setBorder(null);
    myTerserPathTextField.setBackground(SystemColor.control);
    myTerserPathTextField.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (StringUtils.isNotEmpty(myTerserPathTextField.getText())) {
                myTerserPathPopupMenu.show(myTerserPathTextField, 0, 0);
            }
        }
    });

    GridBagConstraints gbc_TerserPathTextField = new GridBagConstraints();
    gbc_TerserPathTextField.weightx = 1.0;
    gbc_TerserPathTextField.fill = GridBagConstraints.HORIZONTAL;
    gbc_TerserPathTextField.gridx = 1;
    gbc_TerserPathTextField.gridy = 0;
    bottomPanel.add(myTerserPathTextField, gbc_TerserPathTextField);

    initLocal();

}

From source file:es.emergya.ui.gis.CustomMapView.java

@Override
public void addLayer(Layer layer, boolean showOnButtonList, int pos) {
    if (layer instanceof MapViewerLayer) {
        minZoom = Math.max(((MapViewerLayer) layer).getMinZoomLevel(), getMinZoom());
        maxZoom = Math.min(((MapViewerLayer) layer).getMaxZoomLevel(), getMaxZoom());
        if (zoomFactor > maxZoom || zoomFactor < minZoom) {
            zoomFactor = (maxZoom + minZoom) / 2;
        }//from  w  w w  .  java 2  s  .c o  m
        zoomTo(center, zoom2Scale(zoomFactor));
    }
    if (showOnButtonList) {
        JToggleButton b = new JToggleButton(layer.name,
                LogicConstants.getIcon("capas_button_" + layer.name.toLowerCase()), layer.visible);
        // b.setVerticalTextPosition(SwingConstants.BOTTOM);
        // b.setHorizontalTextPosition(SwingConstants.CENTER);
        b.setActionCommand(layer.name);
        b.addActionListener(layerControlListener);
        layerControls.add(b);
        layerControlPanel.removeAll();
        layerControlPanel.add(Box.createHorizontalStrut(10));
        for (JToggleButton bt : layerControls) {
            layerControlPanel.add(bt);
            layerControlPanel.add(Box.createHorizontalGlue());
        }
        layerControlPanel.updateUI();
    }

    super.addLayer(layer, pos);
}

From source file:org.prom5.analysis.decisionmining.DecisionAttribute.java

/**
 * Builds a panel containing a checkbox to include or exclude
 * this attribute, and a combobox in order to chose an attribute type.
 *//*from w ww .  ja  va 2  s .  co m*/
private void buildAttributePanel() {
    myPanel = new JPanel();
    myPanel.setLayout(new BoxLayout(myPanel, BoxLayout.LINE_AXIS));
    JLabel myNameLabel = new JLabel("Attribute name: ");
    myNameLabel.setForeground(new Color(100, 100, 100));
    myPanel.add(myNameLabel);
    myNameCheckBox = new JCheckBox(getName());
    // per default select everything
    myNameCheckBox.setSelected(true);

    // register check/uncheck action
    myNameCheckBox.addActionListener(new ActionListener() {
        // specify action when the attribute selection scope is changed
        public void actionPerformed(ActionEvent e) {
            JCheckBox cb = (JCheckBox) e.getSource();
            HLAttribute simAtt = getSimulationAttribute();
            if (cb.isSelected() == true) {
                myTypeGuiRepresenation.enable();
                // add attribute to simulation model
                // and to related activities
                createSimulationAttribute();
            } else {
                myTypeGuiRepresenation.disable();
                // remove attribute from simulation model
                // (automatically removes attribute from contained activities)
                hlProcess.removeAttribute(simAtt.getID());
            }
        }
    });

    myPanel.add(myNameCheckBox);
    myPanel.add(Box.createHorizontalGlue());

    createAttributeTypeGui();
    //      ArrayList<DecisionAttributeType> attributeTypes = new ArrayList<DecisionAttributeType>();
    //      // per default set "nominal"
    //      attributeTypes.add(DecisionAttributeType.NOMINAL);
    //      attributeTypes.add(DecisionAttributeType.NUMERIC);
    //      myTypeGuiRepresenation = new GUIPropertyListWithoutGlue("Attribute type:",
    //                         "Please determine the type of the attribute", attributeTypes, this);

    myPanel.add(myTypeGuiRepresenation.getPropertyPanel());
}