protected void displayNewTxf(String strLabel, String strValue) { strLabel = (strLabel == null) ? "" : strLabel.trim(); strValue = (strValue == null) ? "" : strValue.trim(); JCheckBox chkBox1 = new JCheckBox(Util.getImageIcon("boxGray.gif")); DataField txf1 = new DataField(strLabel); DataField txf2 = new DataField(strValue); JPanel pnlTxf = new JPanel(m_gbl); m_nRow = m_nRow + 1; txf1.setName("label"); txf2.setName("value"); /* 1st line of text field*/ m_gbc.weightx = 0; showComp(m_gbl, m_gbc, 0, m_nRow, 1, chkBox1); m_gbc.weightx = 1; showComp(m_gbl, m_gbc, GridBagConstraints.RELATIVE, m_nRow, 1, txf1); // showSpaces( gbl, gbc, 2, 6 ); showComp(m_gbl, m_gbc, GridBagConstraints.RELATIVE, m_nRow, 1, txf2); m_gbc.weightx = 0; txf1.addFocusListener(this); txf2.addFocusListener(this); m_objTxfValue.addToLabel(txf1); m_objTxfValue.addToValue(txf2); }
private void showSpaces(GridBagLayout gbl, GridBagConstraints gbc, int gridx, int gridy) { JLabel spaces = new JLabel(" "); gbc.gridx = gridx; gbc.gridy = gridy; gbl.setConstraints(spaces, gbc); m_pnlDisplay.add(spaces); }
public DisplayResults() { GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); setLayout(gbl); gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.HORIZONTAL; text.setForeground(Color.black); add(text, gbc); gbc.gridy = 0; gbc.gridwidth = GridBagConstraints.REMAINDER; add(emptyLabel, gbc); add(Box.createVerticalStrut(0), gbc); add(emptyLabel, gbc); /* gbc.gridy = 1; VTextMsg result = new VTextMsg(sshare, vnmrif, null); result.setPreferredSize(new Dimension(300, 30)); result.setForeground(Color.black); add( result, gbc ); */ setBorder( new CompoundBorder( BorderFactory.createTitledBorder(" Results "), BorderFactory.createEmptyBorder(10, 10, 10, 10))); }
// put image into box at specified (x, y) public void addImage(ClickableImage image, int x, int y, Border border) { image.setRow(x); image.setColumn(y); image.setBorder(border); gbc.gridx = y; // ?? why backwards gbc.gridy = x; gbag.setConstraints(image, gbc); add(image); images[x][y] = image; }
private void showComp( GridBagLayout gbl, GridBagConstraints gbc, int gridx, int gridy, int gridwidth, JComponent comp) { gbc.gridx = gridx; gbc.gridy = gridy; gbl.setConstraints(comp, gbc); m_pnlDisplay.add(comp); }
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; }
private void showInstruction( GridBagLayout gbl, GridBagConstraints gbc, int gridx, int gridy, int gridwidth, JLabel instruction) { gbc.gridwidth = gridwidth; gbc.gridx = gridx; gbc.gridy = gridy; gbl.setConstraints(instruction, gbc); instruction.setForeground(Color.black); m_pnlDisplay.add(instruction); }
/** * Adds a JLabel and three JRadioButton instances in a ButtonGroup to the given panel with a * GridBagLayout, and returns the buttons in an array. */ private JRadioButton[] addRadioButtonTriplet(String labelText, JPanel panel) { GridBagConstraints labelConstraints = new GridBagConstraints(); labelConstraints.anchor = GridBagConstraints.WEST; labelConstraints.insets = new Insets(2, 10, 2, 10); GridBagConstraints buttonConstraints = new GridBagConstraints(); buttonConstraints.insets = labelConstraints.insets; GridBagConstraints lastGlueConstraints = new GridBagConstraints(); lastGlueConstraints.gridwidth = GridBagConstraints.REMAINDER; lastGlueConstraints.weightx = 1.0; // Create the radio buttons. JRadioButton radioButton0 = new JRadioButton(); JRadioButton radioButton1 = new JRadioButton(); JRadioButton radioButton2 = new JRadioButton(); // Put them in a button group. ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(radioButton0); buttonGroup.add(radioButton1); buttonGroup.add(radioButton2); // Add the label and the buttons to the panel. panel.add(new JLabel(labelText), labelConstraints); panel.add(radioButton0, buttonConstraints); panel.add(radioButton1, buttonConstraints); panel.add(radioButton2, buttonConstraints); panel.add(Box.createGlue(), lastGlueConstraints); return new JRadioButton[] {radioButton0, radioButton1, radioButton2}; }
public ClickableImageGrid(int rows, int cols) { gRows = rows; gCols = cols; images = new ClickableImage[rows][cols]; setLayout(gbag); gbc.insets = new Insets(4, 4, 4, 4); // spacing around images }
VerificationDlg(JFrame par, String pwd) { super(par, "Password Keeper - Enter Password", true); // Modal Dialog this.par = par; this.pwd = pwd; okButton = new JButton("OK"); okButton.addActionListener(this); dlgPanel = new JPanel(); dlgPanel.setLayout(new GridBagLayout()); cns = new GridBagConstraints(); cns.gridx = cns.gridy = 0; cns.insets = new Insets(2, 2, 2, 2); dlgPanel.add(new JLabel("Password"), cns); cns.gridx++; passField = new TextField(30); dlgPanel.add(passField, cns); cns.gridy++; // cns.gridx = 0; dlgPanel.add(okButton, cns); cancelButton = new JButton("Cancel"); cns.gridx++; dlgPanel.add(cancelButton, cns); Container cp = this.getContentPane(); Border rb = BorderFactory.createEtchedBorder(); dlgPanel.setBorder( BorderFactory.createTitledBorder( rb, "Enter Password", TitledBorder.LEFT, TitledBorder.TOP)); cp.add(dlgPanel); pack(); }
protected void displayNewTxf(String strLabel, String strValue) { strLabel = (strLabel != null) ? strLabel.trim() : ""; strValue = (strValue != null) ? strValue.trim() : ""; JCheckBox chk1 = new JCheckBox(Util.getImageIcon("boxGray.gif")); final DataField txf1 = new DataField(strLabel); final DataField txf2 = new DataField(strValue); m_nRow = m_nRow + 1; txf1.setName("label"); txf2.setName("value"); // new field if (strLabel.equals("") && strValue.equals("")) { txf2.setText(INFOSTR); txf2.addMouseListener(m_mlTxf); if (timer != null) timer.cancel(); timer = new java.util.Timer(); timer.schedule( new TimerTask() { public void run() { WUtil.blink(txf2, WUtil.FOREGROUND); } }, delay, delay); } /* 1st line of text field*/ m_gbc.weightx = 0; showComp(m_gbl, m_gbc, 0, m_nRow, 1, chk1); m_gbc.weightx = 1; showComp(m_gbl, m_gbc, GridBagConstraints.RELATIVE, m_nRow, 1, txf1); // showSpaces( gbl, gbc, 2, 6 ); showComp(m_gbl, m_gbc, GridBagConstraints.RELATIVE, m_nRow, 1, txf2); m_gbc.weightx = 0; txf1.addFocusListener(this); txf2.addFocusListener(this); // Add the textfields to the respective arrays, so that they // can be retreived later for writing to the file. m_objTxfValue.addToLabel(txf1); m_objTxfValue.addToValue(txf2); }
public DisplayUserDirectory() { GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); setLayout(gbl); gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.HORIZONTAL; hmlabel.setForeground(Color.black); add(hmlabel, gbc); add(Box.createHorizontalStrut(10), gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; add(hmdir, gbc); add(Box.createVerticalStrut(15), gbc); gbc.gridwidth = 1; vjlabel.setForeground(Color.black); add(vjlabel, gbc); add(Box.createHorizontalStrut(10), gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; add(vjdir, gbc); add(Box.createVerticalStrut(0), gbc); gbc.gridwidth = 1; vjlabel2.setForeground(Color.black); add(vjlabel2, gbc); setBorder( new CompoundBorder( // i18n // BorderFactory.createTitledBorder(" User_Directories "), BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")), BorderFactory.createEmptyBorder(10, 10, 10, 10))); }
public DisplayTemplate(String strDir, String strDefDirFile) { setLayout(m_gbl); m_gbc.anchor = GridBagConstraints.NORTHWEST; m_gbc.fill = GridBagConstraints.HORIZONTAL; m_strPathDir = strDir; m_strDefDirFile = strDefDirFile; setLayout(new BorderLayout()); m_pnlDisplay = new JPanel(m_gbl); JScrollPane spDisplay = new JScrollPane(m_pnlDisplay); add(spDisplay, BorderLayout.CENTER); JComponent pnlTool = getToolBar(); add(pnlTool, BorderLayout.NORTH); layoutUIComponents(FileUtil.openPath(m_strDefDirFile), true); VItemArea1.addChangeListener(this); VUserToolBar.addChangeListener(this); }
public SyntaxTest() { JFrame frame = new JFrame(); frame.setSize(300, 300); JEditorPane editor = new JEditorPane(); DefaultSyntaxKit.initKit(); editor.setContentType("text/banking"); frame.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.weightx = 1.0; c.weighty = 1.0; c.fill = GridBagConstraints.BOTH; frame.add(editor, c); frame.pack(); frame.setVisible(true); }
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(); }
protected void layoutUIComponents(String strPath, boolean bDefaultFile) { JLabel label = null; // i18n // label = new JLabel( "File names can be constructed from a template. The LABEL field is " ); label = new JLabel( Util.getAdmLabel( "_admin_File_names_can_be_constructed_from_a_template._The_LABEL_field_is_")); label.setForeground(Color.black); // m_gbc.weightx = 0.5; showInstruction(m_gbl, m_gbc, 0, 0, 7, label); // i18n // label = new JLabel( "presented as the choice to the user in the \"Data save\" pop-up." ); label = new JLabel( Util.getAdmLabel( "_admin_presented_as_the_choice_to_the_user_in_the_Data_save_pop-up.")); showInstruction(m_gbl, m_gbc, 0, 1, 7, label); showInstruction(m_gbl, m_gbc, 0, 2, 1, new JLabel("")); label = new JLabel(Util.getAdmLabel("_adm_LABEL")); label.setForeground(Color.black); m_gbc.gridx = 1; m_gbc.gridy = 2; m_gbc.ipadx = 10; m_gbl.setConstraints(label, m_gbc); m_pnlDisplay.add(label); label = new JLabel(" "); m_gbc.gridx = 2; m_gbc.gridy = 2; m_gbc.ipadx = 0; // reset to default m_gbc.gridwidth = 5; m_gbl.setConstraints(label, m_gbc); // add( label ); showInstruction(m_gbl, m_gbc, 2, 2, 1, new JLabel(Util.getAdmLabel("_admin_TEMPLATE"))); m_nRow = 3; m_bDefaultFile = bDefaultFile; m_objTxfValue.clearArrays(); displayNewTxf(strPath); m_pnlDisplay.setBorder( new CompoundBorder( BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")), BorderFactory.createEmptyBorder(10, 10, 10, 10))); }
protected void layoutUIComponents(String strPath, boolean bDefaultFile) { // gbc.weightx = 0.5; showInstructions(m_gbl, m_gbc, 0, 0, 7, infoLabel1); showInstructions(m_gbl, m_gbc, 0, 1, 7, infoLabel2); showInstructions(m_gbl, m_gbc, 0, 2, 7, infoLabel3); /*showInstructions( gbl, gbc, 0, 3, 7, infoLabel4 ); showInstructions( gbl, gbc, 0, 4, 7, infoLabel5 );*/ showInstructions(m_gbl, m_gbc, 0, 5, 1, new JLabel("")); // i18n // label = new JLabel( "LABEL" ); label = new JLabel(Util.getAdmLabel("_adm_LABEL")); label.setForeground(Color.black); m_gbc.gridx = 1; m_gbc.gridy = 5; // gbc.ipadx = 10; m_gbl.setConstraints(label, m_gbc); m_pnlDisplay.add(label); label = new JLabel(" "); m_gbc.gridx = 2; m_gbc.gridy = 5; m_gbc.ipadx = 0; m_gbc.gridwidth = 5; m_gbc.weightx = 0; m_gbl.setConstraints(label, m_gbc); // add( label ); // i18n // showInstructions( m_gbl, m_gbc, 2, 5, 1, new JLabel( "DIRECTORY" )); showInstructions(m_gbl, m_gbc, 2, 5, 1, new JLabel(Util.getAdmLabel("_adm_DIRECTORY"))); m_nRow = 5; m_bDefaultFile = bDefaultFile; m_objTxfValue.clearArrays(); displayNewTxf(strPath); m_pnlDisplay.setBorder( new CompoundBorder( // i18n // BorderFactory.createTitledBorder( " Parent Directories "), BorderFactory.createTitledBorder(Util.getAdmLabel("_adm_Parent_Directories")), BorderFactory.createEmptyBorder(10, 10, 10, 10))); }
public Test(int columns, Insets insets, JComponent[] components) { super(GridBagLayout.class.getName()); GridBagLayout layout = new GridBagLayout(); JPanel panel = new JPanel(layout); // --- code needed to add the components GridBagConstraints constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.WEST; constraints.insets = insets; constraints.fill = GridBagConstraints.BOTH; int i = 0; for (JComponent component : components) { constraints.gridx = i % columns; constraints.gridy = i / columns; layout.setConstraints(component, constraints); panel.add(component); i++; } // --- panel.setBorder(new EtchedBorder()); setContentPane(panel); pack(); show(); }
private void initialize() { setName("NewsPanel"); setLayout(new GridBagLayout()); refreshLanguage(); // We create the components new TextComponentClipboardMenu(uploadPrioTextField, language); new TextComponentClipboardMenu(downloadPrioTextField, language); new TextComponentClipboardMenu(displayDaysTextField, language); new TextComponentClipboardMenu(downloadDaysTextField, language); new TextComponentClipboardMenu(messageBaseTextField, language); new TextComponentClipboardMenu(minimumIntervalTextField, language); new TextComponentClipboardMenu(concurrentUpdatesTextField, language); new TextComponentClipboardMenu(altEditTextField, language); // Adds all of the components final GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.WEST; constraints.weighty = 0.0; constraints.weightx = 0; constraints.insets = new Insets(0, 5, 5, 5); constraints.gridy = 0; constraints.gridx = 0; add(displayDaysLabel, constraints); constraints.gridx = 1; add(displayDaysTextField, constraints); constraints.gridx = 0; constraints.gridy++; add(downloadDaysLabel, constraints); constraints.gridx = 1; add(downloadDaysTextField, constraints); constraints.gridx = 0; constraints.gridy++; constraints.gridwidth = 2; add(alwaysDownloadBackloadCheckBox, constraints); constraints.gridwidth = 1; constraints.gridx = 0; constraints.gridy++; add(messageBaseLabel, constraints); constraints.gridx = 1; add(messageBaseTextField, constraints); constraints.gridy++; constraints.gridx = 0; add(uploadPrioLabel, constraints); constraints.gridx = 1; add(uploadPrioTextField, constraints); constraints.gridy++; constraints.gridx = 0; add(downloadPrioLabel, constraints); constraints.gridx = 1; add(downloadPrioTextField, constraints); constraints.gridx = 0; constraints.gridwidth = 2; constraints.gridy++; add(automaticBoardUpdateCheckBox, constraints); constraints.gridy++; add(getUpdatePanel(), constraints); constraints.gridy++; add(useOneConnectionForMessagesCheckBox, constraints); constraints.gridy++; add(storeSentMessagesCheckBox, constraints); constraints.gridy++; add(silentlyRetryCheckBox, constraints); constraints.gridwidth = 1; constraints.insets = new Insets(0, 5, 0, 5); constraints.gridy++; constraints.gridx = 0; add(altEditCheckBox, constraints); constraints.gridx = 1; constraints.weightx = 1; constraints.fill = GridBagConstraints.HORIZONTAL; add(altEditTextField, constraints); constraints.weightx = 0; constraints.fill = GridBagConstraints.NONE; // glue constraints.gridy++; constraints.gridx = 0; constraints.gridwidth = 2; constraints.fill = GridBagConstraints.BOTH; constraints.weightx = 1; constraints.weighty = 1; add(new JLabel(""), constraints); // Add listeners automaticBoardUpdateCheckBox.addActionListener(listener); altEditCheckBox.addChangeListener(listener); }
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; }
private static JPanel createTextFieldAndListPanel( String label, JTextField textField, JList list) { GridBagLayout layout = new GridBagLayout(); JPanel panel = new JPanel(layout); GridBagConstraints cons = new GridBagConstraints(); cons.gridx = cons.gridy = 0; cons.gridwidth = cons.gridheight = 1; cons.fill = GridBagConstraints.BOTH; cons.weightx = 1.0f; JLabel _label = new JLabel(jEdit.getProperty(label)); layout.setConstraints(_label, cons); panel.add(_label); cons.gridy = 1; Component vs = Box.createVerticalStrut(6); layout.setConstraints(vs, cons); panel.add(vs); cons.gridy = 2; layout.setConstraints(textField, cons); panel.add(textField); cons.gridy = 3; vs = Box.createVerticalStrut(6); layout.setConstraints(vs, cons); panel.add(vs); cons.gridy = 4; cons.gridheight = GridBagConstraints.REMAINDER; cons.weighty = 1.0f; JScrollPane scroller = new JScrollPane(list); layout.setConstraints(scroller, cons); panel.add(scroller); return panel; }
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); }
public SaveDialog(Frame parent) { super(parent, true); this.setLayout(new BorderLayout()); // gather unsaved tab Set<Tab> unsaved = new LinkedHashSet<>(); for (Tab tab : MainPanel.getAllTab()) { if (!tab.isSaved()) { unsaved.add(tab); } } if (unsaved.isEmpty()) { // close directly this.setTitle("Confirm close"); // upper labels JPanel labels = new JPanel(new FlowLayout(FlowLayout.LEFT, 11, 7)); labels.add(iconLabel); labels.add(new MyLabel(" Do you really want to close RefluxEdit?")); // buttons JPanel buttons = new JPanel(new FlowLayout(FlowLayout.CENTER, 4, 7)); buttons.add( new MyButton("YES") { { SaveDialog.this.getRootPane().setDefaultButton(this); this.setFocusPainted(true); } @Override public void actionPerformed(ActionEvent ev) { close = true; SaveDialog.this.setVisible(false); } }); buttons.add( new MyButton("NO") { { this.setFocusPainted(true); } @Override public void actionPerformed(ActionEvent ev) { close = false; SaveDialog.this.setVisible(false); } }); buttons.setBorder(new EmptyBorder(0, 0, 5, 0)); // this.add(labels, BorderLayout.CENTER); this.add(buttons, BorderLayout.PAGE_END); } else { // ask save changes this.setTitle("Unsaved changes"); // upper components: icon and list JPanel upper = new JPanel(new GridBagLayout()); JPanel listPane = new JPanel(new BorderLayout()); final DefaultListModel<Tab> listModel = new DefaultListModel<>(); final JList<Tab> tabList = new JList<>(listModel); tabList.setFont(f13); tabList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); tabList.setCellRenderer( new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent( JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = (JLabel) (super.getListCellRendererComponent( list, value, index, isSelected, cellHasFocus)); if (value instanceof Tab) { String text = ((Tab) value).getTabLabel().getText(); label.setText(text.substring(1)); // remove "*" } return label; } }); for (Tab tab : unsaved) { listModel.addElement(tab); } tabList.getSelectionModel().setSelectionInterval(0, listModel.size() - 1); JScrollPane scrollPane = new JScrollPane(tabList); scrollPane.setPreferredSize(new Dimension(350, 170)); listPane.add(new MyLabel("The following tabs are unsaved:"), BorderLayout.PAGE_START); listPane.add(scrollPane, BorderLayout.CENTER); // setup upper GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.weightx = 0; c.weighty = 1; c.insets = new Insets(5, 5, 5, 5); c.anchor = GridBagConstraints.FIRST_LINE_START; upper.add(iconLabel, c); // c.gridx = 1; c.weightx = 1; c.fill = GridBagConstraints.BOTH; upper.add(listPane, c); // lower components: buttons JPanel buttons = new JPanel(new FlowLayout(FlowLayout.CENTER, 4, 7)); buttons.add( new MyButton("Save") { { this.setFocusPainted(true); this.setToolTipText("Save selected tab(s)"); SaveDialog.this.getRootPane().setDefaultButton(this); if (isMetal) { this.setPreferredSize(METAL_BUTTON_DIZE); } } @Override public void actionPerformed(ActionEvent ev) { for (Tab tab : tabList.getSelectedValuesList()) { if (tab.getFile() != null) { try { tab.save(); MainPanel.close(tab); listModel.removeElement(tab); } catch (Exception ex) { exception(ex); break; } } else { File file = FileChooser.showPreferredFileDialog( RefluxEdit.getInstance(), FileChooser.SAVE, new String[0]); if (file != null) { try { tab.save(file, false); MainPanel.close(tab); listModel.removeElement(tab); } catch (Exception ex) { exception(ex); break; } } } } if (listModel.size() == 0) { RefluxEdit.getInstance().close(); } } }); buttons.add( new MyButton("Discard") { { this.setFocusPainted(true); this.setToolTipText("Discard selected tab(s)"); if (isMetal) { this.setPreferredSize(METAL_BUTTON_DIZE); } } @Override public void actionPerformed(ActionEvent ev) { for (Tab tab : tabList.getSelectedValuesList()) { MainPanel.close(tab); listModel.removeElement(tab); } if (listModel.size() == 0) { RefluxEdit.getInstance().close(); } } }); buttons.add( new MyButton("Close") { { this.setFocusPainted(true); this.setToolTipText("Close RefluxEdit"); if (isMetal) { this.setPreferredSize(METAL_BUTTON_DIZE); } } @Override public void actionPerformed(ActionEvent ev) { SaveDialog.this.close = true; SaveDialog.this.setVisible(false); } }); buttons.add( new MyButton("Cancel") { { this.setFocusPainted(true); if (isMetal) { this.setPreferredSize(METAL_BUTTON_DIZE); } } @Override public void actionPerformed(ActionEvent ev) { SaveDialog.this.close = false; SaveDialog.this.setVisible(false); } }); this.add(upper, BorderLayout.CENTER); this.add(buttons, BorderLayout.PAGE_END); } }
/** Constructor (create and layout page) */ public SOAPMonitorPage(String host_name) { host = host_name; // Set up default filter (show all messages) filter = new SOAPMonitorFilter(); // Use borders to help improve appearance etched_border = new EtchedBorder(); // Build top portion of split (list panel) model = new SOAPMonitorTableModel(); table = new JTable(model); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setRowSelectionInterval(0, 0); table.setPreferredScrollableViewportSize(new Dimension(600, 96)); table.getSelectionModel().addListSelectionListener(this); scroll = new JScrollPane(table); remove_button = new JButton("Remove"); remove_button.addActionListener(this); remove_button.setEnabled(false); remove_all_button = new JButton("Remove All"); remove_all_button.addActionListener(this); filter_button = new JButton("Filter ..."); filter_button.addActionListener(this); list_buttons = new JPanel(); list_buttons.setLayout(new FlowLayout()); list_buttons.add(remove_button); list_buttons.add(remove_all_button); list_buttons.add(filter_button); list_panel = new JPanel(); list_panel.setLayout(new BorderLayout()); list_panel.add(scroll, BorderLayout.CENTER); list_panel.add(list_buttons, BorderLayout.SOUTH); list_panel.setBorder(empty_border); // Build bottom portion of split (message details) details_time = new JLabel("Time: ", SwingConstants.RIGHT); details_target = new JLabel("Target Service: ", SwingConstants.RIGHT); details_status = new JLabel("Status: ", SwingConstants.RIGHT); details_time_value = new JLabel(); details_target_value = new JLabel(); details_status_value = new JLabel(); Dimension preferred_size = details_time.getPreferredSize(); preferred_size.width = 1; details_time.setPreferredSize(preferred_size); details_target.setPreferredSize(preferred_size); details_status.setPreferredSize(preferred_size); details_time_value.setPreferredSize(preferred_size); details_target_value.setPreferredSize(preferred_size); details_status_value.setPreferredSize(preferred_size); details_header = new JPanel(); details_header_layout = new GridBagLayout(); details_header.setLayout(details_header_layout); details_header_constraints = new GridBagConstraints(); details_header_constraints.fill = GridBagConstraints.BOTH; details_header_constraints.weightx = 0.5; details_header_layout.setConstraints(details_time, details_header_constraints); details_header.add(details_time); details_header_layout.setConstraints(details_time_value, details_header_constraints); details_header.add(details_time_value); details_header_layout.setConstraints(details_target, details_header_constraints); details_header.add(details_target); details_header_constraints.weightx = 1.0; details_header_layout.setConstraints(details_target_value, details_header_constraints); details_header.add(details_target_value); details_header_constraints.weightx = .5; details_header_layout.setConstraints(details_status, details_header_constraints); details_header.add(details_status); details_header_layout.setConstraints(details_status_value, details_header_constraints); details_header.add(details_status_value); details_header.setBorder(etched_border); request_label = new JLabel("SOAP Request", SwingConstants.CENTER); request_text = new SOAPMonitorTextArea(); request_text.setEditable(false); request_scroll = new JScrollPane(request_text); request_panel = new JPanel(); request_panel.setLayout(new BorderLayout()); request_panel.add(request_label, BorderLayout.NORTH); request_panel.add(request_scroll, BorderLayout.CENTER); response_label = new JLabel("SOAP Response", SwingConstants.CENTER); response_text = new SOAPMonitorTextArea(); response_text.setEditable(false); response_scroll = new JScrollPane(response_text); response_panel = new JPanel(); response_panel.setLayout(new BorderLayout()); response_panel.add(response_label, BorderLayout.NORTH); response_panel.add(response_scroll, BorderLayout.CENTER); details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); details_soap.setTopComponent(request_panel); details_soap.setRightComponent(response_panel); details_soap.setResizeWeight(.5); details_panel = new JPanel(); layout_button = new JButton("Switch Layout"); layout_button.addActionListener(this); reflow_xml = new JCheckBox("Reflow XML text"); reflow_xml.addActionListener(this); details_buttons = new JPanel(); details_buttons.setLayout(new FlowLayout()); details_buttons.add(reflow_xml); details_buttons.add(layout_button); details_panel.setLayout(new BorderLayout()); details_panel.add(details_header, BorderLayout.NORTH); details_panel.add(details_soap, BorderLayout.CENTER); details_panel.add(details_buttons, BorderLayout.SOUTH); details_panel.setBorder(empty_border); // Add the two parts to the age split pane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split.setTopComponent(list_panel); split.setRightComponent(details_panel); // Build status area start_button = new JButton("Start"); start_button.addActionListener(this); stop_button = new JButton("Stop"); stop_button.addActionListener(this); status_buttons = new JPanel(); status_buttons.setLayout(new FlowLayout()); status_buttons.add(start_button); status_buttons.add(stop_button); status_text = new JLabel(); status_text.setBorder(new BevelBorder(BevelBorder.LOWERED)); status_text_panel = new JPanel(); status_text_panel.setLayout(new BorderLayout()); status_text_panel.add(status_text, BorderLayout.CENTER); status_text_panel.setBorder(empty_border); status_area = new JPanel(); status_area.setLayout(new BorderLayout()); status_area.add(status_buttons, BorderLayout.WEST); status_area.add(status_text_panel, BorderLayout.CENTER); status_area.setBorder(etched_border); // Add the split and status area to page setLayout(new BorderLayout()); add(split, BorderLayout.CENTER); add(status_area, BorderLayout.SOUTH); }
private JPanel getUpdatePanel() { if (updatePanel == null) { updatePanel = new JPanel(new GridBagLayout()); updatePanel.setBorder(new EmptyBorder(0, 30, 0, 5)); final GridBagConstraints constraints = new GridBagConstraints(); constraints.insets = new Insets(0, 5, 5, 5); constraints.weighty = 0; constraints.weightx = 0; constraints.anchor = GridBagConstraints.NORTHWEST; constraints.gridy = 0; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 0; constraints.weightx = 0.5; updatePanel.add(minimumIntervalLabel, constraints); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.weightx = 1; updatePanel.add(minimumIntervalTextField, constraints); constraints.insets = new Insets(0, 5, 0, 5); // we have a bottom inset in the containing layout! constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 0; constraints.gridy++; constraints.weightx = 0.5; updatePanel.add(concurrentUpdatesLabel, constraints); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.weightx = 1; updatePanel.add(concurrentUpdatesTextField, constraints); } return updatePanel; }
/** * The consturctor Constructor instantiates all the panels, convertible value instance, and the * frame. And adds the panels to the frame. And sets a proper size for the frame. */ public HappyHackingConverter() { CFrame frame = new CFrame(); frame.setBackground(white); ConvertibleValue temperatures = new ConvertibleValue(); ConvertibleValue distances = new ConvertibleValue(); ConvertibleValue weights = new ConvertibleValue(); GridBagLayout leftSideLayout = new GridBagLayout(); JPanel leftSide = new JPanel(leftSideLayout); leftSide.setBackground(white); GridBagLayout rightSideLayout = new GridBagLayout(); JPanel rightSide = new JPanel(rightSideLayout); rightSide.setBackground(white); GridBagConstraints metricTemperatureConstraints = new GridBagConstraints(); metricTemperatureConstraints.gridx = 0; metricTemperatureConstraints.gridy = 0; metricTemperatureConstraints.weighty = 0.1; metricTemperatureConstraints.weightx = 1; metricTemperatureConstraints.fill = GridBagConstraints.BOTH; metricTemperatureConstraints.anchor = GridBagConstraints.FIRST_LINE_START; JPanel metricTemperaturePanel = new TemperaturePanel(frame, temperatures, TemperatureScales.CENTIGRADE); leftSideLayout.setConstraints(metricTemperaturePanel, metricTemperatureConstraints); leftSide.add(metricTemperaturePanel); GridBagConstraints metricDistancesPanelConstraints = new GridBagConstraints(); metricDistancesPanelConstraints.gridx = 0; metricDistancesPanelConstraints.gridy = 1; metricDistancesPanelConstraints.weighty = 0.3; metricDistancesPanelConstraints.weightx = 1; metricDistancesPanelConstraints.fill = GridBagConstraints.BOTH; metricDistancesPanelConstraints.anchor = GridBagConstraints.FIRST_LINE_START; JPanel metricDistancesPanel = new MetricDistancesPanel(frame, distances); leftSideLayout.setConstraints(metricDistancesPanel, metricDistancesPanelConstraints); leftSide.add(metricDistancesPanel); GridBagConstraints fahrenheitConstraints = new GridBagConstraints(); fahrenheitConstraints.gridx = 0; fahrenheitConstraints.gridy = 0; fahrenheitConstraints.weighty = 0.1; fahrenheitConstraints.weightx = 1; fahrenheitConstraints.fill = GridBagConstraints.BOTH; fahrenheitConstraints.anchor = GridBagConstraints.FIRST_LINE_START; JPanel fahrenheitTemperaturePanel = new TemperaturePanel(frame, temperatures, TemperatureScales.FAHRENHEIT); rightSideLayout.setConstraints(fahrenheitTemperaturePanel, fahrenheitConstraints); rightSide.add(fahrenheitTemperaturePanel); GridBagConstraints imperialDistancesPanelConstraints = new GridBagConstraints(); imperialDistancesPanelConstraints.gridx = 0; imperialDistancesPanelConstraints.gridy = 1; imperialDistancesPanelConstraints.weighty = 0.3; imperialDistancesPanelConstraints.weightx = 1; imperialDistancesPanelConstraints.fill = GridBagConstraints.BOTH; imperialDistancesPanelConstraints.anchor = GridBagConstraints.FIRST_LINE_START; JPanel imperialDistancesPanel = new ImperialDistancesPanel(frame, distances); rightSideLayout.setConstraints(imperialDistancesPanel, imperialDistancesPanelConstraints); rightSide.add(imperialDistancesPanel); GridBagConstraints metricWeightsConstraints = new GridBagConstraints(); metricWeightsConstraints.gridx = 0; metricWeightsConstraints.gridy = 2; metricWeightsConstraints.weighty = 0.6; metricWeightsConstraints.weightx = 1; metricWeightsConstraints.fill = GridBagConstraints.BOTH; metricWeightsConstraints.anchor = GridBagConstraints.FIRST_LINE_START; MetricWeightsPanel metricWeightsPanel = new MetricWeightsPanel(frame, weights); leftSideLayout.setConstraints(metricWeightsPanel, metricWeightsConstraints); leftSide.add(metricWeightsPanel); GridBagConstraints imperialWeightsConstraints = new GridBagConstraints(); imperialWeightsConstraints.gridx = 0; imperialWeightsConstraints.gridy = 2; imperialWeightsConstraints.weighty = 0.6; imperialWeightsConstraints.weightx = 1; imperialWeightsConstraints.fill = GridBagConstraints.BOTH; imperialWeightsConstraints.anchor = GridBagConstraints.FIRST_LINE_START; ImperialWeightsPanel imperialWeightsPanel = new ImperialWeightsPanel(frame, weights); rightSideLayout.setConstraints(imperialWeightsPanel, imperialWeightsConstraints); rightSide.add(imperialWeightsPanel); CSplit split = new CSplit(JSplitPane.HORIZONTAL_SPLIT, true, leftSide, rightSide); Container contentPane = frame.getContentPane(); contentPane.add(split); frame.validate(); frame.pack(); frame.setSize(600, 997); split.setResizeWeight(0.5); split.setDividerLocation(0.5); } // end of HappyHackingConverter constructor
public ClassMemberSpecificationDialog(JDialog owner, boolean isField) { super(owner, true); setResizable(true); // Create some constraints that can be reused. GridBagConstraints constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(1, 2, 1, 2); GridBagConstraints constraintsStretch = new GridBagConstraints(); constraintsStretch.fill = GridBagConstraints.HORIZONTAL; constraintsStretch.weightx = 1.0; constraintsStretch.anchor = GridBagConstraints.WEST; constraintsStretch.insets = constraints.insets; GridBagConstraints constraintsLast = new GridBagConstraints(); constraintsLast.gridwidth = GridBagConstraints.REMAINDER; constraintsLast.anchor = GridBagConstraints.WEST; constraintsLast.insets = constraints.insets; GridBagConstraints constraintsLastStretch = new GridBagConstraints(); constraintsLastStretch.gridwidth = GridBagConstraints.REMAINDER; constraintsLastStretch.fill = GridBagConstraints.HORIZONTAL; constraintsLastStretch.weightx = 1.0; constraintsLastStretch.anchor = GridBagConstraints.WEST; constraintsLastStretch.insets = constraints.insets; GridBagConstraints panelConstraints = new GridBagConstraints(); panelConstraints.gridwidth = GridBagConstraints.REMAINDER; panelConstraints.fill = GridBagConstraints.HORIZONTAL; panelConstraints.weightx = 1.0; panelConstraints.weighty = 0.0; panelConstraints.anchor = GridBagConstraints.NORTHWEST; panelConstraints.insets = constraints.insets; GridBagConstraints stretchPanelConstraints = new GridBagConstraints(); stretchPanelConstraints.gridwidth = GridBagConstraints.REMAINDER; stretchPanelConstraints.fill = GridBagConstraints.BOTH; stretchPanelConstraints.weightx = 1.0; stretchPanelConstraints.weighty = 1.0; stretchPanelConstraints.anchor = GridBagConstraints.NORTHWEST; stretchPanelConstraints.insets = constraints.insets; GridBagConstraints labelConstraints = new GridBagConstraints(); labelConstraints.anchor = GridBagConstraints.CENTER; labelConstraints.insets = new Insets(2, 10, 2, 10); GridBagConstraints lastLabelConstraints = new GridBagConstraints(); lastLabelConstraints.gridwidth = GridBagConstraints.REMAINDER; lastLabelConstraints.anchor = GridBagConstraints.CENTER; lastLabelConstraints.insets = labelConstraints.insets; GridBagConstraints okButtonConstraints = new GridBagConstraints(); okButtonConstraints.weightx = 1.0; okButtonConstraints.weighty = 1.0; okButtonConstraints.anchor = GridBagConstraints.SOUTHEAST; okButtonConstraints.insets = new Insets(4, 4, 8, 4); GridBagConstraints cancelButtonConstraints = new GridBagConstraints(); cancelButtonConstraints.gridwidth = GridBagConstraints.REMAINDER; cancelButtonConstraints.weighty = 1.0; cancelButtonConstraints.anchor = GridBagConstraints.SOUTHEAST; cancelButtonConstraints.insets = okButtonConstraints.insets; GridBagLayout layout = new GridBagLayout(); Border etchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.RAISED); this.isField = isField; // Create the access panel. JPanel accessPanel = new JPanel(layout); accessPanel.setBorder( BorderFactory.createTitledBorder(etchedBorder, GUIResources.getMessage("access"))); accessPanel.add(Box.createGlue(), labelConstraints); accessPanel.add(new JLabel(GUIResources.getMessage("required")), labelConstraints); accessPanel.add(new JLabel(GUIResources.getMessage("not")), labelConstraints); accessPanel.add(new JLabel(GUIResources.getMessage("dontCare")), labelConstraints); accessPanel.add(Box.createGlue(), constraintsLastStretch); publicRadioButtons = addRadioButtonTriplet("Public", accessPanel); privateRadioButtons = addRadioButtonTriplet("Private", accessPanel); protectedRadioButtons = addRadioButtonTriplet("Protected", accessPanel); staticRadioButtons = addRadioButtonTriplet("Static", accessPanel); finalRadioButtons = addRadioButtonTriplet("Final", accessPanel); if (isField) { volatileRadioButtons = addRadioButtonTriplet("Volatile", accessPanel); transientRadioButtons = addRadioButtonTriplet("Transient", accessPanel); } else { synchronizedRadioButtons = addRadioButtonTriplet("Synchronized", accessPanel); nativeRadioButtons = addRadioButtonTriplet("Native", accessPanel); abstractRadioButtons = addRadioButtonTriplet("Abstract", accessPanel); strictRadioButtons = addRadioButtonTriplet("Strict", accessPanel); } // Create the type panel. JPanel typePanel = new JPanel(layout); typePanel.setBorder( BorderFactory.createTitledBorder( etchedBorder, GUIResources.getMessage(isField ? "type" : "returnType"))); typePanel.add(typeTextField, constraintsLastStretch); // Create the name panel. JPanel namePanel = new JPanel(layout); namePanel.setBorder( BorderFactory.createTitledBorder(etchedBorder, GUIResources.getMessage("name"))); namePanel.add(nameTextField, constraintsLastStretch); // Create the arguments panel. JPanel argumentsPanel = new JPanel(layout); argumentsPanel.setBorder( BorderFactory.createTitledBorder(etchedBorder, GUIResources.getMessage("arguments"))); argumentsPanel.add(argumentsTextField, constraintsLastStretch); // Create the Ok button. JButton okButton = new JButton(GUIResources.getMessage("ok")); okButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { returnValue = APPROVE_OPTION; hide(); } }); // Create the Cancel button. JButton cancelButton = new JButton(GUIResources.getMessage("cancel")); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { hide(); } }); // Add all panels to the main panel. JPanel mainPanel = new JPanel(layout); mainPanel.add(accessPanel, panelConstraints); mainPanel.add(typePanel, panelConstraints); mainPanel.add(namePanel, panelConstraints); if (!isField) { mainPanel.add(argumentsPanel, panelConstraints); } mainPanel.add(okButton, okButtonConstraints); mainPanel.add(cancelButton, cancelButtonConstraints); getContentPane().add(mainPanel); }
// Public constructor public ElectronicOrganFrame(String title) { // Call parent constructor to give title to frame super(title); // Make this frame its own window listener addWindowListener(windowListener); // Panel components: waveformPanel waveformPanel.setBorder( new TitledBorder(new BevelBorder(BevelBorder.RAISED), "Waveform Options")); GridBagLayout waveformPanelGridBag = new GridBagLayout(); GridBagConstraints waveformPanelConstr = new GridBagConstraints(); waveformPanel.setLayout(waveformPanelGridBag); waveformPanelConstr.anchor = GridBagConstraints.CENTER; waveformPanelConstr.weightx = 1.0; waveformPanelConstr.weighty = 1.0; waveformPanelConstr.fill = GridBagConstraints.BOTH; waveformPanelConstr.gridx = 0; waveformPanelConstr.gridy = 0; waveformPanelConstr.gridwidth = 1; waveformPanelConstr.gridheight = 1; waveformPanelGridBag.setConstraints(sineButton, waveformPanelConstr); waveformPanel.add(sineButton); waveformPanelRadio.add(sineButton); sineButton.addActionListener(actionListener); waveformPanelConstr.gridx = 1; waveformPanelConstr.gridy = 0; waveformPanelConstr.gridwidth = 1; waveformPanelConstr.gridheight = 1; waveformPanelGridBag.setConstraints(squareButton, waveformPanelConstr); waveformPanel.add(squareButton); waveformPanelRadio.add(squareButton); squareButton.addActionListener(actionListener); waveformPanelConstr.gridx = 2; waveformPanelConstr.gridy = 0; waveformPanelConstr.gridwidth = 1; waveformPanelConstr.gridheight = 1; waveformPanelGridBag.setConstraints(sawtoothButton, waveformPanelConstr); waveformPanel.add(sawtoothButton); waveformPanelRadio.add(sawtoothButton); sawtoothButton.addActionListener(actionListener); waveformPanelConstr.gridx = 3; waveformPanelConstr.gridy = 0; waveformPanelConstr.gridwidth = 1; waveformPanelConstr.gridheight = 1; waveformPanelGridBag.setConstraints(triangleButton, waveformPanelConstr); waveformPanel.add(triangleButton); waveformPanelRadio.add(triangleButton); triangleButton.addActionListener(actionListener); // Panel components: exitPanel exitPanel.setLayout(new GridLayout(1, 5)); exitPanel.add(label1); exitPanel.add(label2); exitPanel.add(exitButton); exitButton.addActionListener(actionListener); exitPanel.add(label3); exitPanel.add(label4); GridBagLayout thisGridBag = new GridBagLayout(); GridBagConstraints thisConstr = new GridBagConstraints(); this.getContentPane().setLayout(thisGridBag); thisConstr.anchor = GridBagConstraints.CENTER; thisConstr.weightx = 1.0; thisConstr.weighty = 1.0; thisConstr.fill = GridBagConstraints.BOTH; thisConstr.gridx = 0; thisConstr.gridy = 0; thisConstr.gridwidth = 3; thisConstr.gridheight = 1; thisGridBag.setConstraints(label5, thisConstr); this.getContentPane().add(label5); thisConstr.gridx = 0; thisConstr.gridy = 1; thisConstr.gridwidth = 1; thisConstr.gridheight = 1; thisGridBag.setConstraints(label6, thisConstr); this.getContentPane().add(label6); thisConstr.gridx = 1; thisConstr.gridy = 1; thisConstr.gridwidth = 1; thisConstr.gridheight = 1; thisGridBag.setConstraints(waveformPanel, thisConstr); this.getContentPane().add(waveformPanel); thisConstr.gridx = 2; thisConstr.gridy = 1; thisConstr.gridwidth = 1; thisConstr.gridheight = 1; thisGridBag.setConstraints(label7, thisConstr); this.getContentPane().add(label7); thisConstr.gridx = 1; thisConstr.gridy = 2; thisConstr.gridwidth = 1; thisConstr.gridheight = 1; thisGridBag.setConstraints(exitPanel, thisConstr); this.getContentPane().add(exitPanel); // Set frame size and show it setSize(500, 200); setVisible(true); } // Frame constructor ElectronicOrganFrame ()
/** * Create and return the toolbar with the node formatting options. * * @return UIToolBar, the toolbar with all the node formatting options. */ private UIToolBar createToolBar(int orientation) { tbrToolBar = new UIToolBar( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.name"), UIToolBar.NORTHSOUTH); // $NON-NLS-1$ tbrToolBar.setOrientation(orientation); tbrToolBar.setEnabled(false); CSH.setHelpIDString(tbrToolBar, "toolbars.formatlink"); // $NON-NLS-1$ GridBagLayout grid = new GridBagLayout(); linkPanel = new JPanel(grid); linkColourPanel = new JPanel(new BorderLayout()); linkColourPanel.setBackground(Color.black); JLabel label = new JLabel(" "); // $NON-NLS-1$ GridBagConstraints con5 = new GridBagConstraints(); con5.fill = GridBagConstraints.NONE; con5.anchor = GridBagConstraints.CENTER; grid.addLayoutComponent(label, con5); linkPanel.add(label); txtLinkColour = new JLabel(UIImages.get(BACKGROUND_COLOUR)); txtLinkColour.setBorder(null); txtLinkColour.setToolTipText( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectLinkColour")); //$NON-NLS-1$ txtLinkColour.setEnabled(false); txtLinkColour.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { int clickCount = e.getClickCount(); if (clickCount == 1 && txtLinkColour.isEnabled()) { onUpdateLinkColour(linkColourPanel.getBackground().getRGB()); } } }); linkColourPanel.add(txtLinkColour, BorderLayout.CENTER); GridBagConstraints con = new GridBagConstraints(); con.fill = GridBagConstraints.NONE; con.anchor = GridBagConstraints.CENTER; grid.addLayoutComponent(linkColourPanel, con); linkPanel.add(linkColourPanel); btLinkColour = new UIImageButton(UIImages.get(RIGHT_ARROW_ICON)); btLinkColour.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { int clickCount = e.getClickCount(); if (clickCount == 1 && txtLinkColour.isEnabled()) { if (oColorChooserDialog != null) { oColorChooserDialog.setColour(selectedLinkColour); } else { oColorChooserDialog = new UIColorChooserDialog(ProjectCompendium.APP, selectedLinkColour); } oColorChooserDialog.setVisible(true); Color oColour = oColorChooserDialog.getColour(); oColorChooserDialog.setVisible(false); if (oColour != null) { linkColourPanel.setBackground(oColour); onUpdateLinkColour(oColour.getRGB()); } } } }); linkPanel.add(btLinkColour); label = new JLabel(" "); // $NON-NLS-1$ GridBagConstraints con4 = new GridBagConstraints(); con4.fill = GridBagConstraints.NONE; con4.anchor = GridBagConstraints.CENTER; grid.addLayoutComponent(label, con4); linkPanel.add(label); tbrToolBar.add(linkPanel); CSH.setHelpIDString(txtLinkColour, "toolbars.formatlink"); // $NON-NLS-1$ tbrToolBar.add(createWeightChoiceBox()); tbrToolBar.add(createArrowChoiceBox()); tbrToolBar.add(createLinkStyleChoiceBox()); tbrToolBar.add(createLinkDashedChoiceBox()); return tbrToolBar; }
public RecorderDialog(EditorServer parent) { super(parent, true); setTitle("Recorder Info"); // fieldsPanel JPanel fieldsPanel = new JPanel(); GridBagLayout gbLayout = new GridBagLayout(); GridBagConstraints constraints; // Address/Port/TTL : constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.EAST; constraints.insets = new Insets(5, 5, 0, 0); fieldsPanel.setLayout(gbLayout); JLabel AddPTTLabel = new JLabel("Address/Port/TTL :"); gbLayout.setConstraints(AddPTTLabel, constraints); fieldsPanel.add(AddPTTLabel, constraints); constraints = new GridBagConstraints(); constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.insets = new Insets(5, 5, 0, 5); constraints.weightx = 1.0D; addressPortTTL = new JTextField(25); addressPortTTL.setText("224.20.20.20/20002"); gbLayout.setConstraints(addressPortTTL, constraints); fieldsPanel.add(addressPortTTL, constraints); // Outputfile... constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.EAST; constraints.insets = new Insets(5, 5, 0, 0); JLabel OFileLabel = new JLabel("Save file as... :"); gbLayout.setConstraints(OFileLabel, constraints); fieldsPanel.add(OFileLabel, constraints); constraints = new GridBagConstraints(); constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.insets = new Insets(5, 5, 0, 5); constraints.weightx = 1.0D; outFile = new JTextField(25); outFile.setText("Placebo.rtp"); gbLayout.setConstraints(outFile, constraints); fieldsPanel.add(outFile, constraints); // Recording time... constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.EAST; constraints.insets = new Insets(5, 5, 0, 0); JLabel timeLabel = new JLabel("Recording time (in seconds) : "); gbLayout.setConstraints(timeLabel, constraints); fieldsPanel.add(timeLabel, constraints); constraints = new GridBagConstraints(); constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.insets = new Insets(5, 5, 0, 5); constraints.weightx = 1.0D; durationField = new JTextField(25); durationField.setText("2700"); gbLayout.setConstraints(durationField, constraints); fieldsPanel.add(durationField, constraints); // The buttons... JPanel buttonPanel = new JPanel(); JButton startRecordingButton = new JButton("Start Recording"); startRecordingButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent buttonPressed) { // startThread here !!! String apt = addressPortTTL.getText().trim(); String ofile = outFile.getText().trim(); String duration = durationField.getText().trim(); System.out.println( "\napt : *" + apt + "* ofile : *" + ofile + "* duration: *" + duration + "*"); long dur = new Integer(duration).intValue() * 1000; // turned into ms recorder = new Recorder(apt, ofile, dur); recorder.start(); document.resetStartTime(System.currentTimeMillis()); // close dialog Box dispose(); } // }); // endActionListener buttonPanel.add(startRecordingButton); Container dialogContainer = getContentPane(); dialogContainer.setLayout(new BorderLayout()); dialogContainer.add(fieldsPanel, BorderLayout.CENTER); dialogContainer.add(buttonPanel, BorderLayout.SOUTH); pack(); setLocationRelativeTo(parent); }