List of usage examples for javax.swing BoxLayout LINE_AXIS
int LINE_AXIS
To view the source code for javax.swing BoxLayout LINE_AXIS.
Click Source Link
From source file:op.FrmMain.java
/** * This method is called from within the constructor to * initialize the form./*from w ww . jav a2 s . c om*/ * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the PrinterForm Editor. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { pnlMain = new JPanel(); pnlMainMessage = new JPanel(); btnTX = new JButton(); panel1 = new JPanel(); pnlIcons = new JPanel(); lblMainMsg = new JLabel(); btnExit = new JButton(); lblSubMsg = new JideLabel(); btnHelp = new JButton(); pbMsg = new JProgressBar(); btnReload = new JButton(); splitPaneLeft = new JideSplitPane(); pnlCard = new JPanel(); pnlWait = new JPanel(); lblWait = new JLabel(); pbTimeout = new JProgressBar(); panel2 = new JPanel(); btnResetSplitpane = new JButton(); statusBar = new StatusBar(); //======== this ======== setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setTitle("Offene-Pflege.de"); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { thisWindowClosing(e); } }); Container contentPane = getContentPane(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.X_AXIS)); //======== pnlMain ======== { pnlMain.setLayout(new FormLayout("0dlu, $lcgap, pref, $lcgap, left:default:grow, 2*($rgap)", "$rgap, pref, $rgap, default:grow, 3dlu, $nlgap, bottom:pref, $lgap, 0dlu")); //======== pnlMainMessage ======== { pnlMainMessage.setBackground(new Color(220, 223, 208)); pnlMainMessage.setBorder(new SoftBevelBorder(SoftBevelBorder.RAISED)); pnlMainMessage.setLayout(new FormLayout( "0dlu, $lcgap, 23dlu, $lcgap, default:grow, $lcgap, min, $lcgap, 0dlu", "0dlu, $lgap, 15dlu, $lgap, fill:11dlu, $lgap, fill:pref:grow, $lgap, pref, $lgap, 0dlu")); //---- btnTX ---- btnTX.setIcon(new ImageIcon(getClass().getResource("/artwork/32x32/ambulance2.png"))); btnTX.setBorder(null); btnTX.setBorderPainted(false); btnTX.setSelectedIcon(null); btnTX.setToolTipText("Verlegungsbericht drucken"); btnTX.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnTX.setPressedIcon( new ImageIcon(getClass().getResource("/artwork/32x32/ambulance2_pressed.png"))); btnTX.setContentAreaFilled(false); btnTX.addActionListener(e -> btnTXActionPerformed(e)); pnlMainMessage.add(btnTX, CC.xywh(3, 3, 1, 3)); //======== panel1 ======== { panel1.setOpaque(false); panel1.setLayout(new BoxLayout(panel1, BoxLayout.LINE_AXIS)); //======== pnlIcons ======== { pnlIcons.setOpaque(false); pnlIcons.setLayout(new BoxLayout(pnlIcons, BoxLayout.LINE_AXIS)); } panel1.add(pnlIcons); //---- lblMainMsg ---- lblMainMsg.setText("OPDE"); lblMainMsg.setFont(new Font("Arial Rounded MT Bold", Font.PLAIN, 22)); lblMainMsg.setForeground(new Color(105, 80, 69)); lblMainMsg.setHorizontalAlignment(SwingConstants.CENTER); lblMainMsg.setIcon(null); lblMainMsg.setHorizontalTextPosition(SwingConstants.LEADING); panel1.add(lblMainMsg); } pnlMainMessage.add(panel1, CC.xy(5, 3, CC.CENTER, CC.DEFAULT)); //---- btnExit ---- btnExit.setIcon(new ImageIcon(getClass().getResource("/artwork/32x32/lock.png"))); btnExit.setBorder(null); btnExit.setBorderPainted(false); btnExit.setOpaque(false); btnExit.setContentAreaFilled(false); btnExit.setToolTipText("Abmelden"); btnExit.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnExit.setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/lock_pressed.png"))); btnExit.addActionListener(e -> btnExitActionPerformed(e)); pnlMainMessage.add(btnExit, CC.xywh(7, 3, 1, 3)); //---- lblSubMsg ---- lblSubMsg.setText("OPDE"); lblSubMsg.setFont(new Font("Arial", Font.PLAIN, 14)); lblSubMsg.setForeground(new Color(105, 80, 69)); lblSubMsg.setHorizontalAlignment(SwingConstants.CENTER); lblSubMsg.setVerticalAlignment(SwingConstants.TOP); pnlMainMessage.add(lblSubMsg, CC.xywh(5, 5, 1, 3)); //---- btnHelp ---- btnHelp.setText(null); btnHelp.setIcon(new ImageIcon(getClass().getResource("/artwork/32x32/help.png"))); btnHelp.setBorderPainted(false); btnHelp.setContentAreaFilled(false); btnHelp.setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/help_pressed.png"))); btnHelp.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnHelp.addActionListener(e -> btnHelpActionPerformed(e)); pnlMainMessage.add(btnHelp, CC.xywh(3, 7, 1, 3)); //---- pbMsg ---- pbMsg.setValue(50); pbMsg.setFont(new Font("Arial Rounded MT Bold", Font.PLAIN, 12)); pbMsg.setForeground(new Color(105, 80, 69)); pnlMainMessage.add(pbMsg, CC.xy(5, 9, CC.FILL, CC.FILL)); //---- btnReload ---- btnReload.setIcon(new ImageIcon(getClass().getResource("/artwork/32x32/reload0000.png"))); btnReload.setBorder(null); btnReload.setBorderPainted(false); btnReload.setOpaque(false); btnReload.setContentAreaFilled(false); btnReload.setToolTipText("Ansicht aktualisieren"); btnReload.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnReload .setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/reload_pressed.png"))); btnReload.addActionListener(e -> btnReloadActionPerformed(e)); pnlMainMessage.add(btnReload, CC.xywh(7, 7, 1, 3)); } pnlMain.add(pnlMainMessage, CC.xywh(3, 2, 4, 1, CC.DEFAULT, CC.FILL)); //---- splitPaneLeft ---- splitPaneLeft.setOneTouchExpandable(true); splitPaneLeft.setProportionalLayout(true); splitPaneLeft.setShowGripper(true); splitPaneLeft.addPropertyChangeListener("dividerLocation", e -> splitPaneLeftPropertyChange(e)); pnlMain.add(splitPaneLeft, CC.xy(3, 4, CC.FILL, CC.FILL)); //======== pnlCard ======== { pnlCard.setLayout(new CardLayout()); //======== pnlWait ======== { pnlWait.setLayout(new BorderLayout()); //---- lblWait ---- lblWait.setText("text"); lblWait.setFont(new Font("Arial", Font.BOLD, 22)); lblWait.setHorizontalAlignment(SwingConstants.CENTER); pnlWait.add(lblWait, BorderLayout.CENTER); } pnlCard.add(pnlWait, "cardWait"); } pnlMain.add(pnlCard, CC.xy(5, 4, CC.FILL, CC.FILL)); pnlMain.add(pbTimeout, CC.xywh(3, 5, 4, 1, CC.FILL, CC.DEFAULT)); //======== panel2 ======== { panel2.setLayout(new BoxLayout(panel2, BoxLayout.X_AXIS)); //---- btnResetSplitpane ---- btnResetSplitpane.setText(null); btnResetSplitpane .setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/view_top_bottom.png"))); btnResetSplitpane.setAlignmentY(1.0F); btnResetSplitpane.addActionListener(e -> btnResetSplitpaneActionPerformed(e)); panel2.add(btnResetSplitpane); //---- statusBar ---- statusBar.setBackground(new Color(238, 238, 238)); statusBar.setAlignmentY(1.0F); panel2.add(statusBar); } pnlMain.add(panel2, CC.xywh(3, 7, 4, 1, CC.FILL, CC.BOTTOM)); } contentPane.add(pnlMain); setSize(945, 695); setLocationRelativeTo(getOwner()); }
From source file:op.tools.DlgListSelector.java
/** * This method is called from within the constructor to * initialize the form.// w w w .j a v a 2 s . c o m * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the PrinterForm Editor. */ // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initComponents() { lblTopic = new JLabel(); lblDetail = new JLabel(); jScrollPane1 = new JScrollPane(); lstSelect = new JList(); panel1 = new JPanel(); btnApply = new JButton(); btnCancel = new JButton(); //======== this ======== setResizable(false); setModalityType(Dialog.ModalityType.APPLICATION_MODAL); Container contentPane = getContentPane(); contentPane.setLayout(new FormLayout("$rgap, $lcgap, default:grow, $lcgap, $rgap", "$rgap, 2*($lgap, fill:default), $lgap, fill:default:grow, $lgap, fill:default, $lgap, $rgap")); //---- lblTopic ---- lblTopic.setFont(new Font("Dialog", Font.BOLD, 14)); lblTopic.setText("jLabel1"); contentPane.add(lblTopic, CC.xywh(3, 3, 2, 1)); //---- lblDetail ---- lblDetail.setFont(new Font("Dialog", Font.PLAIN, 12)); lblDetail.setText("jLabel2"); contentPane.add(lblDetail, CC.xywh(3, 5, 2, 1)); //======== jScrollPane1 ======== { //---- lstSelect ---- lstSelect.setModel(new AbstractListModel() { String[] values = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; @Override public int getSize() { return values.length; } @Override public Object getElementAt(int i) { return values[i]; } }); lstSelect.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { lstSelectMouseClicked(e); } }); jScrollPane1.setViewportView(lstSelect); } contentPane.add(jScrollPane1, CC.xywh(3, 7, 2, 1)); //======== panel1 ======== { panel1.setLayout(new BoxLayout(panel1, BoxLayout.LINE_AXIS)); //---- btnApply ---- btnApply.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png"))); btnApply.setText("W\u00e4hlen"); btnApply.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnApplyActionPerformed(e); } }); panel1.add(btnApply); //---- btnCancel ---- btnCancel.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png"))); btnCancel.setText("Abbrechen"); btnCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnCancelActionPerformed(e); } }); panel1.add(btnCancel); } contentPane.add(panel1, CC.xy(3, 9, CC.RIGHT, CC.DEFAULT)); setSize(600, 441); setLocationRelativeTo(null); }
From source file:org.ayound.js.debug.ui.DebugMainFrame.java
private void initToolBar() { toolBar = new JToolBar(); Container debugInfoContainer = new Box(BoxLayout.LINE_AXIS); toolBar.add(debugInfoContainer);/* w w w . j a va 2 s .c om*/ JLabel urlLabel = new JLabel(Messages.getString("DebugMainFrame.UrlLabel")); //$NON-NLS-1$ debugInfoContainer.add(urlLabel); urlText = new JTextField(20); String historyUrl = ConfigUtil.getPropertie("url"); if (historyUrl == null) { File testFile = new File(new File(getBaseDir()), "test/test.htm"); //$NON-NLS-1$ urlText.setText(testFile.getAbsolutePath().replace('\\', '/')); } else { urlText.setText(historyUrl); } debugInfoContainer.add(urlText); urlButton = new JButton(Messages.getString("DebugMainFrame.Select")); //$NON-NLS-1$ urlButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub JFileChooser fileDialog = new JFileChooser(); // fileDialog.setFileFilter(new FileFilter() { @Override public boolean accept(File f) { String fileName = f.getName().toLowerCase(); if (fileName.endsWith(".htm") //$NON-NLS-1$ || fileName.endsWith(".html") //$NON-NLS-1$ || f.isDirectory()) { return true; } else { return false; } } @Override public String getDescription() { return ".htm,.html"; //$NON-NLS-1$ } }); int result = fileDialog.showOpenDialog(DebugMainFrame.this); if (result == JFileChooser.APPROVE_OPTION) { urlText.setText(fileDialog.getSelectedFile().getAbsolutePath()); } } }); debugInfoContainer.add(urlButton); JLabel portLabel = new JLabel(Messages.getString("DebugMainFrame.PortLabel")); //$NON-NLS-1$ debugInfoContainer.add(portLabel); portText = new JTextField(2); portText.setText("8088"); //$NON-NLS-1$ debugInfoContainer.add(portText); JLabel browserLabel = new JLabel(Messages.getString("DebugMainFrame.BrowserLabel")); //$NON-NLS-1$ debugInfoContainer.add(browserLabel); browserText = new JTextField(20); debugInfoContainer.add(browserText); String historyBrowser = ConfigUtil.getPropertie("browser"); if (historyBrowser != null) { browserText.setText(historyBrowser); // .setText("C:\\Program Files\\Internet Explorer\\iexplore.exe"); // //$NON-NLS-1$ } browserButton = new JButton(Messages.getString("DebugMainFrame.Select")); //$NON-NLS-1$ browserButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub JFileChooser fileDialog = new JFileChooser(); // fileDialog.setFileFilter(new FileFilter() { @Override public boolean accept(File f) { String fileName = f.getName().toLowerCase(); if (fileName.endsWith(".exe") || f.isDirectory()) { //$NON-NLS-1$ return true; } else { return false; } } @Override public String getDescription() { return ".exe(windows)"; //$NON-NLS-1$ } }); int result = fileDialog.showOpenDialog(DebugMainFrame.this); if (result == JFileChooser.APPROVE_OPTION) { browserText.setText(fileDialog.getSelectedFile().getAbsolutePath()); } } }); debugInfoContainer.add(browserButton); toolBar.addSeparator(); JButton startBtn = toolBar.add(actionDebugStart); startBtn.setToolTipText(Messages.getString("DebugMainFrame.StartDebug")); //$NON-NLS-1$ JButton endBtn = toolBar.add(actionDebugEnd); endBtn.setToolTipText(Messages.getString("DebugMainFrame.EndDebug")); //$NON-NLS-1$ getContentPane().add(toolBar, BorderLayout.BEFORE_FIRST_LINE); }
From source file:org.ciscavate.cjwizard.WizardContainer.java
/** * /*from w w w. j av a2 s. co m*/ */ private void initComponents() { final JButton prevBtn = new JButton(_prevAction); final JButton nextBtn = new JButton(_nextAction); final JButton finishBtn = new JButton(_finishAction); final JButton cancelBtn = new JButton(_cancelAction); final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS)); buttonPanel.add(Box.createHorizontalGlue()); buttonPanel.add(prevBtn); buttonPanel.add(Box.createHorizontalStrut(5)); buttonPanel.add(nextBtn); buttonPanel.add(Box.createHorizontalStrut(10)); buttonPanel.add(finishBtn); buttonPanel.add(Box.createHorizontalStrut(10)); buttonPanel.add(cancelBtn); buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 15, 5, 15)); this.setLayout(new BorderLayout()); this.add(_template, BorderLayout.CENTER); this.add(buttonPanel, BorderLayout.SOUTH); }
From source file:org.isatools.gui.datamanager.exportisa.ExportISAGUI.java
public void createGUI() { // header image add(UIHelper.wrapComponentInPanel(new JLabel(panelHeader, SwingConstants.RIGHT)), BorderLayout.NORTH); // add a checkable jtree with investigations & studies... JPanel availableSubmissionsContainer = new JPanel(new BorderLayout()); availableSubmissionsContainer.setOpaque(false); JPanel optionsContainer = new JPanel(); optionsContainer.setLayout(new BoxLayout(optionsContainer, BoxLayout.LINE_AXIS)); optionsContainer.setOpaque(false);/*from w w w. j ava 2 s .com*/ JPanel optionsAndInformationPanel = new JPanel(); optionsAndInformationPanel.setLayout(new BoxLayout(optionsAndInformationPanel, BoxLayout.PAGE_AXIS)); optionsAndInformationPanel.setOpaque(false); JLabel fileInformation = UIHelper.createLabel("<html><i>where</i> to save the isatab files?</html>", UIHelper.VER_12_BOLD, UIHelper.LIGHT_GREY_COLOR); fileInformation.setVerticalAlignment(JLabel.TOP); JPanel fileLocationOptionContainer = new JPanel(); fileLocationOptionContainer.setLayout(new BoxLayout(fileLocationOptionContainer, BoxLayout.PAGE_AXIS)); fileLocationOptionContainer.setOpaque(false); // add component for selection of output to repository or output to folder... fileLocationOptionGroup = new OptionGroup<String>(OptionGroup.HORIZONTAL_ALIGNMENT, true); fileLocationOptionGroup.addOptionItem("BII repository", true); fileLocationOptionGroup.addOptionItem("Local file system"); localDirectoryLocation = new FileSelectionUtil("select output directory", createFileChooser(), UIHelper.VER_11_BOLD, UIHelper.GREY_COLOR); localDirectoryLocation.setVisible(false); localDirectoryLocation.setPreferredSize(new Dimension(150, 20)); fileLocationOptionGroup.addPropertyChangeListener("optionSelectionChange", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { localDirectoryLocation .setVisible(fileLocationOptionGroup.getSelectedItem().equals("Local file system")); revalidate(); } }); fileLocationOptionContainer.add(UIHelper.wrapComponentInPanel(fileInformation)); fileLocationOptionContainer.add(UIHelper.wrapComponentInPanel(fileLocationOptionGroup)); fileLocationOptionContainer.add(Box.createVerticalStrut(5)); fileLocationOptionContainer.add(UIHelper.wrapComponentInPanel(localDirectoryLocation)); optionsContainer.add(fileLocationOptionContainer); JPanel dataFileExportOptionContainer = new JPanel(); dataFileExportOptionContainer.setLayout(new BoxLayout(dataFileExportOptionContainer, BoxLayout.PAGE_AXIS)); dataFileExportOptionContainer.setOpaque(false); JLabel dataFileExportInformation = UIHelper.createLabel("<html>export data files?</html>", UIHelper.VER_12_BOLD, UIHelper.LIGHT_GREY_COLOR); dataFileExportInformation.setVerticalAlignment(JLabel.TOP); dataFileExportOptionGroup = new OptionGroup<String>(OptionGroup.HORIZONTAL_ALIGNMENT, true); dataFileExportOptionGroup.addOptionItem("yes", true); dataFileExportOptionGroup.addOptionItem("no"); dataFileExportOptionContainer.add(UIHelper.wrapComponentInPanel(dataFileExportInformation)); dataFileExportOptionContainer.add(UIHelper.wrapComponentInPanel(dataFileExportOptionGroup)); dataFileExportOptionContainer.add(Box.createVerticalStrut(25)); optionsContainer.add(dataFileExportOptionContainer); optionsAndInformationPanel.add(Box.createVerticalStrut(5)); optionsAndInformationPanel.add(optionsContainer); optionsAndInformationPanel.add(Box.createVerticalStrut(10)); JLabel information = UIHelper.createLabel( "<html>please <i>select</i> the submissions to be exported...</html>", UIHelper.VER_12_BOLD, UIHelper.LIGHT_GREY_COLOR); information.setVerticalAlignment(JLabel.TOP); optionsAndInformationPanel.add(UIHelper.wrapComponentInPanel(information)); optionsAndInformationPanel.add(Box.createVerticalStrut(5)); availableSubmissionsContainer.add(optionsAndInformationPanel, BorderLayout.NORTH); retrieveAndProcessStudyInformation(); JScrollPane treeScroller = new JScrollPane(studyAvailabilityTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); treeScroller.getViewport().setOpaque(false); treeScroller.setOpaque(false); treeScroller.setBorder(new EmptyBorder(1, 1, 1, 1)); treeScroller.setPreferredSize(new Dimension(380, 250)); availableSubmissionsContainer.add(treeScroller, BorderLayout.CENTER); add(availableSubmissionsContainer, BorderLayout.CENTER); add(createSouthPanel(), BorderLayout.SOUTH); }
From source file:org.isatools.gui.optionselector.OptionGroup.java
/** * OptionGroup contains a number of items which you can either select one or many of depending on the single selection parameter * * @param alignment - e.g. OptionGroup.HORIZONTAL_ALIGNMENT to align the options in a horizontal arrangement. * @param singleSelection - whether or not this group should allow singular selection (true) or multiple option selection (false) *///from w w w. j a va 2 s. co m public OptionGroup(int alignment, boolean singleSelection) { this.singleSelection = singleSelection; this.alignment = alignment; availableOptions = new ListOrderedMap<T, OptionItem>(); setLayout( new BoxLayout(this, alignment == HORIZONTAL_ALIGNMENT ? BoxLayout.LINE_AXIS : BoxLayout.PAGE_AXIS)); setOpaque(false); }
From source file:org.isatools.isacreator.filechooser.FileChooserUI.java
private JPanel createTopPanel() { final JTextField uri = new RoundedJTextField(20); final JTextField username = new RoundedJTextField(20); final JPasswordField password = new RoundedJPasswordField(20); final JPanel topContainer = new JPanel(); topContainer.setLayout(new BoxLayout(topContainer, BoxLayout.PAGE_AXIS)); topContainer.setBackground(UIHelper.BG_COLOR); HUDTitleBar titlePanel = new HUDTitleBar(null, null, true); add(titlePanel, BorderLayout.NORTH); titlePanel.installListeners();/*from w w w. ja v a 2 s . c o m*/ topContainer.add(titlePanel); JPanel buttonPanel = new JPanel(new GridLayout(1, 1)); buttonPanel.setOpaque(false); JPanel fileSystemPanel = new JPanel(); fileSystemPanel.setLayout(new BoxLayout(fileSystemPanel, BoxLayout.LINE_AXIS)); fileSystemPanel.setBackground(UIHelper.BG_COLOR); localFsChoice = new JLabel(localFileSystemIcon, JLabel.LEFT); localFsChoice.setBackground(UIHelper.BG_COLOR); localFsChoice.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { SwingUtilities.invokeLater(new Runnable() { public void run() { localFsChoice.setIcon(localFileSystemIconOver); remoteFsChoice.setIcon(remoteFileSystemIcon); ftpConnectionContainer.setVisible(false); topContainer.revalidate(); status.setText(""); fileBrowser = new LocalBrowser(); try { updateTree(fileBrowser.getHomeDirectory()); } catch (IOException e) { FileBrowserTreeNode defaultFTPNode = new FileBrowserTreeNode("problem occurred!", false, FileBrowserTreeNode.DIRECTORY); updateTree(defaultFTPNode); } } }); } }); fileSystemPanel.add(localFsChoice); fileSystemPanel.add(Box.createHorizontalStrut(5)); remoteFsChoice = new JLabel(remoteFileSystemIcon, JLabel.LEFT); remoteFsChoice.setBackground(UIHelper.BG_COLOR); remoteFsChoice.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { SwingUtilities.invokeLater(new Runnable() { public void run() { localFsChoice.setIcon(localFileSystemIcon); remoteFsChoice.setIcon(remoteFileSystemIconOver); ftpConnectionContainer.setVisible(true); topContainer.revalidate(); } }); // immediately try to call FTP manager to get last sessions details final FTPAuthentication lastSession; if ((lastSession = ftpManager.getLastSession()) != null) { Thread remoteConnector = new Thread(new Runnable() { public void run() { connectToFTP(lastSession.getUri(), lastSession.getUsername(), lastSession.getPassword()); } }); remoteConnector.start(); } else { errorAction("no ftp location"); } } }); fileSystemPanel.add(remoteFsChoice); fileSystemPanel.add(Box.createHorizontalStrut(5)); status = UIHelper.createLabel("", UIHelper.VER_10_BOLD, UIHelper.DARK_GREEN_COLOR); status.setHorizontalAlignment(JLabel.RIGHT); fileSystemPanel.add(status); buttonPanel.add(fileSystemPanel); topContainer.add(buttonPanel); // now create panel to configure the FTP site ftpConnectionContainer = new JPanel(new GridLayout(1, 1)); ftpConnectionContainer.setBackground(UIHelper.BG_COLOR); JPanel userAuthFTP = new JPanel(); userAuthFTP.setLayout(new BoxLayout(userAuthFTP, BoxLayout.LINE_AXIS)); userAuthFTP.setOpaque(false); // add field to add URI JPanel uriPanel = new JPanel(new GridLayout(1, 2)); uriPanel.setBackground(UIHelper.BG_COLOR); JLabel uriLab = UIHelper.createLabel("FTP URI: ", UIHelper.VER_10_BOLD, UIHelper.DARK_GREEN_COLOR); UIHelper.renderComponent(uri, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR, false); uriPanel.add(uriLab); uriPanel.add(uri); userAuthFTP.add(uriPanel); // add field to add username JPanel usernamePanel = new JPanel(new GridLayout(1, 2)); usernamePanel.setBackground(UIHelper.BG_COLOR); JLabel usernameLab = UIHelper.createLabel("Username: ", UIHelper.VER_10_BOLD, UIHelper.DARK_GREEN_COLOR); UIHelper.renderComponent(username, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR, false); uriPanel.add(usernameLab); uriPanel.add(username); userAuthFTP.add(usernamePanel); // add field to add password JPanel passwordPanel = new JPanel(new GridLayout(1, 2)); passwordPanel.setBackground(UIHelper.BG_COLOR); JLabel passwordLab = UIHelper.createLabel("Password: ", UIHelper.VER_10_BOLD, UIHelper.DARK_GREEN_COLOR); UIHelper.renderComponent(password, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR, false); passwordPanel.add(passwordLab); passwordPanel.add(password); userAuthFTP.add(passwordPanel); JLabel connectLab = new JLabel(connectIcon); connectLab.setOpaque(false); connectLab.setToolTipText("<html><b>Connect</b><p>Connect to the FTP source defined!</p></html>"); connectLab.addMouseListener(new CommonMouseAdapter() { public void mousePressed(MouseEvent event) { super.mousePressed(event); if (uri.getText() != null && !uri.getText().trim().equals("")) { String user = (username.getText() != null) ? username.getText() : ""; String pass = (password.getPassword() != null) ? new String(password.getPassword()) : ""; final FTPAuthentication newFTPLocation = new FTPAuthentication(uri.getText(), user, pass); Thread remoteConnector = new Thread(new Runnable() { public void run() { connectToFTP(newFTPLocation.getUri(), newFTPLocation.getUsername(), newFTPLocation.getPassword()); } }); remoteConnector.start(); } } }); userAuthFTP.add(connectLab); JLabel historyLab = new JLabel(viewHistoryIcon); historyLab.setOpaque(false); historyLab.setToolTipText( "<html><b>Search previously connected to FTP locations</b><p>Connect to a previously defined FTP location</p></html>"); historyLab.addMouseListener(new CommonMouseAdapter() { public void mousePressed(MouseEvent event) { super.mousePressed(event); SelectFromFTPHistory selectFTP = new SelectFromFTPHistory(); selectFTP.addPropertyChangeListener("locationSelected", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getNewValue() != null) { final FTPAuthentication ftpRecord = ftpManager .retrieveFTPAuthenticationObject(event.getNewValue().toString()); Thread remoteConnector = new Thread(new Runnable() { public void run() { connectToFTP(ftpRecord.getUri(), ftpRecord.getUsername(), ftpRecord.getPassword()); } }); remoteConnector.start(); } } }); selectFTP.createGUI(); showJDialogAsSheet(selectFTP); } }); userAuthFTP.add(historyLab); ftpConnectionContainer.add(userAuthFTP); ftpConnectionContainer.setVisible(false); topContainer.add(ftpConnectionContainer); return topContainer; }
From source file:org.isatools.isacreator.filechooser.FileChooserUI.java
/** * Creates the FileSelection panel containing the list of selected files, and the toolbar to modify the list * * @return JPanel containing a selection pane *///from w w w .j a v a 2 s . c o m private JPanel createFilesSelectedPanel() { JPanel selectionContainer = new JPanel(new BorderLayout()); selectionContainer.setBackground(UIHelper.BG_COLOR); selectionContainer.setBorder( new TitledBorder(UIHelper.GREEN_ROUNDED_BORDER, "selection(s)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR)); selectedFiles = new DirectoryFileList(); listModel = (DefaultListModel) selectedFiles.getModel(); selectedFiles.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); selectedFiles.setDragEnabled(false); JScrollPane selectedFileScroller = new JScrollPane(selectedFiles, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); selectedFileScroller.setPreferredSize(new Dimension(200, 175)); selectedFileScroller.setBorder(new EmptyBorder(0, 0, 0, 0)); IAppWidgetFactory.makeIAppScrollPane(selectedFileScroller); selectionContainer.add(selectedFileScroller, BorderLayout.CENTER); // add list modification toolbar to sort, move, and delete files from the list. JPanel optionsPanel = new JPanel(); optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.LINE_AXIS)); optionsPanel.setBackground(UIHelper.BG_COLOR); final JLabel moveDown = new JLabel(downIcon); moveDown.setOpaque(false); moveDown.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { moveDown.setIcon(downIcon); if (!selectedFiles.isSelectionEmpty()) { int toMoveDown = selectedFiles.getSelectedIndex(); if (toMoveDown != (listModel.getSize() - 1)) { swapElements(toMoveDown, toMoveDown + 1); } } } public void mouseEntered(MouseEvent event) { moveDown.setIcon(downIconOver); } public void mouseExited(MouseEvent event) { moveDown.setIcon(downIcon); } }); optionsPanel.add(moveDown); optionsPanel.add(Box.createHorizontalStrut(5)); final JLabel moveUp = new JLabel(upIcon); moveUp.setOpaque(false); moveUp.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { moveUp.setIcon(upIcon); if (!selectedFiles.isSelectionEmpty()) { int toMoveUp = selectedFiles.getSelectedIndex(); if (toMoveUp != 0) { swapElements(toMoveUp, toMoveUp - 1); } } } public void mouseEntered(MouseEvent event) { moveUp.setIcon(upIconOver); } public void mouseExited(MouseEvent event) { moveUp.setIcon(upIcon); } }); optionsPanel.add(moveUp); optionsPanel.add(Box.createHorizontalStrut(5)); final JLabel deleteItem = new JLabel(deleteIcon); deleteItem.setOpaque(false); deleteItem.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { deleteItem.setIcon(deleteIcon); if (selectedFiles.getSelectedValues() != null) { for (Object o : selectedFiles.getSelectedValues()) { listModel.removeElement(o); } } } public void mouseEntered(MouseEvent event) { deleteItem.setIcon(deleteIconOver); } public void mouseExited(MouseEvent event) { deleteItem.setIcon(deleteIcon); } }); optionsPanel.add(deleteItem); optionsPanel.add(Box.createHorizontalStrut(5)); final JLabel sortAsc = new JLabel(sortAscIcon); sortAsc.setOpaque(false); sortAsc.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { sortAsc.setIcon(sortAscIcon); if (listModel.getSize() > 0) { sort(true); } } public void mouseEntered(MouseEvent event) { sortAsc.setIcon(sortAscIconOver); } public void mouseExited(MouseEvent event) { sortAsc.setIcon(sortAscIcon); } }); optionsPanel.add(sortAsc); optionsPanel.add(Box.createHorizontalStrut(5)); final JLabel sortDesc = new JLabel(sortDescIcon); sortDesc.setOpaque(false); sortDesc.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { sortDesc.setIcon(sortDescIcon); if (listModel.getSize() > 0) { sort(false); } } public void mouseEntered(MouseEvent event) { sortDesc.setIcon(sortDescIconOver); } public void mouseExited(MouseEvent event) { sortDesc.setIcon(sortDescIcon); } }); optionsPanel.add(sortDesc); optionsPanel.add(Box.createHorizontalStrut(5)); selectionContainer.add(optionsPanel, BorderLayout.SOUTH); return selectionContainer; }
From source file:org.isatools.isacreator.filechooser.FileChooserUI.java
/** * Create the Navigation Tree panel//from w w w. j a v a 2s . co m * * @return @see JPanel containing the navigation tree to browse a file system. */ private JPanel createNavTree() { JPanel treeContainer = new JPanel(new BorderLayout()); treeContainer.setBackground(UIHelper.BG_COLOR); treeContainer .setBorder(new TitledBorder(UIHelper.GREEN_ROUNDED_BORDER, "", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR)); JPanel navigationControls = new JPanel(); navigationControls.setLayout(new BoxLayout(navigationControls, BoxLayout.LINE_AXIS)); navigationControls.setOpaque(false); final JLabel navToParentDir = new JLabel(upIcon); navToParentDir.setOpaque(false); navToParentDir.addMouseListener(new CommonMouseAdapter() { public void mousePressed(MouseEvent event) { super.mousePressed(event); navToParentDir.setIcon(upIcon); try { updateTree(fileBrowser.getParentDirectory()); } catch (IOException e) { errorAction("problem occurred!"); } } public void mouseEntered(MouseEvent event) { super.mouseEntered(event); navToParentDir.setIcon(upIconOver); } public void mouseExited(MouseEvent event) { super.mouseExited(event); navToParentDir.setIcon(upIcon); } }); navigationControls.add(navToParentDir); navigationControls.add(Box.createHorizontalStrut(5)); final JLabel navToHomeDir = new JLabel(homeIcon); navToHomeDir.setOpaque(false); navToHomeDir.addMouseListener(new CommonMouseAdapter() { public void mousePressed(MouseEvent event) { super.mousePressed(event); navToHomeDir.setIcon(homeIcon); try { updateTree(fileBrowser.getHomeDirectory()); } catch (IOException e) { if (e instanceof ConnectionException) { status.setText("<html>status: not connected!</html>"); } FileBrowserTreeNode defaultFTPNode = new FileBrowserTreeNode("problem occurred!", false, FileBrowserTreeNode.DIRECTORY); updateTree(defaultFTPNode); } } public void mouseEntered(MouseEvent event) { super.mouseEntered(event); navToHomeDir.setIcon(homeIconOver); } public void mouseExited(MouseEvent event) { super.mouseExited(event); navToHomeDir.setIcon(homeIcon); } }); navigationControls.add(navToHomeDir); navigationControls.add(Box.createGlue()); treeContainer.add(navigationControls, BorderLayout.NORTH); try { treeModel = new DefaultTreeModel(fileBrowser.getHomeDirectory()); directoryTree = new JTree(treeModel); directoryTree.setFont(UIHelper.VER_11_PLAIN); directoryTree.setCellRenderer(new FileSystemTreeCellRenderer()); } catch (IOException e) { FileBrowserTreeNode defaultFTPNode = new FileBrowserTreeNode("problem occurred!", false, FileBrowserTreeNode.DIRECTORY); updateTree(defaultFTPNode); } directoryTree.addMouseListener(new CommonMouseAdapter() { public void mousePressed(MouseEvent event) { super.mousePressed(event); int selRow = directoryTree.getRowForLocation(event.getX(), event.getY()); TreePath selPath = directoryTree.getPathForLocation(event.getX(), event.getY()); if (selRow != -1) { final FileBrowserTreeNode node = (FileBrowserTreeNode) selPath.getLastPathComponent(); if (SwingUtilities.isLeftMouseButton(event)) { if (event.getClickCount() == 2) { if ((node.getType() == FileBrowserTreeNode.DIRECTORY) && (node.getLevel() != 0)) { String newPath; if (fileBrowser instanceof LocalBrowser) { newPath = ((File) fileBrowser.getDirFiles().get(node.toString())).getPath(); } else { newPath = node.toString(); } updateTree(fileBrowser.changeDirectory(newPath)); } // else, if a leaf node, then add file to to list if (node.isLeaf() && (node.getType() != FileBrowserTreeNode.DIRECTORY)) { String extension = node.toString().substring(node.toString().lastIndexOf(".") + 1) .trim().toUpperCase(); FileChooserFile toAdd = null; for (Object o : fileBrowser.getFileMap().get(extension)) { String fileName; String filePath; if (fileBrowser instanceof LocalBrowser) { File file = (File) o; fileName = file.getName(); filePath = file.getPath(); if (fileName.equals(node.toString())) { toAdd = new CustomFile(filePath); break; } } else { FTPFile ftpFile = (FTPFile) o; fileName = ftpFile.getName(); filePath = fileBrowser.getAbsoluteWorkingDirectory() + File.separator + ftpFile.getName(); if (fileName.equals(node.toString())) { toAdd = new CustomFTPFile(ftpFile, filePath); break; } } } if (toAdd != null && !checkIfInList(toAdd)) { selectedFiles.addFileItem(toAdd); } } } } else { if ((node.getType() == FileBrowserTreeNode.DIRECTORY) && (node.getLevel() != 0)) { // show popup to add the directory to the selected files JPopupMenu popup = new JPopupMenu(); JMenuItem addDirectory = new JMenuItem("add directory"); addDirectory.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { Object fileToAdd = fileBrowser.getDirFiles().get(node.toString()); FileChooserFile toAdd; if (fileToAdd instanceof File) { toAdd = new CustomFile(((File) fileToAdd).getPath()); } else { FTPFile ftpFile = (FTPFile) fileToAdd; String filePath = fileBrowser.getAbsoluteWorkingDirectory() + File.separator + ftpFile.getName(); toAdd = new CustomFTPFile(ftpFile, filePath); } if (!checkIfInList(toAdd)) { selectedFiles.addDirectoryItem(toAdd); } } }); popup.add(addDirectory); popup.show(directoryTree, event.getX(), event.getY()); } } } } }); BasicTreeUI ui = new BasicTreeUI() { public Icon getCollapsedIcon() { return null; } public Icon getExpandedIcon() { return null; } }; directoryTree.setUI(ui); directoryTree.setFont(UIHelper.VER_12_PLAIN); JScrollPane treeScroll = new JScrollPane(directoryTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); treeScroll.setPreferredSize(new Dimension(300, 200)); treeScroll.setBorder(new EmptyBorder(0, 0, 0, 0)); treeContainer.add(treeScroll, BorderLayout.CENTER); IAppWidgetFactory.makeIAppScrollPane(treeScroll); return treeContainer; }
From source file:org.isatools.isacreator.gui.formelements.SubForm.java
private JPanel setupOptionsPanel() { options = new JPanel(); options.setLayout(new BoxLayout(options, BoxLayout.LINE_AXIS)); options.setOpaque(false);//from w ww. j a v a2s. co m String addRecordString = fieldType == FieldTypes.ASSAY && dataEntryForm != null ? "create assay" : "add a new " + fieldType + " column"; final JLabel addRecord = new JLabel(addRecordString, addRecordIcon, JLabel.LEFT); String toolTipText; if (fieldType == FieldTypes.ASSAY) { toolTipText = "<html><b>Create a new Assay</b>" + " <p>Complete the details for the assay in the fields provided</p>" + " <p>and click this button to add the assay to this study...</p>" + "</html>"; } else { toolTipText = "<html><b>Add a new " + fieldType + "</b>" + " <p>Click here to add a new column to enter an additional " + fieldType + "</p>" + "</html>"; } addRecord.setToolTipText(toolTipText); Font fontToUse = fieldType == FieldTypes.ASSAY && dataEntryForm != null ? UIHelper.VER_12_BOLD : UIHelper.VER_12_PLAIN; UIHelper.renderComponent(addRecord, fontToUse, UIHelper.DARK_GREEN_COLOR, false); addRecord.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { addRecord.setIcon(addRecordIcon); if (addColumn()) { updateTables(); } } @Override public void mouseEntered(MouseEvent mouseEvent) { addRecord.setIcon(addRecordIconOver); } @Override public void mouseExited(MouseEvent mouseEvent) { addRecord.setIcon(addRecordIcon); } }); options.add(addRecord); options.add(Box.createHorizontalStrut(10)); removeRecord = new JLabel("Remove " + fieldType + "...", removeIcon, JLabel.LEFT); removeRecord.setVisible(false); UIHelper.renderComponent(removeRecord, UIHelper.VER_12_PLAIN, UIHelper.DARK_GREEN_COLOR, false); removeRecord.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { if (removeRecord.getIcon() != null) { removeRecord.setIcon(removeIcon); } removalConfirmation(fieldType); } @Override public void mouseExited(MouseEvent mouseEvent) { if (removeRecord.getIcon() != null) { removeRecord.setIcon(removeIcon); } } @Override public void mouseEntered(MouseEvent mouseEvent) { if (removeRecord.getIcon() != null) { removeRecord.setIcon(removeIconOver); } } }); if (!showRemoveOption) { removeRecord.setIcon(null); removeRecord.setText(""); } options.add(removeRecord); options.add(Box.createHorizontalStrut(10)); createCustomOptions(); options.add(Box.createGlue()); return options; }