List of usage examples for javax.swing JLabel setMaximumSize
@BeanProperty(description = "The maximum size of the component.") public void setMaximumSize(Dimension maximumSize)
From source file:org.jdal.swing.form.FormUtils.java
/** * @param message//from ww w. j a v a 2 s. c om * @return JLabel */ public static JLabel newLabelForBox(String message) { JLabel label = new JLabel(message); label.setMaximumSize(new Dimension(Short.MAX_VALUE, label.getFont().getSize() + 10)); label.setAlignmentX(Container.CENTER_ALIGNMENT); return label; }
From source file:mergedoc.ui.ButtonBar.java
/** * ???// w w w.jav a 2 s. c om * ?????????????????<br> * ???????? * @param state */ public void setState(final ButtonState state) { if (runListener == null || backListener == null || cancelListener == null || endListener == null) { String m = "?????????????"; RuntimeException e = new IllegalStateException(m); log.fatal(m, e); throw e; } // ? final JLabel filler = new JLabel(); int maxWidth = (int) ComponentFactory.createMaxDimension().getWidth(); filler.setMaximumSize(new Dimension(maxWidth, 0)); runButton = createButton(); endButton = createButton(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { // ?????? removeAll(); add(filler); add(runButton); add(ComponentFactory.createSpacer(10, 0)); add(endButton); // ? state.apply(); } }); }
From source file:com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel.java
private JComponent buildToolbar() { JXToolBar toolBar = UISupport.createToolbar(); JButton runButton = UISupport.createToolbarButton(runAction); toolBar.add(runButton);//from w ww . java 2s .co m toolBar.add(Box.createHorizontalGlue()); JLabel label = new JLabel("<html>Script is invoked with <code>log</code>, <code>context</code> " + "and <code>testRunner</code> variables</html>"); label.setToolTipText(label.getText()); label.setMaximumSize(label.getPreferredSize()); toolBar.add(label); toolBar.addRelatedGap(); toolBar.add(UISupport.createToolbarButton(new ShowOnlineHelpAction(HelpUrls.GROOVYSTEPEDITOR_HELP_URL))); componentEnabler.add(runButton); return toolBar; }
From source file:net.sf.firemox.ui.wizard.About.java
/** * Creates a new instance of About <br> * /* w w w. jav a2 s . c o m*/ * @param parent */ public About(JFrame parent) { super(LanguageManager.getString("wiz_about.title"), LanguageManager.getString("wiz_about.description"), "mp64.gif", LanguageManager.getString("close"), 420, 620); JPanel thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setMaximumSize(new Dimension(32767, 26)); thanksPanel.setOpaque(false); JLabel jLabel5 = new JLabel(LanguageManager.getString("version") + " : "); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.RIGHT); jLabel5.setMaximumSize(new Dimension(100, 16)); jLabel5.setMinimumSize(new Dimension(100, 16)); jLabel5.setPreferredSize(new Dimension(100, 16)); thanksPanel.add(jLabel5); jLabel5 = new JLabel(IdConst.VERSION); thanksPanel.add(jLabel5); gameParamPanel.add(thanksPanel); thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setOpaque(false); JPanel thanksPanelLeft = new JPanel(new FlowLayout(FlowLayout.LEADING)); thanksPanelLeft.setLayout(new BoxLayout(thanksPanelLeft, BoxLayout.Y_AXIS)); thanksPanelLeft.setMaximumSize(new Dimension(100, 2000)); thanksPanelLeft.setMinimumSize(new Dimension(100, 16)); jLabel5 = new JLabel(LanguageManager.getString("thanks") + " : "); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.RIGHT); jLabel5.setMaximumSize(new Dimension(100, 16)); jLabel5.setMinimumSize(new Dimension(100, 16)); jLabel5.setPreferredSize(new Dimension(100, 16)); thanksPanelLeft.add(jLabel5); thanksPanel.add(thanksPanelLeft); thanksPanelLeft = new JPanel(); thanksPanelLeft.setLayout(new BoxLayout(thanksPanelLeft, BoxLayout.Y_AXIS)); StringBuilder contributors = new StringBuilder(); addContributor(contributors, "Fabrice Daugan", "developper", "france"); addContributor(contributors, "Hoani Cross", "developper", "frenchpolynesia"); addContributor(contributors, "nico100", "graphist", "france"); addContributor(contributors, "seingalt_tm", "graphist", "france"); addContributor(contributors, "surtur2", "tester", null); addContributor(contributors, "Jan Blaha", "developper", "cz"); addContributor(contributors, "Tureba", "developper", "brazil"); addContributor(contributors, "hakvf", "tester", "france"); addContributor(contributors, "Stefano \"Kismet\" Lenzi", "developper", "italian"); jLabel5 = new JLabel(contributors.toString()); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.LEFT); thanksPanelLeft.add(jLabel5); jLabel5 = new JLink("http://obsidiurne.free.fr", "morgil has designed the splash screen"); jLabel5.setFont(MToolKit.defaultFont); thanksPanelLeft.add(jLabel5); thanksPanel.add(thanksPanelLeft); gameParamPanel.add(thanksPanel); thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setMaximumSize(new Dimension(32767, 26)); thanksPanel.setOpaque(false); JLabel blanklbl = new JLabel(); blanklbl.setHorizontalAlignment(SwingConstants.RIGHT); blanklbl.setMaximumSize(new Dimension(100, 16)); blanklbl.setMinimumSize(new Dimension(100, 16)); blanklbl.setPreferredSize(new Dimension(100, 16)); thanksPanel.add(blanklbl); jLabel5 = new JLink( "http://sourceforge.net/tracker/?func=add&group_id=" + IdConst.PROJECT_ID + "&atid=601043", LanguageManager.getString("joindev")); jLabel5.setFont(MToolKit.defaultFont); thanksPanel.add(jLabel5); gameParamPanel.add(thanksPanel); thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setOpaque(false); jLabel5 = new JLabel(LanguageManager.getString("projecthome") + " : "); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.RIGHT); jLabel5.setMaximumSize(new Dimension(100, 16)); jLabel5.setMinimumSize(new Dimension(100, 16)); jLabel5.setPreferredSize(new Dimension(100, 16)); thanksPanel.add(jLabel5); jLabel5 = new JLink(IdConst.MAIN_PAGE, IdConst.MAIN_PAGE); jLabel5.setFont(MToolKit.defaultFont); thanksPanel.add(jLabel5); gameParamPanel.add(thanksPanel); // forum francais thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setOpaque(false); jLabel5 = new JLabel(LanguageManager.getString("othersites") + " : "); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.RIGHT); jLabel5.setMaximumSize(new Dimension(100, 16)); jLabel5.setMinimumSize(new Dimension(100, 16)); jLabel5.setPreferredSize(new Dimension(100, 16)); thanksPanel.add(jLabel5); jLabel5 = new JLink("http://www.Firemox.fr.st", UIHelper.getIcon("mpfrsml.gif"), SwingConstants.LEFT); jLabel5.setToolTipText(LanguageManager.getString("frenchforum.tooltip")); thanksPanel.add(jLabel5); jLabel5 = new JLabel(); jLabel5.setMaximumSize(new Dimension(1000, 16)); thanksPanel.add(jLabel5); gameParamPanel.add(thanksPanel); JTextArea disclaimer = new JTextArea(); disclaimer.setEditable(false); disclaimer.setLineWrap(true); disclaimer.setWrapStyleWord(true); disclaimer.setAutoscrolls(true); disclaimer.setTabSize(2); disclaimer.setFont(new Font("Arial", 0, 10)); // Then try and read it locally BufferedReader inGPL = null; try { inGPL = new BufferedReader(new InputStreamReader(MToolKit.getResourceAsStream(IdConst.FILE_LICENSE))); disclaimer.read(inGPL, ""); } catch (IOException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(inGPL); } JScrollPane disclaimerSPanel = new JScrollPane(); disclaimerSPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); MToolKit.addOverlay(disclaimerSPanel); disclaimerSPanel.setViewportView(disclaimer); gameParamPanel.add(disclaimerSPanel); }
From source file:edu.virginia.speclab.juxta.author.view.export.WebServiceExportDialog.java
/** * Creates the UI panel containing all of the fields necessary to upload * the current session data to the web service */// w ww .ja v a 2 s. c o m private void createSetupPane() { this.setupPanel = new JPanel(); this.setupPanel.setLayout(new BorderLayout()); this.setupPanel.setBackground(Color.white); try { String data = IOUtils.toString(LoginDialog.class.getResourceAsStream("/export2.html")); data = data.replace("{LIST}", formatWitnessList()); JLabel txt = new JLabel(data); this.setupPanel.add(txt, BorderLayout.NORTH); } catch (IOException e) { // dunno. not much that can be done! } // ugly layout code to follow. avert your eyes JPanel data = new JPanel(); data.setLayout(new BorderLayout()); data.setBackground(Color.white); JPanel names = new JPanel(); names.setLayout(new BoxLayout(names, BoxLayout.Y_AXIS)); names.setBackground(Color.white); JLabel l = new JLabel("Name:", SwingConstants.RIGHT); l.setPreferredSize(new Dimension(100, 20)); l.setMaximumSize(new Dimension(100, 20)); l.setAlignmentX(RIGHT_ALIGNMENT); names.add(l); names.add(Box.createVerticalStrut(5)); JLabel l2 = new JLabel("Description:", SwingConstants.RIGHT); l2.setPreferredSize(new Dimension(100, 20)); l2.setMaximumSize(new Dimension(100, 20)); l2.setAlignmentX(RIGHT_ALIGNMENT); names.add(l2); data.add(names, BorderLayout.WEST); JPanel edits = new JPanel(); edits.setBackground(Color.white); edits.setLayout(new BoxLayout(edits, BoxLayout.Y_AXIS)); this.nameEdit = new JTextField(); this.nameEdit.setPreferredSize(new Dimension(200, 22)); this.nameEdit.setMaximumSize(new Dimension(200, 22)); File saveFile = this.juxtaFrame.getSession().getSaveFile(); if (saveFile == null) { this.nameEdit.setText("new_session"); } else { String name = saveFile.getName(); this.nameEdit.setText(name.substring(0, name.lastIndexOf('.'))); } edits.add(this.nameEdit); this.descriptionEdit = new JTextArea(3, 0); this.descriptionEdit.setLineWrap(true); this.descriptionEdit.setWrapStyleWord(true); JScrollPane sp = new JScrollPane(this.descriptionEdit); sp.setPreferredSize(new Dimension(194, 60)); sp.setMaximumSize(new Dimension(194, 300)); edits.add(Box.createVerticalStrut(4)); edits.add(sp); data.add(edits, BorderLayout.CENTER); this.setupPanel.add(data, BorderLayout.SOUTH); }
From source file:ConfigFiles.java
public JPanel addField(JTextField textfield, String text, int nr) { textfield.setMaximumSize(new Dimension(340, 25)); textfield.setPreferredSize(new Dimension(340, 25)); if (RunnerRepository.getLogs().size() > 0) textfield.setText(RunnerRepository.getLogs().get(nr)); JLabel l1 = new JLabel(text); l1.setMaximumSize(new Dimension(80, 20)); l1.setPreferredSize(new Dimension(80, 20)); JPanel p721 = new JPanel(); p721.setBackground(Color.WHITE); p721.add(l1);/*from w ww . j a v a 2s. c o m*/ p721.add(textfield); p721.setMaximumSize(new Dimension(800, 28)); p721.setPreferredSize(new Dimension(800, 28)); return p721; }
From source file:com.josue.tileset.editor.Editor.java
private void mountButtons(List<Tile> tiles, int cols, int rows) { imagePanel.removeAll();// w ww . j a v a 2 s .c o m if (animatedPerformer != null) { animatedPerformer.stop(); animatedPerformer = null; } imagePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); Dimension dimension = new Dimension(cols * TILE_SIZE, rows * TILE_SIZE); for (Tile tile : tiles) { final JLabel tileLabel = new JLabel(); tileLabel.setIcon(new ImageIcon(tile.getImage())); Dimension labelDimension = new Dimension(TILE_SIZE, TILE_SIZE); tileLabel.setMinimumSize(labelDimension); tileLabel.setMaximumSize(labelDimension); tileLabel.setPreferredSize(labelDimension); tileLabel.setSize(labelDimension); tileLabel.addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mouseClicked(java.awt.event.MouseEvent evt) { if (SwingUtilities.isRightMouseButton(evt)) {//select animated sequence if (animatedAction.isSelected()) { addAnimatedTile(tile); } else { addLightSourceTile(tile); } } else { if (animatedPerformer != null) { animatedPerformer.stop(); } Iterator<JLabel> iterator = tileLabels.values().iterator(); while (iterator.hasNext()) { JLabel next = iterator.next(); next.revalidate(); } imagePanel.repaint(); for (Map.Entry<Tile, JLabel> entry : tileLabels.entrySet()) { Tile key = entry.getKey(); JLabel value = entry.getValue(); value.setBorder(null); //clear borders } selectedTile = tile;//this isolate for the next operations tileLabel.setBorder(new LineBorder(Color.RED, 2)); previewLabel.setIcon(new ImageIcon(tile.getImage())); animatedTb.setSelected(selectedTile.isAnimated()); lightTb.setSelected(selectedTile.isLight()); solidTb.setSelected(selectedTile.isSolid()); if (tile.isAnimated()) { for (Integer animatesTileOffset : selectedTile.getAnimation().getAnimatedSequence()) { //display animated borders for (Map.Entry<Tile, JLabel> entry : tileLabels.entrySet()) { Tile key = entry.getKey(); JLabel value = entry.getValue(); if (key.getId() == selectedTile.getId() + animatesTileOffset) { value.setBorder(new LineBorder(Color.BLUE, 2)); } } } animatedPerformer = new Timer( (int) (selectedTile.getAnimation().getAnimationInterval()), new TileAnimator(selectedTile, previewLabel, loadedTiles)); animatedPerformer.start(); } if (selectedTile.isLight()) {//light color has preference for (Tile tile : tiles) { if (tile.getId() == selectedTile.getLightTileId()) { JLabel found = tileLabels.get(tile); found.setBorder(new LineBorder(Color.YELLOW, 2)); break; } } } } } @Override public void mouseExited(MouseEvent e) { if (selectedTile != null && selectedTile.getAnimation() != null && selectedTile.getAnimation() .getAnimatedSequence().contains(tile.getId() - selectedTile.getId())) { tileLabel.setBorder(new LineBorder(Color.BLUE, 2)); } else if (selectedTile != null && selectedTile.isLight() && selectedTile.getLightTileId() == tile.getId()) { tileLabel.setBorder(new LineBorder(Color.YELLOW, 2)); } else if (selectedTile != null) { JLabel get = tileLabels.get(selectedTile); if (!get.equals(tileLabel)) { //keep the red border if is the selected tileLabel.setBorder(null); } } else { tileLabel.setBorder(null); } } @Override public void mouseEntered(MouseEvent e) { if (selectedTile != null && selectedTile.getAnimation() != null && !selectedTile.getAnimation().getAnimatedSequence() .contains(tile.getId() - selectedTile.getId()) && tile.getLight() != null && tile.getLight().getLightTileOffset() != 0) { tileLabel.setBorder(new LineBorder(Color.RED, 2)); } else if (selectedTile == null) { tileLabel.setBorder(new LineBorder(Color.RED, 2)); } } }); tileLabels.put(tile, tileLabel); imagePanel.add(tileLabel); } imagePanel.setMaximumSize(dimension); imagePanel.setMinimumSize(dimension); imagePanel.setPreferredSize(dimension); imagePanel.revalidate(); imagePanel.repaint(); this.pack(); }
From source file:net.sf.firemox.DeckBuilder.java
/** * Creates new form DeckBuilder/*from w w w . j a v a 2 s . c om*/ */ private DeckBuilder() { super("DeckBuilder"); form = this; timerPanel = new TimerGlassPane(); cardLoader = new CardLoader(timerPanel); timer = new Timer(200, cardLoader); setGlassPane(timerPanel); try { setIconImage(Picture.loadImage(IdConst.IMAGES_DIR + "deckbuilder.gif")); } catch (Exception e) { // IGNORING } // Load settings loadSettings(); // Initialize components final JMenuItem newItem = UIHelper.buildMenu("menu_db_new", 'n', this); newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK)); final JMenuItem loadItem = UIHelper.buildMenu("menu_db_load", 'o', this); loadItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK)); final JMenuItem saveAsItem = UIHelper.buildMenu("menu_db_saveas", 'a', this); saveAsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F12, 0)); final JMenuItem saveItem = UIHelper.buildMenu("menu_db_save", 's', this); saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK)); final JMenuItem quitItem = UIHelper.buildMenu("menu_db_exit", this); quitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_MASK)); final JMenuItem deckConstraintsItem = UIHelper.buildMenu("menu_db_constraints", 'c', this); deckConstraintsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0)); final JMenuItem aboutItem = UIHelper.buildMenu("menu_help_about", 'a', this); aboutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, InputEvent.SHIFT_MASK)); final JMenuItem convertDCK = UIHelper.buildMenu("menu_convert_DCK_MP", this); final JMenu mainMenu = UIHelper.buildMenu("menu_file"); mainMenu.add(newItem); mainMenu.add(loadItem); mainMenu.add(saveAsItem); mainMenu.add(saveItem); mainMenu.add(new JSeparator()); mainMenu.add(quitItem); super.optionMenu = new JMenu("Options"); final JMenu convertMenu = UIHelper.buildMenu("menu_convert"); convertMenu.add(convertDCK); final JMenuItem helpItem = UIHelper.buildMenu("menu_help_help", 'h', this); helpItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)); final JMenu helpMenu = new JMenu("?"); helpMenu.add(helpItem); helpMenu.add(deckConstraintsItem); helpMenu.add(aboutItem); final JMenuBar menuBar = new JMenuBar(); menuBar.add(mainMenu); initAbstractMenu(); menuBar.add(optionMenu); menuBar.add(convertMenu); menuBar.add(helpMenu); setJMenuBar(menuBar); addWindowListener(this); // Build the panel containing amount of available cards final JLabel amountLeft = new JLabel("<html>0/?", SwingConstants.RIGHT); // Build the left list allListModel = new MListModel<MCardCompare>(amountLeft, false); leftList = new ThreadSafeJList(allListModel); leftList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); leftList.setLayoutOrientation(JList.VERTICAL); leftList.getSelectionModel().addListSelectionListener(this); leftList.addMouseListener(this); leftList.setVisibleRowCount(10); // Initialize the text field containing the amount to add addQtyTxt = new JTextField("1"); // Build the "Add" button addButton = new JButton(LanguageManager.getString("db_add")); addButton.setMnemonic('a'); addButton.setEnabled(false); // Build the panel containing : "Add" amount and "Add" button final Box addPanel = Box.createHorizontalBox(); addPanel.add(addButton); addPanel.add(addQtyTxt); addPanel.setMaximumSize(new Dimension(32010, 26)); // Build the panel containing the selected card name cardNameTxt = new JTextField(); new HireListener(cardNameTxt, addButton, this, leftList); final JLabel searchLabel = new JLabel(LanguageManager.getString("db_search") + " : "); searchLabel.setLabelFor(cardNameTxt); // Build the panel containing search label and card name text field final Box searchPanel = Box.createHorizontalBox(); searchPanel.add(searchLabel); searchPanel.add(cardNameTxt); searchPanel.setMaximumSize(new Dimension(32010, 26)); listScrollerLeft = new JScrollPane(leftList); MToolKit.addOverlay(listScrollerLeft); // Build the left panel containing : list, available amount, "Add" panel final JPanel srcPanel = new JPanel(null); srcPanel.add(searchPanel); srcPanel.add(listScrollerLeft); srcPanel.add(amountLeft); srcPanel.add(addPanel); srcPanel.setMinimumSize(new Dimension(220, 200)); srcPanel.setLayout(new BoxLayout(srcPanel, BoxLayout.Y_AXIS)); // Initialize constraints constraintsChecker = new ConstraintsChecker(); constraintsChecker.setBorder(new EtchedBorder()); final JScrollPane constraintsCheckerScroll = new JScrollPane(constraintsChecker); MToolKit.addOverlay(constraintsCheckerScroll); // create a pane with the oracle text for the present card oracleText = new JLabel(); oracleText.setPreferredSize(new Dimension(180, 200)); oracleText.setVerticalAlignment(SwingConstants.TOP); final JScrollPane oracle = new JScrollPane(oracleText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); MToolKit.addOverlay(oracle); // build some Pie Charts and a panel to display it initSets(); datasets = new ChartSets(); final JTabbedPane tabbedPane = new JTabbedPane(); for (ChartFilter filter : ChartFilter.values()) { final Dataset dataSet = filter.createDataSet(this); final JFreeChart chart = new JFreeChart(null, null, filter.createPlot(dataSet, painterMapper.get(filter)), false); datasets.addDataSet(filter, dataSet); ChartPanel pieChartPanel = new ChartPanel(chart, true); tabbedPane.add(pieChartPanel, filter.getTitle()); } // add the Constraints scroll panel and Oracle text Pane to the tabbedPane tabbedPane.add(constraintsCheckerScroll, LanguageManager.getString("db_constraints")); tabbedPane.add(oracle, LanguageManager.getString("db_text")); tabbedPane.setSelectedComponent(oracle); // The toollBar for color filtering toolBar = new JToolBar(); toolBar.setFloatable(false); final JButton clearButton = UIHelper.buildButton("clear"); clearButton.addActionListener(this); toolBar.add(clearButton); final JToggleButton toggleColorlessButton = new JToggleButton( UIHelper.getTbsIcon("mana/colorless/small/" + MdbLoader.unknownSmlMana), true); toggleColorlessButton.setActionCommand("0"); toggleColorlessButton.addActionListener(this); toolBar.add(toggleColorlessButton); for (int index = 1; index < IdCardColors.CARD_COLOR_NAMES.length; index++) { final JToggleButton toggleButton = new JToggleButton( UIHelper.getTbsIcon("mana/colored/small/" + MdbLoader.coloredSmlManas[index]), true); toggleButton.setActionCommand(String.valueOf(index)); toggleButton.addActionListener(this); toolBar.add(toggleButton); } // sorted card type combobox creation final List<String> idCards = new ArrayList<String>(Arrays.asList(CardFactory.exportedIdCardNames)); Collections.sort(idCards); final Object[] cardTypes = ArrayUtils.addAll(new String[] { LanguageManager.getString("db_types.any") }, idCards.toArray()); idCardComboBox = new JComboBox(cardTypes); idCardComboBox.setSelectedIndex(0); idCardComboBox.addActionListener(this); idCardComboBox.setActionCommand("cardTypeFilter"); // sorted card properties combobox creation final List<String> properties = new ArrayList<String>( CardFactory.getPropertiesName(DeckConstraints.getMinProperty(), DeckConstraints.getMaxProperty())); Collections.sort(properties); final Object[] cardProperties = ArrayUtils .addAll(new String[] { LanguageManager.getString("db_properties.any") }, properties.toArray()); propertiesComboBox = new JComboBox(cardProperties); propertiesComboBox.setSelectedIndex(0); propertiesComboBox.addActionListener(this); propertiesComboBox.setActionCommand("propertyFilter"); final JLabel colors = new JLabel(" " + LanguageManager.getString("colors") + " : "); final JLabel types = new JLabel(" " + LanguageManager.getString("types") + " : "); final JLabel property = new JLabel(" " + LanguageManager.getString("properties") + " : "); // filter Panel with colors toolBar and card type combobox final Box filterPanel = Box.createHorizontalBox(); filterPanel.add(colors); filterPanel.add(toolBar); filterPanel.add(types); filterPanel.add(idCardComboBox); filterPanel.add(property); filterPanel.add(propertiesComboBox); getContentPane().add(filterPanel, BorderLayout.NORTH); // Destination section : // Build the panel containing amount of available cards final JLabel rightAmount = new JLabel("0/?", SwingConstants.RIGHT); rightAmount.setMaximumSize(new Dimension(220, 26)); // Build the right list rightListModel = new MCardTableModel(new MListModel<MCardCompare>(rightAmount, true)); rightListModel.addTableModelListener(this); rightList = new JTable(rightListModel); rightList.setShowGrid(false); rightList.setTableHeader(null); rightList.getSelectionModel().addListSelectionListener(this); rightList.getColumnModel().getColumn(0).setMaxWidth(25); rightList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); // Build the panel containing the selected deck deckNameTxt = new JTextField("loading..."); deckNameTxt.setEditable(false); deckNameTxt.setBorder(null); final JLabel deckLabel = new JLabel(LanguageManager.getString("db_deck") + " : "); deckLabel.setLabelFor(deckNameTxt); final Box deckNamePanel = Box.createHorizontalBox(); deckNamePanel.add(deckLabel); deckNamePanel.add(deckNameTxt); deckNamePanel.setMaximumSize(new Dimension(220, 26)); // Initialize the text field containing the amount to remove removeQtyTxt = new JTextField("1"); // Build the "Remove" button removeButton = new JButton(LanguageManager.getString("db_remove")); removeButton.setMnemonic('r'); removeButton.addMouseListener(this); removeButton.setEnabled(false); // Build the panel containing : "Remove" amount and "Remove" button final Box removePanel = Box.createHorizontalBox(); removePanel.add(removeButton); removePanel.add(removeQtyTxt); removePanel.setMaximumSize(new Dimension(220, 26)); // Build the right panel containing : list, available amount, constraints final JScrollPane deskListScroller = new JScrollPane(rightList); MToolKit.addOverlay(deskListScroller); deskListScroller.setBorder(BorderFactory.createLineBorder(Color.GRAY)); deskListScroller.setMinimumSize(new Dimension(220, 200)); deskListScroller.setMaximumSize(new Dimension(220, 32000)); final Box destPanel = Box.createVerticalBox(); destPanel.add(deckNamePanel); destPanel.add(deskListScroller); destPanel.add(rightAmount); destPanel.add(removePanel); destPanel.setMinimumSize(new Dimension(220, 200)); destPanel.setMaximumSize(new Dimension(220, 32000)); // Build the panel containing the name of card in picture cardPictureNameTxt = new JLabel("<html><i>no selected card</i>"); final Box cardPictureNamePanel = Box.createHorizontalBox(); cardPictureNamePanel.add(cardPictureNameTxt); cardPictureNamePanel.setMaximumSize(new Dimension(32010, 26)); // Group the detail panels final JPanel viewCard = new JPanel(null); viewCard.add(cardPictureNamePanel); viewCard.add(CardView.getInstance()); viewCard.add(tabbedPane); viewCard.setLayout(new BoxLayout(viewCard, BoxLayout.Y_AXIS)); final Box mainPanel = Box.createHorizontalBox(); mainPanel.add(destPanel); mainPanel.add(viewCard); // Add the main panel getContentPane().add(srcPanel, BorderLayout.WEST); getContentPane().add(mainPanel, BorderLayout.CENTER); // Size this frame getRootPane().setPreferredSize(new Dimension(WINDOW_WIDTH, WINDOW_HEIGHT)); getRootPane().setMinimumSize(getRootPane().getPreferredSize()); pack(); }
From source file:ca.uhn.hl7v2.testpanel.ui.conn.Hl7ConnectionPanelBackup.java
/** * Create the panel./*w w w .jav a 2 s . c o m*/ */ public Hl7ConnectionPanelBackup(Controller theController) { myController = theController; setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWidths = new int[] { 150, 0 }; gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; gridBagLayout.columnWeights = new double[] { 0.0, 1.0 }; gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE }; setLayout(gridBagLayout); mySinglePortRadio = new JRadioButton("Single Port MLLP"); mySinglePortRadio.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updatePortsModel(); updatePortsUi(); } }); myPortButtonGroup.add(mySinglePortRadio); GridBagConstraints gbc_SinglePortRadio = new GridBagConstraints(); gbc_SinglePortRadio.anchor = GridBagConstraints.WEST; gbc_SinglePortRadio.insets = new Insets(0, 0, 5, 5); gbc_SinglePortRadio.gridx = 0; gbc_SinglePortRadio.gridy = 0; add(mySinglePortRadio, gbc_SinglePortRadio); JPanel panel_4 = new JPanel(); panel_4.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); GridBagConstraints gbc_panel_4 = new GridBagConstraints(); gbc_panel_4.fill = GridBagConstraints.BOTH; gbc_panel_4.insets = new Insets(0, 0, 5, 0); gbc_panel_4.gridx = 1; gbc_panel_4.gridy = 0; add(panel_4, gbc_panel_4); GridBagLayout gbl_panel_4 = new GridBagLayout(); gbl_panel_4.columnWidths = new int[] { 0, 0, 0 }; gbl_panel_4.rowHeights = new int[] { 0, 0 }; gbl_panel_4.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE }; gbl_panel_4.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; panel_4.setLayout(gbl_panel_4); mySinglePortTextBox = new JTextField(); mySinglePortTextBox.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent theE) { String text = mySinglePortTextBox.getText(); text = text.replaceAll("[^0-9]+", ""); if (!StringUtils.equals(mySinglePortTextBox.getText(), text)) { final String newVal = text; SwingUtilities.invokeLater(new Runnable() { public void run() { mySinglePortTextBox.setText(newVal); } }); } if (mySinglePortRadio.isSelected()) { if (text.length() > 0) { myConnection.setIncomingOrSinglePort(Integer.parseInt(text)); } else { myConnection.setIncomingOrSinglePort(-1); } } } }); mylabel = new JLabel("Port"); mylabel.setHorizontalAlignment(SwingConstants.CENTER); mylabel.setPreferredSize(new Dimension(60, 16)); mylabel.setMinimumSize(new Dimension(60, 16)); mylabel.setMaximumSize(new Dimension(60, 16)); GridBagConstraints gbc_label = new GridBagConstraints(); gbc_label.anchor = GridBagConstraints.EAST; gbc_label.insets = new Insets(0, 0, 0, 5); gbc_label.gridx = 0; gbc_label.gridy = 0; panel_4.add(mylabel, gbc_label); GridBagConstraints gbc_SinglePortTextBox = new GridBagConstraints(); gbc_SinglePortTextBox.insets = new Insets(0, 5, 0, 0); gbc_SinglePortTextBox.anchor = GridBagConstraints.WEST; gbc_SinglePortTextBox.gridx = 1; gbc_SinglePortTextBox.gridy = 0; panel_4.add(mySinglePortTextBox, gbc_SinglePortTextBox); mySinglePortTextBox.setMinimumSize(new Dimension(100, 28)); mySinglePortTextBox.setMaximumSize(new Dimension(100, 2147483647)); mySinglePortTextBox.setColumns(10); myDualPortRadio = new JRadioButton("Dual Port MLLP"); myDualPortRadio.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updatePortsModel(); updatePortsUi(); } }); myPortButtonGroup.add(myDualPortRadio); GridBagConstraints gbc_DualPortRadio = new GridBagConstraints(); gbc_DualPortRadio.anchor = GridBagConstraints.WEST; gbc_DualPortRadio.insets = new Insets(0, 0, 5, 5); gbc_DualPortRadio.gridx = 0; gbc_DualPortRadio.gridy = 1; add(myDualPortRadio, gbc_DualPortRadio); JPanel panel = new JPanel(); panel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); GridBagConstraints gbc_BottomPanel = new GridBagConstraints(); gbc_BottomPanel.insets = new Insets(0, 0, 5, 0); gbc_BottomPanel.fill = GridBagConstraints.BOTH; gbc_BottomPanel.gridx = 1; gbc_BottomPanel.gridy = 1; add(panel, gbc_BottomPanel); GridBagLayout gbl_panel = new GridBagLayout(); gbl_panel.columnWidths = new int[] { 0, 0, 0, 0, 0, 0 }; gbl_panel.rowHeights = new int[] { 0, 0 }; gbl_panel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; gbl_panel.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; panel.setLayout(gbl_panel); JLabel lblInbound = new JLabel("Inbound"); lblInbound.setHorizontalAlignment(SwingConstants.CENTER); lblInbound.setPreferredSize(new Dimension(60, 16)); lblInbound.setMinimumSize(new Dimension(60, 16)); lblInbound.setMaximumSize(new Dimension(60, 16)); GridBagConstraints gbc_lblInbound = new GridBagConstraints(); gbc_lblInbound.insets = new Insets(0, 5, 0, 5); gbc_lblInbound.anchor = GridBagConstraints.EAST; gbc_lblInbound.gridx = 0; gbc_lblInbound.gridy = 0; panel.add(lblInbound, gbc_lblInbound); myDualIncomingTextBox = new JTextField(); myDualIncomingTextBox.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent theE) { String text = myDualIncomingTextBox.getText(); text = text.replaceAll("[^0-9]+", ""); if (!StringUtils.equals(myDualIncomingTextBox.getText(), text)) { final String newVal = text; SwingUtilities.invokeLater(new Runnable() { public void run() { myDualIncomingTextBox.setText(newVal); } }); } if (myDualPortRadio.isSelected()) { if (text.length() > 0) { myConnection.setIncomingOrSinglePort(Integer.parseInt(text)); } else { myConnection.setIncomingOrSinglePort(-1); } } } }); myDualIncomingTextBox.setMaximumSize(new Dimension(100, 2147483647)); myDualIncomingTextBox.setMinimumSize(new Dimension(100, 28)); GridBagConstraints gbc_DualIncomingTextBox = new GridBagConstraints(); gbc_DualIncomingTextBox.anchor = GridBagConstraints.WEST; gbc_DualIncomingTextBox.insets = new Insets(0, 0, 0, 5); gbc_DualIncomingTextBox.gridx = 1; gbc_DualIncomingTextBox.gridy = 0; panel.add(myDualIncomingTextBox, gbc_DualIncomingTextBox); myDualIncomingTextBox.setColumns(10); JLabel lblOutbound = new JLabel("Outbound"); GridBagConstraints gbc_lblOutbound = new GridBagConstraints(); gbc_lblOutbound.anchor = GridBagConstraints.EAST; gbc_lblOutbound.insets = new Insets(0, 0, 0, 5); gbc_lblOutbound.gridx = 2; gbc_lblOutbound.gridy = 0; panel.add(lblOutbound, gbc_lblOutbound); myDualOutgoingTextBox = new JTextField(); myDualOutgoingTextBox.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent theE) { String text = myDualOutgoingTextBox.getText(); text = text.replaceAll("[^0-9]+", ""); if (!StringUtils.equals(myDualOutgoingTextBox.getText(), text)) { final String newVal = text; SwingUtilities.invokeLater(new Runnable() { public void run() { myDualOutgoingTextBox.setText(newVal); } }); } if (myDualPortRadio.isSelected()) { if (text.length() > 0) { myConnection.setOutgoingPort(Integer.parseInt(text)); } else { myConnection.setOutgoingPort(-1); } } } }); myDualOutgoingTextBox.setMinimumSize(new Dimension(100, 28)); myDualOutgoingTextBox.setMaximumSize(new Dimension(100, 2147483647)); GridBagConstraints gbc_DualOutgoingTextBox = new GridBagConstraints(); gbc_DualOutgoingTextBox.insets = new Insets(0, 0, 0, 5); gbc_DualOutgoingTextBox.anchor = GridBagConstraints.WEST; gbc_DualOutgoingTextBox.gridx = 3; gbc_DualOutgoingTextBox.gridy = 0; panel.add(myDualOutgoingTextBox, gbc_DualOutgoingTextBox); myDualOutgoingTextBox.setColumns(10); myHl7OverHttpRadioButton = new JRadioButton("HL7 over HTTP"); myHl7OverHttpRadioButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updatePortsModel(); updatePortsUi(); } }); myPortButtonGroup.add(myHl7OverHttpRadioButton); GridBagConstraints gbc_Hl7OverHttpRadioButton = new GridBagConstraints(); gbc_Hl7OverHttpRadioButton.anchor = GridBagConstraints.WEST; gbc_Hl7OverHttpRadioButton.insets = new Insets(0, 0, 5, 5); gbc_Hl7OverHttpRadioButton.gridx = 0; gbc_Hl7OverHttpRadioButton.gridy = 2; add(myHl7OverHttpRadioButton, gbc_Hl7OverHttpRadioButton); mypanel = new JPanel(); mypanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); GridBagConstraints gbc_panel = new GridBagConstraints(); gbc_panel.insets = new Insets(0, 0, 5, 0); gbc_panel.fill = GridBagConstraints.BOTH; gbc_panel.gridx = 1; gbc_panel.gridy = 2; add(mypanel, gbc_panel); GridBagLayout gbl_panel2 = new GridBagLayout(); gbl_panel2.columnWidths = new int[] { 0, 0 }; gbl_panel2.rowHeights = new int[] { 0, 0 }; gbl_panel2.columnWeights = new double[] { 0.0, 1.0 }; gbl_panel2.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; mypanel.setLayout(gbl_panel2); mylabel_1 = new JLabel("URL"); mylabel_1.setHorizontalAlignment(SwingConstants.CENTER); mylabel_1.setPreferredSize(new Dimension(60, 16)); mylabel_1.setMinimumSize(new Dimension(60, 16)); mylabel_1.setMaximumSize(new Dimension(60, 16)); GridBagConstraints gbc_label_1 = new GridBagConstraints(); gbc_label_1.anchor = GridBagConstraints.EAST; gbc_label_1.insets = new Insets(0, 0, 0, 5); gbc_label_1.gridx = 0; gbc_label_1.gridy = 0; mypanel.add(mylabel_1, gbc_label_1); myHoHUrlTextField = new JTextField(); myHoHUrlTextField.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent theE) { if (myHohUrlTextFieldUpdating) { return; } String value = myHoHUrlTextField.getText(); try { URL url = new URL(value); boolean tls; if (url.getProtocol().equals("http")) { tls = false; } else if (url.getProtocol().equals("https")) { tls = true; } else { ourLog.info("Unknown protocol: {}", url.getProtocol()); myHoHUrlTextField.setBackground(ERROR_BG); return; } myConnection.setTls(tls); myConnection.setHost(url.getHost()); myConnection .setIncomingOrSinglePort(url.getPort() != -1 ? url.getPort() : url.getDefaultPort()); myConnection.setHttpUriPath(url.getPath()); myHohUrlTextFieldUpdating = true; updatePortsUi(); myHohUrlTextFieldUpdating = false; myTlsCheckbox.setSelected(tls); myHohTlsCheckbox.setSelected(tls); myHoHUrlTextField.setBackground(Color.white); } catch (MalformedURLException e) { myHoHUrlTextField.setBackground(ERROR_BG); } } }); GridBagConstraints gbc_HohUsernameTextbox = new GridBagConstraints(); gbc_HohUsernameTextbox.fill = GridBagConstraints.HORIZONTAL; gbc_HohUsernameTextbox.gridx = 1; gbc_HohUsernameTextbox.gridy = 0; mypanel.add(myHoHUrlTextField, gbc_HohUsernameTextbox); myHoHUrlTextField.setColumns(10); JLabel lblEncoding = new JLabel("Encoding"); GridBagConstraints gbc_lblEncoding = new GridBagConstraints(); gbc_lblEncoding.insets = new Insets(0, 0, 5, 5); gbc_lblEncoding.gridx = 0; gbc_lblEncoding.gridy = 3; add(lblEncoding, gbc_lblEncoding); JPanel encodingPanel = new JPanel(); GridBagConstraints gbc_encodingPanel = new GridBagConstraints(); gbc_encodingPanel.fill = GridBagConstraints.HORIZONTAL; gbc_encodingPanel.insets = new Insets(0, 0, 5, 0); gbc_encodingPanel.gridx = 1; gbc_encodingPanel.gridy = 3; add(encodingPanel, gbc_encodingPanel); encodingPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); GridBagLayout gbl_encodingPanel = new GridBagLayout(); gbl_encodingPanel.columnWidths = new int[] { 144, 58, 0 }; gbl_encodingPanel.rowHeights = new int[] { 23, 0 }; gbl_encodingPanel.columnWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; gbl_encodingPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; encodingPanel.setLayout(gbl_encodingPanel); myXmlRadio = new JRadioButton("XML"); myXmlRadio.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent theE) { updateEncodingModel(); } }); myEr7Radio = new JRadioButton("ER7 (Pipe and hat)"); myEr7Radio.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateEncodingModel(); } }); encodingButtonGroup.add(myEr7Radio); GridBagConstraints gbc_Er7Radio = new GridBagConstraints(); gbc_Er7Radio.anchor = GridBagConstraints.NORTHWEST; gbc_Er7Radio.insets = new Insets(0, 0, 0, 5); gbc_Er7Radio.gridx = 0; gbc_Er7Radio.gridy = 0; encodingPanel.add(myEr7Radio, gbc_Er7Radio); encodingButtonGroup.add(myXmlRadio); GridBagConstraints gbc_XmlRadio = new GridBagConstraints(); gbc_XmlRadio.anchor = GridBagConstraints.NORTHWEST; gbc_XmlRadio.gridx = 1; gbc_XmlRadio.gridy = 0; encodingPanel.add(myXmlRadio, gbc_XmlRadio); JLabel lblCharset = new JLabel("Charset"); GridBagConstraints gbc_lblCharset = new GridBagConstraints(); gbc_lblCharset.insets = new Insets(0, 0, 5, 5); gbc_lblCharset.gridx = 0; gbc_lblCharset.gridy = 4; add(lblCharset, gbc_lblCharset); JPanel panel_2 = new JPanel(); GridBagConstraints gbc_panel_2 = new GridBagConstraints(); gbc_panel_2.fill = GridBagConstraints.HORIZONTAL; gbc_panel_2.insets = new Insets(0, 0, 5, 0); gbc_panel_2.gridx = 1; gbc_panel_2.gridy = 4; add(panel_2, gbc_panel_2); panel_2.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); GridBagLayout gbl_panel_2 = new GridBagLayout(); gbl_panel_2.columnWidths = new int[] { 28, 198, 0, 0 }; gbl_panel_2.rowHeights = new int[] { 27, 0 }; gbl_panel_2.columnWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE }; gbl_panel_2.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; panel_2.setLayout(gbl_panel_2); myCharsetSelectRadio = new JRadioButton(""); myCharsetSelectRadio.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateCharsetModel(); } }); charsetButtonGroup.add(myCharsetSelectRadio); GridBagConstraints gbc_CharsetSelectRadio = new GridBagConstraints(); gbc_CharsetSelectRadio.anchor = GridBagConstraints.WEST; gbc_CharsetSelectRadio.insets = new Insets(0, 0, 0, 5); gbc_CharsetSelectRadio.gridx = 0; gbc_CharsetSelectRadio.gridy = 0; panel_2.add(myCharsetSelectRadio, gbc_CharsetSelectRadio); myCharsetCombo = new JComboBox(); myCharsetCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateCharsetModel(); } }); GridBagConstraints gbc_CharsetCombo = new GridBagConstraints(); gbc_CharsetCombo.anchor = GridBagConstraints.NORTHWEST; gbc_CharsetCombo.insets = new Insets(0, 0, 0, 5); gbc_CharsetCombo.gridx = 1; gbc_CharsetCombo.gridy = 0; panel_2.add(myCharsetCombo, gbc_CharsetCombo); myCharsetDetectRadio = new JRadioButton("Detect in Message (MSH-18)"); myCharsetDetectRadio.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateCharsetModel(); } }); charsetButtonGroup.add(myCharsetDetectRadio); GridBagConstraints gbc_CharsetDetectRadio = new GridBagConstraints(); gbc_CharsetDetectRadio.anchor = GridBagConstraints.NORTH; gbc_CharsetDetectRadio.gridwidth = 2; gbc_CharsetDetectRadio.gridx = 2; gbc_CharsetDetectRadio.gridy = 0; panel_2.add(myCharsetDetectRadio, gbc_CharsetDetectRadio); mylabel_5 = new JLabel("Debug"); GridBagConstraints gbc_label_5 = new GridBagConstraints(); gbc_label_5.insets = new Insets(0, 0, 5, 5); gbc_label_5.gridx = 0; gbc_label_5.gridy = 5; add(mylabel_5, gbc_label_5); mypanel_2 = new JPanel(); mypanel_2.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); GridBagConstraints gbc_panel_75 = new GridBagConstraints(); gbc_panel_75.insets = new Insets(0, 0, 5, 0); gbc_panel_75.fill = GridBagConstraints.BOTH; gbc_panel_75.gridx = 1; gbc_panel_75.gridy = 5; add(mypanel_2, gbc_panel_75); GridBagLayout gbl_panel_74 = new GridBagLayout(); gbl_panel_74.columnWidths = new int[] { 0, 0 }; gbl_panel_74.rowHeights = new int[] { 0, 0 }; gbl_panel_74.columnWeights = new double[] { 0.0, Double.MIN_VALUE }; gbl_panel_74.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; mypanel_2.setLayout(gbl_panel_74); myCaptureByteStreamCheckbox = new JCheckBox("Capture Bytes"); GridBagConstraints gbc_CaptureByteStreamCheckbox = new GridBagConstraints(); gbc_CaptureByteStreamCheckbox.gridx = 0; gbc_CaptureByteStreamCheckbox.gridy = 0; mypanel_2.add(myCaptureByteStreamCheckbox, gbc_CaptureByteStreamCheckbox); myCaptureByteStreamCheckbox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myConnection.setCaptureBytes(myCaptureByteStreamCheckbox.isSelected()); } }); myCaptureByteStreamCheckbox.setToolTipText("Check this box to capture the transport level communication"); myInterfaceTypeCardPanel = new JPanel(); myInterfaceTypeCardPanel.setBorder(null); GridBagConstraints gbc_InterfaceTypeCardPanel = new GridBagConstraints(); gbc_InterfaceTypeCardPanel.gridwidth = 2; gbc_InterfaceTypeCardPanel.fill = GridBagConstraints.BOTH; gbc_InterfaceTypeCardPanel.gridx = 0; gbc_InterfaceTypeCardPanel.gridy = 6; add(myInterfaceTypeCardPanel, gbc_InterfaceTypeCardPanel); myInterfaceTypeCardPanel.setLayout(new CardLayout(0, 0)); myMllpCard = new JPanel(); myMllpCard.setBorder(null); myInterfaceTypeCardPanel.add(myMllpCard, IFACE_TYPE_CARD_MLLP); GridBagLayout gbl_MllpCard = new GridBagLayout(); gbl_MllpCard.columnWidths = new int[] { 150, 0, 0 }; gbl_MllpCard.rowHeights = new int[] { 0, 0, 0, 0 }; gbl_MllpCard.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE }; gbl_MllpCard.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE }; myMllpCard.setLayout(gbl_MllpCard); JLabel lblHost = new JLabel("Host"); GridBagConstraints gbc_lblHost = new GridBagConstraints(); gbc_lblHost.insets = new Insets(0, 0, 5, 5); gbc_lblHost.gridx = 0; gbc_lblHost.gridy = 0; myMllpCard.add(lblHost, gbc_lblHost); mypanel_1 = new JPanel(); mypanel_1.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); GridBagConstraints gbc_panel_1 = new GridBagConstraints(); gbc_panel_1.insets = new Insets(0, 0, 5, 0); gbc_panel_1.fill = GridBagConstraints.BOTH; gbc_panel_1.gridx = 1; gbc_panel_1.gridy = 0; myMllpCard.add(mypanel_1, gbc_panel_1); GridBagLayout gbl_panel_1 = new GridBagLayout(); gbl_panel_1.columnWidths = new int[] { 134, 0 }; gbl_panel_1.rowHeights = new int[] { 28, 0 }; gbl_panel_1.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_panel_1.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; mypanel_1.setLayout(gbl_panel_1); myHostBox = new JTextField(); GridBagConstraints gbc_HostBox = new GridBagConstraints(); gbc_HostBox.fill = GridBagConstraints.HORIZONTAL; gbc_HostBox.anchor = GridBagConstraints.NORTH; gbc_HostBox.gridx = 0; gbc_HostBox.gridy = 0; mypanel_1.add(myHostBox, gbc_HostBox); myHostBox.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent theE) { myConnection.setHost(myHostBox.getText()); } }); myHostBox.setColumns(10); JLabel lblTransport = new JLabel("Transport"); GridBagConstraints gbc_lblTransport = new GridBagConstraints(); gbc_lblTransport.insets = new Insets(0, 0, 5, 5); gbc_lblTransport.gridx = 0; gbc_lblTransport.gridy = 1; myMllpCard.add(lblTransport, gbc_lblTransport); JPanel panel_3 = new JPanel(); GridBagConstraints gbc_hohAuthPanel = new GridBagConstraints(); gbc_hohAuthPanel.fill = GridBagConstraints.HORIZONTAL; gbc_hohAuthPanel.insets = new Insets(0, 0, 5, 0); gbc_hohAuthPanel.gridx = 1; gbc_hohAuthPanel.gridy = 1; myMllpCard.add(panel_3, gbc_hohAuthPanel); panel_3.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); GridBagLayout gbl_hohAuthPanel = new GridBagLayout(); gbl_hohAuthPanel.columnWidths = new int[] { 0, 0, 0 }; gbl_hohAuthPanel.rowHeights = new int[] { 0, 0 }; gbl_hohAuthPanel.columnWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; gbl_hohAuthPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; panel_3.setLayout(gbl_hohAuthPanel); myTlsCheckbox = new JCheckBox("Use TLS/SSL"); myTlsCheckbox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myHohTlsCheckbox.setSelected(myTlsCheckbox.isSelected()); myConnection.setTls(myTlsCheckbox.isSelected()); } }); GridBagConstraints gbc_TlsCheckbox = new GridBagConstraints(); gbc_TlsCheckbox.insets = new Insets(0, 0, 0, 5); gbc_TlsCheckbox.anchor = GridBagConstraints.WEST; gbc_TlsCheckbox.gridx = 0; gbc_TlsCheckbox.gridy = 0; panel_3.add(myTlsCheckbox, gbc_TlsCheckbox); myHoHCard = new JPanel(); myInterfaceTypeCardPanel.add(myHoHCard, IFACE_TYPE_CARD_HOH); GridBagLayout gbl_HoHCard = new GridBagLayout(); gbl_HoHCard.columnWidths = new int[] { 150, 0, 0 }; gbl_HoHCard.rowHeights = new int[] { 0, 0, 0, 0 }; gbl_HoHCard.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE }; gbl_HoHCard.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE }; myHoHCard.setLayout(gbl_HoHCard); mylabel_6 = new JLabel("Authorization"); GridBagConstraints gbc_label_6 = new GridBagConstraints(); gbc_label_6.insets = new Insets(0, 0, 5, 5); gbc_label_6.gridx = 0; gbc_label_6.gridy = 0; myHoHCard.add(mylabel_6, gbc_label_6); hohAuthPanel = new JPanel(); hohAuthPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); GridBagConstraints gbc_hohAuthPanel2 = new GridBagConstraints(); gbc_hohAuthPanel2.insets = new Insets(0, 0, 5, 0); gbc_hohAuthPanel2.fill = GridBagConstraints.BOTH; gbc_hohAuthPanel2.gridx = 1; gbc_hohAuthPanel2.gridy = 0; myHoHCard.add(hohAuthPanel, gbc_hohAuthPanel2); GridBagLayout gbl_hohAuthPanel3 = new GridBagLayout(); gbl_hohAuthPanel3.columnWidths = new int[] { 0, 0, 0, 0, 0, 0, 0 }; gbl_hohAuthPanel3.rowHeights = new int[] { 0, 0 }; gbl_hohAuthPanel3.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE }; gbl_hohAuthPanel3.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; hohAuthPanel.setLayout(gbl_hohAuthPanel3); myHohAuthEnabledCheckbox = new JCheckBox("Enabled"); myHohAuthEnabledCheckbox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent theE) { myConnection.setHohAuthenticationEnabled(myHohAuthEnabledCheckbox.isSelected()); } }); GridBagConstraints gbc_HohAuthEnabledCheckbox = new GridBagConstraints(); gbc_HohAuthEnabledCheckbox.insets = new Insets(0, 0, 0, 5); gbc_HohAuthEnabledCheckbox.gridx = 0; gbc_HohAuthEnabledCheckbox.gridy = 0; hohAuthPanel.add(myHohAuthEnabledCheckbox, gbc_HohAuthEnabledCheckbox); mylabel_7 = new JLabel("Username:"); GridBagConstraints gbc_label_7 = new GridBagConstraints(); gbc_label_7.insets = new Insets(0, 0, 0, 5); gbc_label_7.anchor = GridBagConstraints.EAST; gbc_label_7.gridx = 1; gbc_label_7.gridy = 0; hohAuthPanel.add(mylabel_7, gbc_label_7); myHohAuthUsernameTextbox = new JTextField(); myHohAuthUsernameTextbox.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent theE) { myConnection.setHohAuthenticationUsername(myHohAuthUsernameTextbox.getText()); } }); myHohAuthUsernameTextbox.setMaximumSize(new Dimension(200, 2147483647)); myHohAuthUsernameTextbox.setMinimumSize(new Dimension(100, 28)); myHohAuthUsernameTextbox.setPreferredSize(new Dimension(100, 28)); GridBagConstraints gbc_HohUsernameTextbox2 = new GridBagConstraints(); gbc_HohUsernameTextbox2.insets = new Insets(0, 0, 0, 5); gbc_HohUsernameTextbox2.fill = GridBagConstraints.HORIZONTAL; gbc_HohUsernameTextbox2.gridx = 2; gbc_HohUsernameTextbox2.gridy = 0; hohAuthPanel.add(myHohAuthUsernameTextbox, gbc_HohUsernameTextbox2); myHohAuthUsernameTextbox.setColumns(10); mylabel_8 = new JLabel("Password:"); GridBagConstraints gbc_label_8 = new GridBagConstraints(); gbc_label_8.insets = new Insets(0, 0, 0, 5); gbc_label_8.anchor = GridBagConstraints.EAST; gbc_label_8.gridx = 3; gbc_label_8.gridy = 0; hohAuthPanel.add(mylabel_8, gbc_label_8); myHohAuthPasswordTextbox = new JTextField(); myHohAuthPasswordTextbox.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent theE) { myConnection.setHohAuthenticationPassword(myHohAuthPasswordTextbox.getText()); } }); myHohAuthPasswordTextbox.setPreferredSize(new Dimension(100, 28)); myHohAuthPasswordTextbox.setMaximumSize(new Dimension(200, 2147483647)); myHohAuthPasswordTextbox.setMinimumSize(new Dimension(100, 28)); GridBagConstraints gbc_textField = new GridBagConstraints(); gbc_textField.insets = new Insets(0, 0, 0, 5); gbc_textField.fill = GridBagConstraints.HORIZONTAL; gbc_textField.gridx = 4; gbc_textField.gridy = 0; hohAuthPanel.add(myHohAuthPasswordTextbox, gbc_textField); myHohAuthPasswordTextbox.setColumns(10); mylabel_2 = new JLabel("Security Profile"); GridBagConstraints gbc_label_2 = new GridBagConstraints(); gbc_label_2.insets = new Insets(0, 0, 5, 5); gbc_label_2.gridx = 0; gbc_label_2.gridy = 1; myHoHCard.add(mylabel_2, gbc_label_2); securityProfilePanel = new JPanel(); GridBagConstraints gbc_securityProfilePanel = new GridBagConstraints(); gbc_securityProfilePanel.insets = new Insets(0, 0, 5, 0); gbc_securityProfilePanel.fill = GridBagConstraints.BOTH; gbc_securityProfilePanel.gridx = 1; gbc_securityProfilePanel.gridy = 1; myHoHCard.add(securityProfilePanel, gbc_securityProfilePanel); securityProfilePanel.setLayout(new BorderLayout(0, 0)); myHohTlsCheckbox = new JCheckBox("TLS Enabled"); myHohTlsCheckbox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myConnection.setTls(myHohTlsCheckbox.isSelected()); myTlsCheckbox.setSelected(myHohTlsCheckbox.isSelected()); updatePortsUi(); } }); securityProfilePanel.add(myHohTlsCheckbox, BorderLayout.WEST); tlsKeystorePanel = new JPanel(); tlsKeystorePanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); securityProfilePanel.add(tlsKeystorePanel, BorderLayout.CENTER); GridBagLayout gbl_tlsKeystorePanel = new GridBagLayout(); gbl_tlsKeystorePanel.columnWidths = new int[] { 58, 107, 77, 0, 0 }; gbl_tlsKeystorePanel.rowHeights = new int[] { 28, 16, 0 }; gbl_tlsKeystorePanel.columnWeights = new double[] { 0.0, 1.0, 1.0, 0.0, Double.MIN_VALUE }; gbl_tlsKeystorePanel.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; tlsKeystorePanel.setLayout(gbl_tlsKeystorePanel); mylabel_3 = new JLabel("Keystore:"); GridBagConstraints gbc_label_3 = new GridBagConstraints(); gbc_label_3.anchor = GridBagConstraints.WEST; gbc_label_3.fill = GridBagConstraints.VERTICAL; gbc_label_3.insets = new Insets(0, 0, 5, 5); gbc_label_3.gridx = 0; gbc_label_3.gridy = 0; tlsKeystorePanel.add(mylabel_3, gbc_label_3); myHohSecurityKeystoreTextbox = new JTextField(); GridBagConstraints gbc_HohKeystoreTextbox = new GridBagConstraints(); gbc_HohKeystoreTextbox.gridwidth = 2; gbc_HohKeystoreTextbox.anchor = GridBagConstraints.NORTH; gbc_HohKeystoreTextbox.fill = GridBagConstraints.HORIZONTAL; gbc_HohKeystoreTextbox.insets = new Insets(0, 0, 5, 5); gbc_HohKeystoreTextbox.gridx = 1; gbc_HohKeystoreTextbox.gridy = 0; tlsKeystorePanel.add(myHohSecurityKeystoreTextbox, gbc_HohKeystoreTextbox); myHohSecurityKeystoreTextbox.setColumns(10); myHohSecurityKeystoreTextbox.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent theE) { String text = myHohSecurityKeystoreTextbox.getText(); myHohSecurityKeyPwTextBox.setEnabled(isNotBlank(text)); myConnection.setTlsKeystoreLocation(text); scheduleHohSecurityKeystoreCheck(); } }); myHohSecurityKeystoreChooseBtn = new JButton("Choose"); myHohSecurityKeystoreChooseBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String directory = Prefs.getInstance().getInterfaceHohSecurityKeystoreDirectory(); directory = StringUtils.defaultString(directory, "."); JFileChooser chooser = new JFileChooser(directory); chooser.setDialogType(JFileChooser.OPEN_DIALOG); chooser.setDialogTitle("Select a Java Keystore"); int result = chooser.showOpenDialog(Hl7ConnectionPanelBackup.this); if (result == JFileChooser.APPROVE_OPTION) { Prefs.getInstance() .setInterfaceHohSecurityKeystoreDirectory(chooser.getSelectedFile().getParent()); myHohSecurityKeystoreTextbox.setText(chooser.getSelectedFile().getAbsolutePath()); } } }); myHohSecurityKeystoreChooseBtn.setIcon(new ImageIcon( Hl7ConnectionPanelBackup.class.getResource("/ca/uhn/hl7v2/testpanel/images/open.png"))); GridBagConstraints gbc_button = new GridBagConstraints(); gbc_button.insets = new Insets(0, 0, 5, 0); gbc_button.gridx = 3; gbc_button.gridy = 0; tlsKeystorePanel.add(myHohSecurityKeystoreChooseBtn, gbc_button); mylabel_4 = new JLabel("Store Pass:"); GridBagConstraints gbc_label_4 = new GridBagConstraints(); gbc_label_4.insets = new Insets(0, 0, 0, 5); gbc_label_4.anchor = GridBagConstraints.EAST; gbc_label_4.gridx = 0; gbc_label_4.gridy = 1; tlsKeystorePanel.add(mylabel_4, gbc_label_4); myHohSecurityKeyPwTextBox = new JTextField(); myHohSecurityKeyPwTextBox.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent theE) { myConnection.setTlsKeystorePassword(myHohSecurityKeyPwTextBox.getText()); scheduleHohSecurityKeystoreCheck(); } }); GridBagConstraints gbc_HohSecurityKeyPwTextBox = new GridBagConstraints(); gbc_HohSecurityKeyPwTextBox.insets = new Insets(0, 0, 0, 5); gbc_HohSecurityKeyPwTextBox.fill = GridBagConstraints.HORIZONTAL; gbc_HohSecurityKeyPwTextBox.gridx = 1; gbc_HohSecurityKeyPwTextBox.gridy = 1; tlsKeystorePanel.add(myHohSecurityKeyPwTextBox, gbc_HohSecurityKeyPwTextBox); myHohSecurityKeyPwTextBox.setColumns(10); myHohSecurityProfileKeystoreStatus = new JLabel("Value goes here"); myHohSecurityProfileKeystoreStatus.setHorizontalAlignment(SwingConstants.LEFT); GridBagConstraints gbc_HohSecurityProfileKeystoreStatus = new GridBagConstraints(); gbc_HohSecurityProfileKeystoreStatus.anchor = GridBagConstraints.NORTH; gbc_HohSecurityProfileKeystoreStatus.fill = GridBagConstraints.HORIZONTAL; gbc_HohSecurityProfileKeystoreStatus.gridwidth = 2; gbc_HohSecurityProfileKeystoreStatus.gridx = 2; gbc_HohSecurityProfileKeystoreStatus.gridy = 1; tlsKeystorePanel.add(myHohSecurityProfileKeystoreStatus, gbc_HohSecurityProfileKeystoreStatus); init(); }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopFieldGroup.java
protected void reattachColumnFields(int colIndex) { fields.values().stream().filter(FieldConfig::isBound).map(fieldConfig -> ((FieldConfigImpl) fieldConfig)) .filter(fci -> fci.getColumn() == colIndex).forEach(fci -> { impl.remove(fci.getCompositionNN().getComposition()); if (fci.getLabel() != null) { impl.remove(fci.getLabel()); }/* www . ja v a 2 s. co m*/ if (fci.getToolTipButton() != null) { impl.remove(fci.getToolTipButton()); } }); List<FieldConfig> columnFCs = columnFieldMapping.get(colIndex); int insertRowIndex = 0; for (FieldConfig fc : columnFCs) { if (fc.isBound()) { FieldConfigImpl fci = (FieldConfigImpl) fc; Component fieldComponent = fci.getComponentNN(); JComponent composition = fieldComponent.unwrapComposition(JComponent.class); JLabel label = fci.getLabel(); if (label != null) { int preferredCaptionWidth = getPreferredCaptionWidth(colIndex); if (preferredCaptionWidth > 0) { label.setPreferredSize(new Dimension(preferredCaptionWidth, 25)); label.setMaximumSize(new Dimension(preferredCaptionWidth, 25)); label.setMinimumSize(new Dimension(preferredCaptionWidth, 25)); } else { label.setPreferredSize(new Dimension(label.getPreferredSize().width, 25)); } label.setVisible(fieldComponent.isVisible()); CC labelCc = new CC(); MigLayoutHelper.applyAlignment(labelCc, Alignment.TOP_LEFT); impl.add(label, labelCc.cell(colIndex * 3, insertRowIndex, 1, 1)); } ToolTipButton toolTipButton = fci.getToolTipButton(); if (fci.getToolTipButton() != null) { updateTooltipButton(fci, fieldComponent); DesktopToolTipManager.getInstance().registerTooltip(toolTipButton); impl.add(toolTipButton, new CC().cell(colIndex * 3 + 2, insertRowIndex, 1, 1).alignY("top")); } CC cell = new CC().cell(colIndex * 3 + 1, insertRowIndex, 1, 1); MigLayoutHelper.applyWidth(cell, (int) fieldComponent.getWidth(), fieldComponent.getWidthUnits(), false); MigLayoutHelper.applyHeight(cell, (int) fieldComponent.getHeight(), fieldComponent.getHeightUnits(), false); MigLayoutHelper.applyAlignment(cell, fieldComponent.getAlignment()); composition.putClientProperty(getSwingPropertyId(), fci.getId()); impl.add(composition, cell); insertRowIndex++; } } impl.validate(); impl.repaint(); }