/** * Adds contact entry labels. * * @param nameLabelGridWidth the grid width of the contact entry name label */ private void addLabels(int nameLabelGridWidth) { remove(nameLabel); remove(rightLabel); remove(displayDetailsLabel); if (treeNode != null && !(treeNode instanceof GroupNode)) constraints.insets = new Insets(0, 0, V_GAP, H_GAP); else constraints.insets = new Insets(0, 0, 0, H_GAP); constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 0; constraints.weightx = 1f; constraints.weighty = 0f; constraints.gridheight = 1; constraints.gridwidth = nameLabelGridWidth; this.add(nameLabel, constraints); constraints.anchor = GridBagConstraints.NORTHEAST; constraints.fill = GridBagConstraints.VERTICAL; constraints.gridx = nameLabelGridWidth + 1; constraints.gridy = 0; constraints.gridheight = 3; constraints.weightx = 0f; constraints.weighty = 1f; this.add(rightLabel, constraints); if (treeNode != null && treeNode instanceof ContactNode) { constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 1; constraints.weightx = 1f; constraints.weighty = 0f; constraints.gridwidth = nameLabelGridWidth; constraints.gridheight = 1; this.add(displayDetailsLabel, constraints); } else if (treeNode != null && treeNode instanceof GroupNode) { constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 1; constraints.weightx = 1f; constraints.weighty = 0f; constraints.gridwidth = nameLabelGridWidth; constraints.gridheight = 1; this.add(displayDetailsLabel, constraints); } }
// Initializing this component. private void jbInit() { callStackTable.addFocusListener( new FocusListener() { public void focusGained(FocusEvent e) { callStackTable_focusGained(e); } public void focusLost(FocusEvent e) { callStackTable_focusLost(e); } }); callStackTable.setTableHeader(null); callStackTable.setDefaultRenderer(callStackTable.getColumnClass(0), getCellRenderer()); scrollPane = new JScrollPane(callStackTable); setVisibleRows(DEFAULT_VISIBLE_ROWS); scrollPane.setLocation(0, 27); setBorder(BorderFactory.createEtchedBorder()); // this.setLayout(null); this.setLayout(new GridBagLayout()); nameLbl.setText("Call Stack"); nameLbl.setBounds(new Rectangle(3, 4, 70, 23)); nameLbl.setFont(Utilities.labelsFont); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.ipadx = 0; c.ipady = 0; c.weightx = 1; c.weighty = 1; c.gridwidth = 7; c.gridheight = 1; c.anchor = GridBagConstraints.PAGE_END; c.gridx = 0; c.gridy = 2; this.add(scrollPane, c); c.fill = GridBagConstraints.HORIZONTAL; c.ipadx = 0; c.ipady = 0; c.weightx = 1; c.weighty = 0.0; c.gridwidth = 3; c.gridheight = 1; c.anchor = GridBagConstraints.FIRST_LINE_START; c.gridx = 0; c.gridy = 0; c.insets = new Insets(5, 0, 0, 0); this.add(nameLbl, c); }
private void add(Component c, GridBagConstraints gbc, int x, int y, int w, int h) { gbc.gridx = x; gbc.gridy = y; gbc.gridwidth = w; gbc.gridheight = h; getContentPane().add(c, gbc); }
private int addButton(SIPCommButton button, int gridX, int xBounds, boolean isLast) { lastAddedButton = button; constraints.insets = new Insets(0, 0, V_GAP, 0); constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = gridX; constraints.gridy = 2; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0f; constraints.weighty = 0f; this.add(button, constraints); int yBounds = TOP_BORDER + BOTTOM_BORDER + 2 * V_GAP + ComponentUtils.getStringSize(nameLabel, nameLabel.getText()).height + ComponentUtils.getStringSize(displayDetailsLabel, displayDetailsLabel.getText()) .height; button.setBounds(xBounds, yBounds, BUTTON_WIDTH, BUTTON_HEIGHT); button.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); setButtonBg(button, gridX, isLast); return button.getWidth(); }
public static void addToGridBag( GridBagLayout grid, Container cont, Component comp, int x, int y, int gw, int gh, double wx, double wy, int fill, int anchor) { // now the constraints GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = x; gbc.gridy = y; gbc.weightx = wx; gbc.weighty = wy; gbc.fill = fill; gbc.gridwidth = gw; gbc.gridheight = gh; gbc.anchor = anchor; cont.add(comp); grid.setConstraints(comp, gbc); }
public void addForDisplay(CTalkativeTextPane pane, LabelPair<String, String> lp) { GridBagLayout gridbag = (GridBagLayout) getLayout(); labelPair = lp; label = new JLabel(labelPair.getSingular(), JLabel.LEFT); pane.getDocument().addDocumentListener(this); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.1; c.weighty = 0.1; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 20, 0, 00); gridbag.setConstraints(pane, c); add(pane); c = new GridBagConstraints(); c.gridx = 1; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.1; c.weighty = 0.1; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 20); gridbag.setConstraints(label, c); add(label); JPanel filler = new JPanel(); filler.setBackground(white); c = new GridBagConstraints(); c.gridx = 2; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.8; c.weighty = 0.8; c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.LINE_END; gridbag.setConstraints(filler, c); add(filler); filler = null; c = null; }
/** * Hilfsmethode für das GridBagLayout zur Positionierung der Elemente. * * @param x die x-Position im Grid * @param y die y-Position im Grid * @param width gibt die Anzahl der Spalten an, die die Komponente nutzen soll * @param height gibt die Anzahl der Zeilen an, die die Komponente nutzen soll * @return die Rahmenbedingungen für eine Komponente */ private GridBagConstraints makegbc(int x, int y, int width, int height) { GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = x; gbc.gridy = y; gbc.gridwidth = width; gbc.gridheight = height; gbc.insets = new Insets(1, 5, 1, 1); return gbc; }
protected GridBagConstraints createConstraints(int x, int y) { GridBagConstraints c = new GridBagConstraints(); c.gridx = x; c.gridy = y; c.gridwidth = 2; c.gridheight = 1; c.ipadx = 1; c.weightx = 0.5; c.weighty = 0.5; c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.CENTER; return c; }
/* * helper class to initialize empty spaces * @param int x - column of button * @param int y - row of button * @param Dimension btnSize - sets the size of the button */ public void createBlankButtons(int x, int y, Dimension btnSize) { String output = ""; Font clueFont = new Font("Arial", Font.PLAIN, 8); // initialize next myButton btn[activeMyButtons] = new myButton(); String toolTip = ("" + activeMyButtons); btn[activeMyButtons].setDefaultToolTipText(toolTip); btn[activeMyButtons].setToolTipText(toolTip); // get next available myButton and assign current position btn[activeMyButtons].positionX = x; btn[activeMyButtons].positionY = y; btn[activeMyButtons].button = activeMyButtons; btn[activeMyButtons].setPreferredSize(btnSize); btn[activeMyButtons].setFont(clueFont); // assign GridBagConstraints for //position cons.gridx = x; cons.gridy = y; cons.gridwidth = 1; cons.gridheight = 1; cons.ipadx = 0; cons.ipady = 0; // determine position and set alternating color if (((x % 2 == 0) && (y % 2 == 0)) || ((x % 2 != 0) && (y % 2 != 0))) { btn[activeMyButtons].setBackground(new Color(152, 86, 112)); btn[activeMyButtons].setDefaultColor(new Color(152, 86, 112)); } else { btn[activeMyButtons].setBackground(new Color(128, 48, 82)); btn[activeMyButtons].setDefaultColor(new Color(128, 48, 82)); } btn[activeMyButtons].setOpaque(true); btn[activeMyButtons].setBorderPainted(false); // add button to boardPanel this.add(btn[activeMyButtons], cons); btn[activeMyButtons].addActionListener(new myActionListener()); validate(); // pass output to setOutput() output = "activeMyButtons: " + activeMyButtons + " " + btn[activeMyButtons].getDefaultColor(); // setOutput(output); activeMyButtons++; }
/** * Initializes the display details component for the given <tt>UIContact</tt>. * * @param displayDetails the display details to show */ private void initDisplayDetails(String displayDetails) { remove(displayDetailsLabel); displayDetailsLabel.setText(""); if (displayDetails != null && displayDetails.length() > 0) { // Replace all occurrences of new line with slash. displayDetails = Html2Text.extractText(displayDetails); displayDetails = displayDetails.replaceAll("\n|<br>|<br/>", " / "); displayDetailsLabel.setText(displayDetails); } constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 1; constraints.weightx = 1f; constraints.weighty = 0f; constraints.gridwidth = 1; constraints.gridheight = 1; this.add(displayDetailsLabel, constraints); }
protected void populateDialog(JDialog dlg) { dlg.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); dlg.setResizable(false); dlg.setSize(new Dimension(350, 135)); dlg.setTitle("New TurboVNC Connection"); dlg.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { if (VncViewer.nViewers == 1) { if (cc.viewer instanceof VncViewer) { ((VncViewer) cc.viewer).exit(1); } } else { ret = false; endDialog(); } } }); dlg.getContentPane().setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.LINE_START; gbc.fill = GridBagConstraints.BOTH; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.gridheight = 1; gbc.insets = new Insets(0, 0, 0, 0); gbc.ipadx = 0; gbc.ipady = 0; gbc.weightx = 1; gbc.weighty = 1; dlg.getContentPane().add(topPanel, gbc); dlg.getContentPane().add(buttonPanel); dlg.pack(); }
private void initComponents() { setLayout(new BorderLayout()); final JPanel mainPanel = new TransparentPanel(); add(mainPanel, BorderLayout.NORTH); mainPanel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.weightx = 1; c.anchor = GridBagConstraints.LINE_START; c.fill = GridBagConstraints.HORIZONTAL; // general encryption option enableDefaultEncryption = new SIPCommCheckBox( UtilActivator.getResources() .getI18NString("plugin.sipaccregwizz.ENABLE_DEFAULT_ENCRYPTION"), regform.isDefaultEncryption()); enableDefaultEncryption.addActionListener(this); mainPanel.add(enableDefaultEncryption, c); // warning message and button to show advanced options JLabel lblWarning = new JLabel(); lblWarning.setBorder(new EmptyBorder(10, 5, 10, 0)); lblWarning.setText( UtilActivator.getResources() .getI18NString( "plugin.sipaccregwizz.SECURITY_WARNING", new String[] { UtilActivator.getResources().getSettingsString("service.gui.APPLICATION_NAME") })); c.gridy++; mainPanel.add(lblWarning, c); cmdExpandAdvancedSettings = new JLabel(); cmdExpandAdvancedSettings.setBorder(new EmptyBorder(0, 5, 0, 0)); cmdExpandAdvancedSettings.setIcon( UtilActivator.getResources().getImage("service.gui.icons.RIGHT_ARROW_ICON")); cmdExpandAdvancedSettings.setText( UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.SHOW_ADVANCED")); cmdExpandAdvancedSettings.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { cmdExpandAdvancedSettings.setIcon( UtilActivator.getResources() .getImage( pnlAdvancedSettings.isVisible() ? "service.gui.icons.RIGHT_ARROW_ICON" : "service.gui.icons.DOWN_ARROW_ICON")); pnlAdvancedSettings.setVisible(!pnlAdvancedSettings.isVisible()); pnlAdvancedSettings.revalidate(); } }); c.gridy++; mainPanel.add(cmdExpandAdvancedSettings, c); pnlAdvancedSettings = new TransparentPanel(); pnlAdvancedSettings.setLayout(new GridBagLayout()); pnlAdvancedSettings.setVisible(false); c.gridy++; mainPanel.add(pnlAdvancedSettings, c); c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.gridwidth = 2; c.gridheight = 1; c.anchor = GridBagConstraints.LINE_START; c.fill = GridBagConstraints.HORIZONTAL; pnlAdvancedSettings.add(new JSeparator(), c); // Encryption protcol preferences. JLabel lblEncryptionProtocolPreferences = new JLabel(); lblEncryptionProtocolPreferences.setText( UtilActivator.getResources() .getI18NString("plugin.sipaccregwizz.ENCRYPTION_PROTOCOL_PREFERENCES")); c.gridy++; pnlAdvancedSettings.add(lblEncryptionProtocolPreferences, c); int nbEncryptionProtocols = ENCRYPTION_PROTOCOLS.length; String[] encryptions = new String[nbEncryptionProtocols]; boolean[] selectedEncryptions = new boolean[nbEncryptionProtocols]; this.encryptionConfigurationTableModel = new EncryptionConfigurationTableModel(encryptions, selectedEncryptions); loadEncryptionProtocols(new HashMap<String, Integer>(), new HashMap<String, Boolean>()); this.encryptionProtocolPreferences = new PriorityTable(this.encryptionConfigurationTableModel, 60); this.encryptionConfigurationTableModel.addTableModelListener(this); c.gridy++; pnlAdvancedSettings.add(this.encryptionProtocolPreferences, c); // ZRTP JLabel lblZrtpOption = new JLabel(); lblZrtpOption.setBorder(new EmptyBorder(5, 5, 5, 0)); lblZrtpOption.setText( UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.ZRTP_OPTION")); c.gridx = 0; c.gridy++; c.gridwidth = 1; pnlAdvancedSettings.add(lblZrtpOption, c); c.gridx = 1; pnlAdvancedSettings.add(new JSeparator(), c); enableSipZrtpAttribute = new SIPCommCheckBox( UtilActivator.getResources() .getI18NString("plugin.sipaccregwizz.ENABLE_SIPZRTP_ATTRIBUTE"), regform.isSipZrtpAttribute()); c.gridx = 0; c.gridy++; c.gridwidth = 2; pnlAdvancedSettings.add(enableSipZrtpAttribute, c); // SDES JLabel lblSDesOption = new JLabel(); lblSDesOption.setBorder(new EmptyBorder(5, 5, 5, 0)); lblSDesOption.setText( UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.SDES_OPTION")); c.gridx = 0; c.gridy++; c.gridwidth = 1; pnlAdvancedSettings.add(lblSDesOption, c); c.gridx = 1; pnlAdvancedSettings.add(new JSeparator(), c); JLabel lblCipherInfo = new JLabel(); lblCipherInfo.setText( UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.CIPHER_SUITES")); c.gridx = 0; c.gridy++; c.gridwidth = 2; pnlAdvancedSettings.add(lblCipherInfo, c); cipherModel = new CipherTableModel(regform.getSDesCipherSuites()); tabCiphers = new JTable(cipherModel); tabCiphers.setShowGrid(false); tabCiphers.setTableHeader(null); TableColumnModel tableColumnModel = tabCiphers.getColumnModel(); TableColumn tableColumn = tableColumnModel.getColumn(0); tableColumn.setMaxWidth(tableColumn.getMinWidth()); JScrollPane scrollPane = new JScrollPane(tabCiphers); scrollPane.setPreferredSize(new Dimension(tabCiphers.getWidth(), 100)); c.gridy++; pnlAdvancedSettings.add(scrollPane, c); // SAVP selection c.gridx = 0; c.gridwidth = 1; JLabel lblSavpOption = new JLabel(); lblSavpOption.setBorder(new EmptyBorder(5, 5, 5, 0)); lblSavpOption.setText( UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.SAVP_OPTION")); if (this.displaySavpOtions) { c.gridy++; pnlAdvancedSettings.add(lblSavpOption, c); } c.gridx = 1; if (this.displaySavpOtions) { pnlAdvancedSettings.add(new JSeparator(), c); } cboSavpOption = new JComboBox(new SavpOption[] {new SavpOption(0), new SavpOption(1), new SavpOption(2)}); c.gridx = 0; c.gridwidth = 2; c.insets = new Insets(0, 20, 0, 0); if (this.displaySavpOtions) { c.gridy++; pnlAdvancedSettings.add(cboSavpOption, c); } }
/** * Initializes the GUI by creating the components, placing them in the dialog, and displaying * them. */ private void init() { setForeground(Color.black); setTitle("Nonlocal Means Filter"); JPanel mainPanel; mainPanel = new JPanel(); mainPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); mainPanel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = 1; gbc.gridheight = 1; gbc.anchor = GridBagConstraints.WEST; gbc.weightx = 1; gbc.insets = new Insets(3, 3, 3, 3); gbc.gridx = 0; gbc.gridy = 0; gbc.fill = GridBagConstraints.HORIZONTAL; paramPanel = new JPanel(new GridBagLayout()); paramPanel.setForeground(Color.black); paramPanel.setBorder(buildTitledBorder("Parameters")); mainPanel.add(paramPanel, gbc); GridBagConstraints gbc2 = new GridBagConstraints(); gbc2.gridwidth = 1; gbc2.gridheight = 1; gbc2.anchor = GridBagConstraints.WEST; gbc2.weightx = 1; gbc2.insets = new Insets(3, 3, 3, 3); gbc2.gridx = 0; gbc2.gridy = 0; gbc2.fill = GridBagConstraints.HORIZONTAL; labelSearchWindowSide = createLabel("Search window side (odd)"); paramPanel.add(labelSearchWindowSide, gbc2); gbc2.gridx = 1; textSearchWindowSide = createTextField("15"); paramPanel.add(textSearchWindowSide, gbc2); gbc2.gridx = 0; gbc2.gridy = 1; labelSimilarityWindowSide = createLabel("Similarity window side (odd) "); paramPanel.add(labelSimilarityWindowSide, gbc2); gbc2.gridx = 1; textSimilarityWindowSide = createTextField("7"); paramPanel.add(textSimilarityWindowSide, gbc2); gbc2.gridx = 0; gbc2.gridy = 2; labelNoiseStandardDeviation = createLabel("Noise standard deviation "); paramPanel.add(labelNoiseStandardDeviation, gbc2); gbc2.gridx = 1; textNoiseStandardDeviation = createTextField("10.0"); paramPanel.add(textNoiseStandardDeviation, gbc2); gbc2.gridx = 0; gbc2.gridy = 3; labelDegree = createLabel("Degree of filtering "); labelDegree.setEnabled(doRician); paramPanel.add(labelDegree, gbc2); gbc2.gridx = 1; textDegree = createTextField("1.414"); textDegree.setEnabled(doRician); paramPanel.add(textDegree, gbc2); gbc2.gridx = 0; gbc2.gridy = 4; doRicianCheckBox = new JCheckBox("Deal with Rician noise in MRI"); doRicianCheckBox.setFont(serif12); doRicianCheckBox.setSelected(false); doRicianCheckBox.addActionListener(this); paramPanel.add(doRicianCheckBox, gbc2); if (image.getNDims() > 2) { gbc2.gridx = 0; gbc2.gridy = 5; gbc2.gridwidth = 2; image25DCheckBox = new JCheckBox("Process each slice independently (2.5D)"); image25DCheckBox.setFont(serif12); paramPanel.add(image25DCheckBox, gbc2); image25DCheckBox.setSelected(false); } // if (image.getNDims > 2) JPanel outputOptPanel = new JPanel(new GridLayout(1, 2)); destinationPanel = new JPanel(new BorderLayout()); destinationPanel.setForeground(Color.black); destinationPanel.setBorder(buildTitledBorder("Destination")); outputOptPanel.add(destinationPanel); destinationGroup = new ButtonGroup(); newImage = new JRadioButton("New image", true); newImage.setBounds(10, 16, 120, 25); newImage.setFont(serif12); destinationGroup.add(newImage); destinationPanel.add(newImage, BorderLayout.NORTH); replaceImage = new JRadioButton("Replace image", false); replaceImage.setFont(serif12); destinationGroup.add(replaceImage); destinationPanel.add(replaceImage, BorderLayout.CENTER); // Only if the image is unlocked can it be replaced. if (image.getLockStatus() == ModelStorageBase.UNLOCKED) { replaceImage.setEnabled(true); } else { replaceImage.setEnabled(false); } gbc.gridx = 0; gbc.gridy = 1; mainPanel.add(outputOptPanel, gbc); mainDialogPanel.add(mainPanel, BorderLayout.CENTER); mainDialogPanel.add(buildButtons(), BorderLayout.SOUTH); getContentPane().add(mainDialogPanel); pack(); setResizable(true); // setVisible(true); System.gc(); }
/* * main constructor * @param debug - boolean for debug mode */ public boardPanel(boolean debug) { // initial constructor super(); debugBoardPanel = debug; // continue defining boardPanel this.setLayout(new GridBagLayout()); cons.fill = GridBagConstraints.BOTH; cons.insets = new Insets(0, 0, 0, 0); cons.anchor = GridBagConstraints.FIRST_LINE_START; this.setVisible(true); // button preferred size Dimension btnSize = new Dimension(25, 25); // top row // ------------------------------------------------------------------------------------------ // spa btnSpa = new JButton("Spa"); allRooms[0] = btnSpa; btnSpa.setPreferredSize(btnSize); cons.gridx = 0; cons.gridy = 0; cons.gridwidth = 5; cons.gridheight = 5; btnSpa.setBackground(defaultRoomColor); btnSpa.setOpaque(true); btnSpa.setBorderPainted(false); btnSpa.addActionListener(new myActionListener()); this.add(btnSpa, cons); // space buttons for (int y = 0; y < 5; y++) { for (int x = 5; x < 10; x++) { createBlankButtons(x, y, btnSize); } } // theater btnTheater = new JButton("Theater"); allRooms[1] = btnTheater; btnTheater.setPreferredSize(btnSize); cons.gridx = 10; cons.gridy = 0; cons.gridwidth = 5; cons.gridheight = 5; btnTheater.setOpaque(true); btnTheater.setBorderPainted(false); btnTheater.setBackground(defaultRoomColor); btnTheater.addActionListener(new myActionListener()); this.add(btnTheater, cons); // space buttons for (int y = 0; y < 5; y++) { for (int x = 15; x < 20; x++) { createBlankButtons(x, y, btnSize); } } // Living Room btnLivingRoom = new JButton("Living Room"); allRooms[2] = btnLivingRoom; btnLivingRoom.setPreferredSize(btnSize); cons.gridx = 20; cons.gridy = 0; cons.gridwidth = 5; cons.gridheight = 5; btnLivingRoom.setBackground(defaultRoomColor); btnLivingRoom.setOpaque(true); btnLivingRoom.setBorderPainted(false); btnLivingRoom.addActionListener(new myActionListener()); this.add(btnLivingRoom, cons); // space buttons for (int y = 0; y < 5; y++) { for (int x = 25; x < 30; x++) { createBlankButtons(x, y, btnSize); } } // observatory btnObservatory = new JButton("Observatory"); allRooms[3] = btnObservatory; btnObservatory.setPreferredSize(btnSize); cons.gridx = 30; cons.gridy = 0; cons.gridwidth = 5; cons.gridheight = 5; btnObservatory.setBackground(defaultRoomColor); btnObservatory.setOpaque(true); btnObservatory.setBorderPainted(false); btnObservatory.addActionListener(new myActionListener()); this.add(btnObservatory, cons); // top to middle spaces // ------------------------------------------------------------------------------------------ // space buttons for (int y = 5; y < 10; y++) { for (int x = 0; x < 35; x++) { createBlankButtons(x, y, btnSize); } } // middle row // ------------------------------------------------------------------------------------------ // Patio btnPatio = new JButton("Patio"); allRooms[4] = btnPatio; btnPatio.setPreferredSize(btnSize); cons.gridx = 0; cons.gridy = 10; cons.gridwidth = 5; cons.gridheight = 5; btnPatio.setBackground(defaultRoomColor); btnPatio.setOpaque(true); btnPatio.setBorderPainted(false); btnPatio.addActionListener(new myActionListener()); this.add(btnPatio, cons); // space buttons for (int y = 10; y < 15; y++) { for (int x = 5; x < 10; x++) { createBlankButtons(x, y, btnSize); } } // pool btnPool = new JButton("Pool"); allRooms[5] = btnPool; btnPool.setPreferredSize(btnSize); cons.gridx = 10; cons.gridy = 10; cons.gridwidth = 15; cons.gridheight = 5; btnPool.setBackground(defaultPoolColor); btnPool.setOpaque(true); btnPool.setBorderPainted(false); btnPool.addActionListener(new myActionListener()); this.add(btnPool, cons); // space buttons for (int y = 10; y < 15; y++) { for (int x = 25; x < 30; x++) { createBlankButtons(x, y, btnSize); } } // Hall btnHall = new JButton("Hall"); allRooms[6] = btnHall; btnHall.setPreferredSize(btnSize); cons.gridx = 30; cons.gridy = 10; cons.gridwidth = 5; cons.gridheight = 5; btnHall.setBackground(defaultRoomColor); btnHall.setOpaque(true); btnHall.setBorderPainted(false); btnHall.addActionListener(new myActionListener()); this.add(btnHall, cons); // middle to bottom spaces // ------------------------------------------------------------------------------------------ // space buttons for (int y = 15; y < 20; y++) { for (int x = 0; x < 35; x++) { createBlankButtons(x, y, btnSize); } } // bottom row // ------------------------------------------------------------------------------------------ // Kitchen btnKitchen = new JButton("Kitchen"); allRooms[7] = btnKitchen; btnKitchen.setPreferredSize(btnSize); cons.gridx = 0; cons.gridy = 20; cons.gridwidth = 5; cons.gridheight = 5; btnKitchen.setBackground(defaultRoomColor); btnKitchen.setOpaque(true); btnKitchen.setBorderPainted(false); btnKitchen.addActionListener(new myActionListener()); this.add(btnKitchen, cons); // space buttons for (int y = 20; y < 25; y++) { for (int x = 5; x < 10; x++) { createBlankButtons(x, y, btnSize); } } // dining room btnDiningRoom = new JButton("Dining Room"); allRooms[8] = btnDiningRoom; btnPool.setPreferredSize(btnSize); cons.gridx = 10; cons.gridy = 20; cons.gridwidth = 15; cons.gridheight = 5; btnDiningRoom.setBackground(defaultRoomColor); btnDiningRoom.setOpaque(true); btnDiningRoom.setBorderPainted(false); btnDiningRoom.addActionListener(new myActionListener()); this.add(btnDiningRoom, cons); // space buttons for (int y = 20; y < 25; y++) { for (int x = 25; x < 30; x++) { createBlankButtons(x, y, btnSize); } } // Guest House btnGuestHouse = new JButton("Guest House"); allRooms[9] = btnGuestHouse; btnGuestHouse.setPreferredSize(btnSize); cons.gridx = 30; cons.gridy = 20; cons.gridwidth = 5; cons.gridheight = 5; btnGuestHouse.setBackground(defaultRoomColor); btnGuestHouse.setOpaque(true); btnGuestHouse.setBorderPainted(false); btnGuestHouse.addActionListener(new myActionListener()); this.add(btnGuestHouse, cons); // textArea // ------------------------------------------------------------------------------------------ // create textarea for output cons.gridx = 0; cons.gridy = 25; cons.gridwidth = 35; this.add(jsp, cons); }
/** * Constructs a new {@link FileLoadingPanel} object containing: * * <ul> * <li>loadButton- clicking opens Cytoscape's FileChooser to choose a data file * <li>label - displays the path of the chosen file * <li>textField - can be edited such that an abbreviation for the data set can be given * <li>removeButton - removes this object from the GUI * </ul> * * @param dataPanel - The {@link DataPanel} which created this {@link FileLoadingPanel}. */ public KPMFileLoadingPanel(KPMDataTab dataPanel) { this.dataPanel = dataPanel; fileChooserFilter = new FileChooserFilter("*.csv,*.txt,*.dat", DATA_EXTENSIONS); filterList = new ArrayList<FileChooserFilter>(1); filterList.add(fileChooserFilter); loadButton = new JButton("Load"); loadButton.setToolTipText(LOADBUTTONTIP); JPanel loadButtonPanel = new JPanel(); loadButtonPanel.add(loadButton); loadButtonPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); label = new JLabel(PATHLABELDEFAULT); label.setToolTipText(PATHLABELTIP); textField = new JTextField(ABBREVIATIONFIELDDEFAULT, 20); textField.setToolTipText(TEXTFIELDTIP); nodesCountLabel = new JLabel(""); nodesCountLabel.setToolTipText( "Number of entities in the dataset, for instance genes or proteins."); samplesCountLabel = new JLabel(""); removeButton = new JButton(); JPanel removeButtonPanel = new JPanel(); removeButtonPanel.add(removeButton); removeButtonPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); removeIcon = new ImageIcon(this.getClass().getResource("/minus.png"), "Remove"); removeButton.setIcon(removeIcon); removeButton.setToolTipText(REMOVEBUTTONTIP); id = NOOFPANELS++; addLoadButtonListener(); addRemoveButtonListener(); addTextFieldListener(); setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 0; c.gridheight = 3; add(loadButtonPanel, c); c.gridx = 1; c.gridy = 0; c.weightx = .5; c.gridheight = 1; c.gridwidth = 3; add(label, c); c.gridwidth = 1; c.gridx = 1; c.gridy = 2; add(nodesCountLabel, c); c.gridx = 2; c.gridy = 2; add(samplesCountLabel, c); c.gridx = 1; c.gridy = 1; c.gridwidth = 3; add(textField, c); c.gridx = 4; c.gridy = 0; c.weightx = 0; c.gridheight = 3; c.gridwidth = 1; add(removeButtonPanel, c); // setMaximumSize(new Dimension(Integer.MAX_VALUE, // 3 * removeIcon.getIconHeight())); // Add a border. Border border = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); this.setBorder(border); }
private void recreateEditorsPanel() { myValuesPanel.removeAll(); myValuesPanel.setLayout(new CardLayout()); if (!myProject.isOpen()) return; JPanel valuesPanelComponent = new MyJPanel(new GridBagLayout()); myValuesPanel.add( new JBScrollPane(valuesPanelComponent) { @Override public void updateUI() { super.updateUI(); getViewport().setBackground(UIUtil.getPanelBackground()); } }, VALUES); myValuesPanel.add(myNoPropertySelectedPanel, NO_PROPERTY_SELECTED); List<PropertiesFile> propertiesFiles = myResourceBundle.getPropertiesFiles(); GridBagConstraints gc = new GridBagConstraints( 0, 0, 0, 0, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0); releaseAllEditors(); myTitledPanels.clear(); int y = 0; Editor previousEditor = null; Editor firstEditor = null; for (final PropertiesFile propertiesFile : propertiesFiles) { final Editor editor = createEditor(); final Editor oldEditor = myEditors.put(propertiesFile, editor); if (firstEditor == null) { firstEditor = editor; } if (previousEditor != null) { editor.putUserData( ChooseSubsequentPropertyValueEditorAction.PREV_EDITOR_KEY, previousEditor); previousEditor.putUserData( ChooseSubsequentPropertyValueEditorAction.NEXT_EDITOR_KEY, editor); } previousEditor = editor; if (oldEditor != null) { EditorFactory.getInstance().releaseEditor(oldEditor); } ((EditorEx) editor) .addFocusListener( new FocusChangeListener() { @Override public void focusGained(final Editor editor) { mySelectedEditor = editor; } @Override public void focusLost(final Editor eventEditor) { writeEditorPropertyValue(editor, propertiesFile, null); } }); gc.gridx = 0; gc.gridy = y++; gc.gridheight = 1; gc.gridwidth = GridBagConstraints.REMAINDER; gc.weightx = 1; gc.weighty = 1; gc.anchor = GridBagConstraints.CENTER; Locale locale = propertiesFile.getLocale(); List<String> names = new ArrayList<String>(); if (!Comparing.strEqual(locale.getDisplayLanguage(), null)) { names.add(locale.getDisplayLanguage()); } if (!Comparing.strEqual(locale.getDisplayCountry(), null)) { names.add(locale.getDisplayCountry()); } if (!Comparing.strEqual(locale.getDisplayVariant(), null)) { names.add(locale.getDisplayVariant()); } String title = propertiesFile.getName(); if (!names.isEmpty()) { title += " (" + StringUtil.join(names, "/") + ")"; } JComponent comp = new JPanel(new BorderLayout()) { @Override public Dimension getPreferredSize() { Insets insets = getBorder().getBorderInsets(this); return new Dimension(100, editor.getLineHeight() * 4 + insets.top + insets.bottom); } }; comp.add(editor.getComponent(), BorderLayout.CENTER); comp.setBorder(IdeBorderFactory.createTitledBorder(title, true)); myTitledPanels.put(propertiesFile, (JPanel) comp); valuesPanelComponent.add(comp, gc); } if (previousEditor != null) { previousEditor.putUserData( ChooseSubsequentPropertyValueEditorAction.NEXT_EDITOR_KEY, firstEditor); firstEditor.putUserData( ChooseSubsequentPropertyValueEditorAction.PREV_EDITOR_KEY, previousEditor); } gc.gridx = 0; gc.gridy = y; gc.gridheight = GridBagConstraints.REMAINDER; gc.gridwidth = GridBagConstraints.REMAINDER; gc.weightx = 10; gc.weighty = 1; valuesPanelComponent.add(new JPanel(), gc); selectionChanged(); myValuesPanel.repaint(); UIUtil.invokeAndWaitIfNeeded( new Runnable() { @Override public void run() { updateEditorsFromProperties(); } }); }
public void setup() { setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); title = new JLabel(SHTML + TITLE + elem.title + EHTML); gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.WEST; gbc.gridy = 4; gbc.gridx = 0; gbc.gridwidth = 2; gbc.gridheight = 1; gbc.weighty = 1.0; add(title, gbc); donor = new JLabel(SHTML + DONOR + elem.donor + EHTML); gbc.gridy = 5; add(donor, gbc); subDate = new JLabel(SHTML + SUB_DATE + elem.subDate.toString() + EHTML); gbc.gridy = 6; add(subDate, gbc); objDate = new JLabel(SHTML + OBJ_DATE + elem.objDate.toString() + EHTML); gbc.gridy = 7; add(objDate, gbc); medium = new JLabel(SHTML + MEDIUM + elem.medium + EHTML); gbc.gridy = 8; add(medium, gbc); accNum = new JLabel(SHTML + ACC_NUM + elem.accNum + EHTML); gbc.gridy = 9; add(accNum, gbc); desc = new JLabel(SHTML + DESC + EHTML); // gbc.anchor = GridBagConstraints.PAGE_START; gbc.insets = new Insets(0, 50, 0, 0); gbc.gridy = 4; gbc.gridx = 2; add(desc, gbc); descView = new JTextArea(); descView.setLineWrap(true); descView.setWrapStyleWord(true); descView.setEditable(false); descView.setText(elem.desc); descView.setFont(new Font("Times New Roman", Font.PLAIN, 13)); JScrollPane scrollPane = new JScrollPane(descView); scrollPane.setPreferredSize(new Dimension(225, 100)); // scrollPane.setBorder(null); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); descView.setCaretPosition(0); gbc.gridy = 5; gbc.gridheight = 4; gbc.gridx = 2; add(scrollPane, gbc); gbc.insets = null; gbc.gridy = 0; gbc.gridx = 0; gbc.gridwidth = 4; gbc.gridheight = 4; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 0, 10, 0); vpan = new V3DPanel(elem, provider); vpan.setPreferredSize(new Dimension(500, 300)); setBackground(BACKGROUND); add(vpan, gbc); validate(); }
private void initLayout() { fieldNameField.setEnabled(false); fieldList.setVisibleRowCount(4); wordList.setVisibleRowCount(10); final String VAL = "Uren luren himmelturen, ja Besseggen."; fieldList.setPrototypeCellValue(VAL); wordList.setPrototypeCellValue(VAL); fieldPan.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), Globals.lang("Field name"))); wordPan.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), Globals.lang("Keyword"))); fieldPan.setLayout(gbl); wordPan.setLayout(gbl); con.insets = new Insets(2, 2, 2, 2); con.fill = GridBagConstraints.BOTH; con.gridwidth = 2; con.weightx = 1; con.weighty = 1; con.gridx = 0; con.gridy = 0; gbl.setConstraints(fPane, con); fieldPan.add(fPane); gbl.setConstraints(wPane, con); wordPan.add(wPane); con.gridwidth = 1; con.gridx = 2; // con.weightx = 0.7; con.gridheight = 2; gbl.setConstraints(fieldNamePan, con); fieldPan.add(fieldNamePan); gbl.setConstraints(wordEditPan, con); wordPan.add(wordEditPan); con.gridx = 0; con.gridy = 1; con.weightx = 0; con.weighty = 0; con.gridwidth = 1; con.gridheight = 1; con.fill = GridBagConstraints.NONE; con.anchor = GridBagConstraints.WEST; gbl.setConstraints(newField, con); fieldPan.add(newField); gbl.setConstraints(newWord, con); wordPan.add(newWord); con.gridx = 1; // con.anchor = GridBagConstraints.EAST; gbl.setConstraints(removeField, con); fieldPan.add(removeField); gbl.setConstraints(removeWord, con); wordPan.add(removeWord); con.anchor = GridBagConstraints.WEST; con.gridx = 0; con.gridy = 0; gbl.setConstraints(fieldNameField, con); fieldNamePan.add(fieldNameField); gbl.setConstraints(wordEditField, con); wordEditPan.add(wordEditField); // Add buttons: ButtonBarBuilder bsb = new ButtonBarBuilder(buttonPan); bsb.addGlue(); bsb.addButton(ok); bsb.addButton(apply); bsb.addButton(cancel); bsb.addRelatedGap(); bsb.addButton(help); bsb.addGlue(); // Add panels to dialog: con.fill = GridBagConstraints.BOTH; getContentPane().setLayout(gbl); con.weightx = 1; con.weighty = 0.5; con.gridwidth = 1; con.gridheight = 1; con.gridx = 0; con.gridy = 0; gbl.setConstraints(fieldPan, con); getContentPane().add(fieldPan); con.gridy = 1; gbl.setConstraints(wordPan, con); getContentPane().add(wordPan); con.weighty = 0; con.gridy = 2; con.insets = new Insets(12, 2, 2, 2); gbl.setConstraints(buttonPan, con); getContentPane().add(buttonPan); }
// Here some legacy code makes use of generics. They are tested, so there // is no risk of an actual error, but Java issues a warning. @SuppressWarnings("unchecked") public DialogParameters( JFrame parent, Vector<ParameterDescription> vec, boolean strict, Vector<LayerDesc> layers) { super(parent, Globals.messages.getString("Param_opt"), true); keyb1 = new OSKeybPanel(KEYBMODES.GREEK); keyb2 = new OSKeybPanel(KEYBMODES.MISC); keyb1.setField(this); keyb2.setField(this); keyb.addTab("Greek", keyb1); keyb.addTab("Misc", keyb2); keyb.setVisible(false); v = vec; int ycount = 0; // We create dynamically all the needed elements. // For this reason, we work on arrays of the potentially useful Swing // objects. jtf = new JTextField[MAX_ELEMENTS]; jcb = new JCheckBox[MAX_ELEMENTS]; jco = new JComboBox[MAX_ELEMENTS]; active = false; addComponentListener(this); GridBagLayout bgl = new GridBagLayout(); GridBagConstraints constraints = new GridBagConstraints(); Container contentPane = getContentPane(); contentPane.setLayout(bgl); boolean extStrict = strict; ParameterDescription pd; int top = 0; JLabel lab; tc = 0; cc = 0; co = 0; // We process all parameter passed. Depending on its type, a // corresponding interface element will be created. // A symmetrical operation is done when validating parameters. for (ycount = 0; ycount < v.size(); ++ycount) { if (ycount > MAX) break; pd = (ParameterDescription) v.elementAt(ycount); // We do not need to store label objects, since we do not need // to retrieve data from them. lab = new JLabel(pd.description); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 1; constraints.gridy = ycount; constraints.gridwidth = 1; constraints.gridheight = 1; // The first element needs a little bit more space at the top. if (ycount == 0) top = 10; else top = 0; // Here we configure the grid layout constraints.insets = new Insets(top, 20, 0, 6); constraints.fill = GridBagConstraints.VERTICAL; constraints.anchor = GridBagConstraints.EAST; lab.setEnabled(!(pd.isExtension && extStrict)); if (!(pd.parameter instanceof Boolean)) contentPane.add(lab, constraints); constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(top, 0, 0, 0); constraints.fill = GridBagConstraints.HORIZONTAL; // Now, depending on the type of parameter we create interface // elements and we populate the dialog. if (pd.parameter instanceof PointG) { jtf[tc] = new JTextField(10); jtf[tc].setText("" + ((PointG) (pd.parameter)).x); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 1; constraints.gridheight = 1; // Disable FidoCadJ extensions in the strict compatibility mode jtf[tc].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jtf[tc++], constraints); jtf[tc] = new JTextField(10); jtf[tc].setText("" + ((PointG) (pd.parameter)).y); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 3; constraints.gridy = ycount; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.insets = new Insets(top, 6, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jtf[tc].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jtf[tc++], constraints); } else if (pd.parameter instanceof String) { jtf[tc] = new JTextField(24); jtf[tc].setText((String) (pd.parameter)); // If we have a String text field in the first position, its // contents should be evidenced, since it is supposed to be // the most important field (e.g. for the AdvText primitive) if (ycount == 0) jtf[tc].selectAll(); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jtf[tc].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jtf[tc++], constraints); } else if (pd.parameter instanceof Boolean) { jcb[cc] = new JCheckBox(pd.description); jcb[cc].setSelected(((Boolean) (pd.parameter)).booleanValue()); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jcb[cc].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jcb[cc++], constraints); } else if (pd.parameter instanceof Integer) { jtf[tc] = new JTextField(24); jtf[tc].setText(((Integer) pd.parameter).toString()); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jtf[tc].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jtf[tc++], constraints); } else if (pd.parameter instanceof Float) { // TODO. // WARNING: (DB) this is supposed to be temporary. In fact, I // am planning to upgrade some of the parameters from int // to float. But for a few months, the users should not be // aware of that, even if the internal representation is // slowing being adapted. jtf[tc] = new JTextField(24); int dummy = java.lang.Math.round((Float) pd.parameter); jtf[tc].setText("" + dummy); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jtf[tc].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jtf[tc++], constraints); } else if (pd.parameter instanceof FontG) { GraphicsEnvironment gE; gE = GraphicsEnvironment.getLocalGraphicsEnvironment(); String[] s = gE.getAvailableFontFamilyNames(); jco[co] = new JComboBox(); for (int i = 0; i < s.length; ++i) { jco[co].addItem(s[i]); if (s[i].equals(((FontG) pd.parameter).getFamily())) jco[co].setSelectedIndex(i); } constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jco[co].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jco[co++], constraints); } else if (pd.parameter instanceof LayerInfo) { jco[co] = new JComboBox(new Vector<LayerDesc>(layers)); jco[co].setSelectedIndex(((LayerInfo) pd.parameter).layer); jco[co].setRenderer(new LayerCellRenderer()); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jco[co].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jco[co++], constraints); } else if (pd.parameter instanceof ArrowInfo) { jco[co] = new JComboBox<ArrowInfo>(); jco[co].addItem(new ArrowInfo(0)); jco[co].addItem(new ArrowInfo(1)); jco[co].addItem(new ArrowInfo(2)); jco[co].addItem(new ArrowInfo(3)); jco[co].setSelectedIndex(((ArrowInfo) pd.parameter).style); jco[co].setRenderer(new ArrowCellRenderer()); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jco[co].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jco[co++], constraints); } else if (pd.parameter instanceof DashInfo) { jco[co] = new JComboBox<DashInfo>(); for (int k = 0; k < Globals.dashNumber; ++k) { jco[co].addItem(new DashInfo(k)); } jco[co].setSelectedIndex(((DashInfo) pd.parameter).style); jco[co].setRenderer(new DashCellRenderer()); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jco[co].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jco[co++], constraints); } } // Put the OK and Cancel buttons and make them active. JButton ok = new JButton(Globals.messages.getString("Ok_btn")); JButton cancel = new JButton(Globals.messages.getString("Cancel_btn")); JButton keybd = new JButton("\u00B6\u2211\u221A"); // phylum keybd.setFocusable(false); keybd.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // If at this point, the keyboard is not visible, this means // that it will become visible in a while. It is better to // resize first and then show up the keyboard. if (keyb.isVisible()) { MIN_WIDTH = 400; MIN_HEIGHT = 350; } else { MIN_WIDTH = 400; MIN_HEIGHT = 500; } // setSize(MIN_WIDTH, MIN_HEIGHT); keyb.setVisible(!keyb.isVisible()); pack(); } }); constraints.gridx = 0; constraints.gridy = ycount++; constraints.gridwidth = 4; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.EAST; constraints.insets = new Insets(6, 20, 20, 20); // Put the OK and Cancel buttons and make them active. Box b = Box.createHorizontalBox(); b.add(keybd); // phylum b.add(Box.createHorizontalGlue()); ok.setPreferredSize(cancel.getPreferredSize()); if (Globals.okCancelWinOrder) { b.add(ok); b.add(Box.createHorizontalStrut(12)); b.add(cancel); } else { b.add(cancel); b.add(Box.createHorizontalStrut(12)); b.add(ok); } // b.add(Box.createHorizontalStrut(12)); contentPane.add(b, constraints); constraints.gridx = 0; constraints.gridy = ycount; constraints.gridwidth = 4; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.EAST; constraints.insets = new Insets(6, 20, 20, 20); contentPane.add(keyb, constraints); ok.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { try { int ycount; ParameterDescription pd; tc = 0; cc = 0; co = 0; // Here we read all the contents of the interface and we // update the contents of the parameter description array. for (ycount = 0; ycount < v.size(); ++ycount) { if (ycount > MAX) break; pd = (ParameterDescription) v.elementAt(ycount); if (pd.parameter instanceof PointG) { ((PointG) (pd.parameter)).x = Integer.parseInt(jtf[tc++].getText()); ((PointG) (pd.parameter)).y = Integer.parseInt(jtf[tc++].getText()); } else if (pd.parameter instanceof String) { pd.parameter = jtf[tc++].getText(); } else if (pd.parameter instanceof Boolean) { pd.parameter = Boolean.valueOf(jcb[cc++].isSelected()); } else if (pd.parameter instanceof Integer) { pd.parameter = Integer.valueOf(Integer.parseInt(jtf[tc++].getText())); } else if (pd.parameter instanceof Float) { pd.parameter = Float.valueOf(Float.parseFloat(jtf[tc++].getText())); } else if (pd.parameter instanceof FontG) { pd.parameter = new FontG((String) jco[co++].getSelectedItem()); } else if (pd.parameter instanceof LayerInfo) { pd.parameter = new LayerInfo(jco[co++].getSelectedIndex()); } else if (pd.parameter instanceof ArrowInfo) { pd.parameter = new ArrowInfo(jco[co++].getSelectedIndex()); } else if (pd.parameter instanceof DashInfo) { pd.parameter = new DashInfo(jco[co++].getSelectedIndex()); } } } catch (NumberFormatException E) { // Error detected. Probably, the user has entered an // invalid string when FidoCadJ was expecting a numerical // input. JOptionPane.showMessageDialog( null, Globals.messages.getString("Format_invalid"), "", JOptionPane.INFORMATION_MESSAGE); return; } active = true; // Globals.activeWindow.setEnabled(true); setVisible(false); keyb.setVisible(false); } }); cancel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { // Globals.activeWindow.setEnabled(true); setVisible(false); keyb.setVisible(false); } }); // Here is an action in which the dialog is closed AbstractAction cancelAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { // Globals.activeWindow.setEnabled(true); setVisible(false); keyb.setVisible(false); } }; DialogUtil.addCancelEscape(this, cancelAction); this.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { // Globals.activeWindow.setEnabled(true); keyb.setVisible(false); } }); pack(); DialogUtil.center(this); getRootPane().setDefaultButton(ok); }
protected void dolayout(String strDir, String strFreq, String strTraynum) { // TopBar String strTitle = gettitle(strFreq); Color color = DisplayOptions.getColor("Heading3"); // Center Panel JPanel panelCenter = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints( 0, 0, 1, 1, 0.2, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0); ImageIcon icon = getImageIcon(); // panelCenter.add(new JLabel(icon)); addComp(panelCenter, new JLabel(icon), gbc, 0, 0); strTitle = getSampleName(strDir, strTraynum); m_lblSampleName = new JLabel(strTitle); if (strTitle == null || !strTitle.trim().equals("")) strTitle = "3"; Font font = m_lblSampleName.getFont(); font = DisplayOptions.getFont(font.getName(), Font.BOLD, 300); m_lblSampleName.setFont(font); m_lblSampleName.setForeground(color); // panelCenter.add(m_lblSampleName); m_pnlSampleName = new JPanel(new CardLayout()); m_pnlSampleName.add(m_lblSampleName, OTHER); addComp(panelCenter, m_pnlSampleName, gbc, 1, 0); m_pnlSampleName.setVisible(false); m_pnlTrays = new JPanel(new GridLayout(1, 0)); // Vast panels VBox pnlVast1 = new VBox(m_pnlTrays, "1"); m_pnlTrays.add(pnlVast1); m_pnlVast[0] = pnlVast1; VBox pnlVast2 = new VBox(m_pnlTrays, "2"); m_pnlTrays.add(pnlVast2); m_pnlVast[1] = pnlVast2; VBox pnlVast3 = new VBox(m_pnlTrays, "3"); m_pnlTrays.add(pnlVast3); m_pnlVast[2] = pnlVast3; VBox pnlVast4 = new VBox(m_pnlTrays, "4"); m_pnlTrays.add(pnlVast4); m_pnlVast[3] = pnlVast4; VBox pnlVast5 = new VBox(m_pnlTrays, "5"); m_pnlTrays.add(pnlVast5); m_pnlVast[4] = pnlVast5; m_pnlSampleName.add(m_pnlTrays, VAST); // Login Panel JPanel panelThird = new JPanel(new BorderLayout()); JPanel panelLogin = new JPanel(new GridBagLayout()); gbc = new GridBagConstraints(); panelThird.add(panelLogin); Object[] aStrUser = getOperators(); m_cmbUser = new JComboBox(aStrUser); BasicComboBoxRenderer renderer = new BasicComboBoxRenderer(); m_cmbUser.setRenderer(renderer); m_cmbUser.setEditable(true); m_passwordField = new JPasswordField(); // *Warning, working around a Java problem* // When we went to the T3500 running Redhat 5.3, the JPasswordField // fields sometimes does not allow ANY entry of characters. Setting // the enableInputMethods() to true fixed this problem. There are // comments that indicate that this could cause the typed characters // to be visible. I have not found that to be a problem. // This may not be required in the future, or could cause characters // to become visible in the future if Java changes it's code. // GRS 8/20/09 m_passwordField.enableInputMethods(true); m_lblLogin = new VLoginLabel(null, "Incorrect username/password \n Please try again ", 0, 0); m_lblLogin.setVisible(false); okButton.setActionCommand("enter"); okButton.addActionListener(this); cancelButton.setActionCommand("cancel"); cancelButton.addActionListener(this); helpButton.setActionCommand("help"); helpButton.addActionListener(this); m_passwordField.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) enterLogin(); } }); // These is some wierd problem such that sometimes, the vnmrj command // area gets the focus and these items in the login box do not get // the focus. Even clicking in these items does not bring focus to // them. Issuing requestFocus() does not bring focus to them. // I can however, determing if either the operator entry box or // the password box has focus and if neither does, I can unshow and // reshow the panel and that fixes the focus. So, I have added this // to the mouseClicked action. If neither has focus, it will // take focus with setVisible false then true. comboTextField = m_cmbUser.getEditor().getEditorComponent(); m_passwordField.addMouseListener(this); comboTextField.addMouseListener(this); m_lblUsername = new JLabel(Util.getLabel("_Operator")); addComp(panelLogin, m_lblUsername, gbc, 0, 0); addComp(panelLogin, m_cmbUser, gbc, 1, 0); m_lblPassword = new JLabel(Util.getLabel("_Password")); addComp(panelLogin, m_lblPassword, gbc, 0, 1); addComp(panelLogin, m_passwordField, gbc, 1, 1); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.gridheight = GridBagConstraints.REMAINDER; addComp(panelLogin, m_lblLogin, gbc, 2, 0); setPref(); Container container = getContentPane(); JPanel panelLoginBox = new JPanel(new BorderLayout()); panelLoginBox.add(panelCenter, BorderLayout.CENTER); panelLoginBox.add(panelThird, BorderLayout.SOUTH); container.add(panelLoginBox, BorderLayout.CENTER); }
/** Initializes the panel containing the node. */ public ContactListTreeCellRenderer() { super(new GridBagLayout()); loadSkin(); this.setOpaque(true); this.nameLabel.setOpaque(false); this.displayDetailsLabel.setFont(getFont().deriveFont(9f)); this.displayDetailsLabel.setForeground(Color.GRAY); this.rightLabel.setHorizontalAlignment(JLabel.RIGHT); // !! IMPORTANT: General insets used for all components if not // overwritten! constraints.insets = new Insets(0, 0, 0, H_GAP); constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 0; constraints.gridy = 0; constraints.gridheight = 1; constraints.weightx = 0f; constraints.weighty = 1f; this.add(statusLabel, constraints); addLabels(1); callButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (treeNode != null && treeNode instanceof ContactNode) { call(treeNode, callButton, false, false); } } }); callVideoButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (treeNode != null && treeNode instanceof ContactNode) { call(treeNode, callVideoButton, true, false); } } }); desktopSharingButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (treeNode != null && treeNode instanceof ContactNode) { call(treeNode, desktopSharingButton, true, true); } } }); chatButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (treeNode != null && treeNode instanceof ContactNode) { UIContact contactDescriptor = ((ContactNode) treeNode).getContactDescriptor(); if (contactDescriptor.getDescriptor() instanceof MetaContact) { GuiActivator.getUIService() .getChatWindowManager() .startChat((MetaContact) contactDescriptor.getDescriptor()); } } } }); addContactButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (treeNode != null && treeNode instanceof ContactNode) { UIContact contactDescriptor = ((ContactNode) treeNode).getContactDescriptor(); // The add contact function has only sense for external // source contacts. if (contactDescriptor instanceof SourceUIContact) { addContact((SourceUIContact) contactDescriptor); } } } }); initButtonToolTips(); this.setToolTipText(""); }
/** Sets up the GUI (panels, buttons, etc) and displays it on the screen. */ private void init() { if (image.getFileInfo(0).getFileFormat() == FileUtility.DICOM) { FileInfoDicom dicomInfo = (FileInfoDicom) image.getFileInfo(0); FileDicomTagTable tagTable = dicomInfo.getTagTable(); if (tagTable.getValue("0018,1310") != null) { // Acquisition matrix FileDicomTag tag = tagTable.get(new FileDicomKey("0018,1310")); Object[] values = tag.getValueList(); int valNumber = values.length; if ((valNumber == 4) && (values instanceof Short[])) { int frequencyRows = ((Short) values[0]).intValue(); Preferences.debug("frequencyRows = " + frequencyRows + "\n"); int frequencyColumns = ((Short) values[1]).intValue(); Preferences.debug("frequencyColumns = " + frequencyColumns + "\n"); int phaseRows = ((Short) values[2]).intValue(); Preferences.debug("phaseRows = " + phaseRows + "\n"); int phaseColumns = ((Short) values[3]).intValue(); Preferences.debug("phaseColumns = " + phaseColumns + "\n"); if ((frequencyRows > 0) && (phaseRows == 0)) { subYDim = frequencyRows; } else if ((frequencyRows == 0) && (phaseRows > 0)) { subYDim = phaseRows; } if ((frequencyColumns > 0) && (phaseColumns == 0)) { subXDim = frequencyColumns; } else if ((frequencyColumns == 0) && (phaseColumns > 0)) { subXDim = phaseColumns; } } } // if (tagTable.getValue("0018,1310") != null) if (tagTable.getValue("0019,100A") != null) { FileDicomTag tag = tagTable.get(new FileDicomKey("0019,100A")); Object value = tag.getValue(false); if (value instanceof Short) { numberOfImagesInMosaic = ((Short) value).intValue(); Preferences.debug("Number of images in mosaic = " + numberOfImagesInMosaic + "\n"); } } // if (tagTable.getValue("0019,100A") != null) } // if (image.getFileInfo(0).getFileFormat() == FileUtility.DICOM)*/ setForeground(Color.black); setTitle("Mosaic To 3D Volume"); JPanel inputPanel = new JPanel(new GridBagLayout()); inputPanel.setForeground(Color.black); inputPanel.setBorder(buildTitledBorder("Image")); JLabel labelUse = new JLabel("Image:"); labelUse.setForeground(Color.black); labelUse.setFont(serif12); JLabel labelImage = new JLabel(image.getImageName()); labelImage.setForeground(Color.black); labelImage.setFont(serif12); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.gridheight = 1; gbc.gridwidth = 1; gbc.anchor = GridBagConstraints.WEST; gbc.weightx = 1; gbc.insets = new Insets(5, 5, 5, 5); inputPanel.add(labelUse, gbc); gbc.gridx = 1; gbc.fill = GridBagConstraints.HORIZONTAL; inputPanel.add(labelImage, gbc); JPanel dimensionPanel = new JPanel(new GridBagLayout()); dimensionPanel.setForeground(Color.black); dimensionPanel.setBorder(buildTitledBorder("X and Y Dimensions of Result")); JLabel labelXDim = new JLabel("X dimension of slices"); labelXDim.setForeground(Color.black); labelXDim.setFont(serif12); textXDim = new JTextField(10); if (subXDim != 0) { textXDim.setText(String.valueOf(subXDim)); } textXDim.setFont(serif12); textXDim.setForeground(Color.black); JLabel labelYDim = new JLabel("Y dimension of slices"); labelYDim.setForeground(Color.black); labelYDim.setFont(serif12); textYDim = new JTextField(10); if (subYDim != 0) { textYDim.setText(String.valueOf(subYDim)); } textYDim.setFont(serif12); textYDim.setForeground(Color.black); JLabel labelNumberImages = new JLabel("Number of images in mosaic"); labelNumberImages.setForeground(Color.black); labelNumberImages.setFont(serif12); textNumberImages = new JTextField(10); if (numberOfImagesInMosaic != 0) { textNumberImages.setText(String.valueOf(numberOfImagesInMosaic)); } textNumberImages.setFont(serif12); textNumberImages.setForeground(Color.black); gbc.gridx = 0; gbc.gridy = 0; dimensionPanel.add(labelXDim, gbc); gbc.gridx = 1; dimensionPanel.add(textXDim, gbc); gbc.gridx = 0; gbc.gridy = 1; dimensionPanel.add(labelYDim, gbc); gbc.gridx = 1; dimensionPanel.add(textYDim, gbc); gbc.gridx = 0; gbc.gridy = 2; dimensionPanel.add(labelNumberImages, gbc); gbc.gridx = 1; dimensionPanel.add(textNumberImages, gbc); JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(inputPanel, BorderLayout.NORTH); mainPanel.add(dimensionPanel, BorderLayout.CENTER); mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JPanel buttonPanel = new JPanel(); buttonPanel.add(buildButtons()); getContentPane().add(mainPanel); getContentPane().add(buttonPanel, BorderLayout.SOUTH); pack(); setVisible(true); }
public WizStepManyTextFields(Wizard w, String instr, Vector strings) { // store wizard? _instructions.setText(instr); _instructions.setWrapStyleWord(true); _instructions.setEditable(false); _instructions.setBorder(null); _instructions.setBackground(_mainPanel.getBackground()); _mainPanel.setBorder(new EtchedBorder()); GridBagLayout gb = new GridBagLayout(); _mainPanel.setLayout(gb); GridBagConstraints c = new GridBagConstraints(); c.ipadx = 3; c.ipady = 3; c.weightx = 0.0; c.weighty = 0.0; c.anchor = GridBagConstraints.EAST; JLabel image = new JLabel(""); // image.setMargin(new Insets(0, 0, 0, 0)); image.setIcon(WIZ_ICON); image.setBorder(null); c.gridx = 0; c.gridheight = GridBagConstraints.REMAINDER; c.gridy = 0; c.anchor = GridBagConstraints.NORTH; gb.setConstraints(image, c); _mainPanel.add(image); c.weightx = 0.0; c.gridx = 2; c.gridheight = 1; c.gridwidth = 3; c.gridy = 0; c.fill = GridBagConstraints.NONE; gb.setConstraints(_instructions, c); _mainPanel.add(_instructions); c.gridx = 1; c.gridy = 1; c.weightx = 0.0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; SpacerPanel spacer = new SpacerPanel(); gb.setConstraints(spacer, c); _mainPanel.add(spacer); c.gridx = 2; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; int size = strings.size(); for (int i = 0; i < size; i++) { c.gridy = 2 + i; String s = (String) strings.elementAt(i); JTextField tf = new JTextField(s, 50); tf.setMinimumSize(new Dimension(200, 20)); tf.getDocument().addDocumentListener(this); _fields.addElement(tf); gb.setConstraints(tf, c); _mainPanel.add(tf); } c.gridx = 1; c.gridy = 3 + strings.size(); c.weightx = 0.0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; SpacerPanel spacer2 = new SpacerPanel(); gb.setConstraints(spacer2, c); _mainPanel.add(spacer2); }