/** Inicializace základních komponent okna */ private void init() { krokLabel = new JLabel("Synchronizace s web aplikací"); Font pismo = new Font("Arial", Font.BOLD, 14); krokLabel.setFont(pismo); NacitaciOkno.add(krokLabel); krokLabel.setBounds(90, 10, 250, 20); startButton = new JButton("Načíst"); startButton.setActionCommand("start"); startButton.setBounds(250, 110, 120, 25); startButton.addActionListener(new Start()); progressBar = new JProgressBar(0, 100); progressBar.setBounds(20, 60, 350, 25); progressBar.setValue(0); progressBar.setStringPainted(true); taskOutput = new JTextArea(5, 20); taskOutput.setMargin(new Insets(5, 5, 5, 5)); taskOutput.setEditable(false); NacitaciOkno.add(startButton); NacitaciOkno.add(progressBar); NacitaciOkno.setVisible(true); vybratButton = new JButton("Otevřít"); NacitaciOkno.add(vybratButton); vybratButton.setBounds(20, 110, 120, 25); vybratButton.addActionListener(new Zpet()); }
private void initGUI() { JPanel pCommand = new JPanel(); pResult = new JPanel(); nsSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, pCommand, pResult); pCommand.setLayout(new BorderLayout()); pResult.setLayout(new BorderLayout()); Font fFont = new Font("Dialog", Font.PLAIN, 12); txtCommand = new JTextArea(5, 40); txtCommand.setMargin(new Insets(5, 5, 5, 5)); txtCommand.addKeyListener(this); txtCommandScroll = new JScrollPane(txtCommand); txtResult = new JTextArea(20, 40); txtResult.setMargin(new Insets(5, 5, 5, 5)); txtResultScroll = new JScrollPane(txtResult); txtCommand.setFont(fFont); txtResult.setFont(new Font("Courier", Font.PLAIN, 12)); /* // button replaced by toolbar butExecute = new JButton("Execute"); butExecute.addActionListener(this); pCommand.add(butExecute, BorderLayout.EAST); */ pCommand.add(txtCommandScroll, BorderLayout.CENTER); gResult = new GridSwing(); gResultTable = new JTable(gResult); gScrollPane = new JScrollPane(gResultTable); // getContentPane().setLayout(new BorderLayout()); pResult.add(gScrollPane, BorderLayout.CENTER); // Set up the tree rootNode = new DefaultMutableTreeNode("Connection"); treeModel = new DefaultTreeModel(rootNode); tTree = new JTree(treeModel); tScrollPane = new JScrollPane(tTree); tScrollPane.setPreferredSize(new Dimension(120, 400)); tScrollPane.setMinimumSize(new Dimension(70, 100)); txtCommandScroll.setPreferredSize(new Dimension(360, 100)); txtCommandScroll.setMinimumSize(new Dimension(180, 100)); gScrollPane.setPreferredSize(new Dimension(460, 300)); ewSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tScrollPane, nsSplitPane); fMain.getContentPane().add(ewSplitPane, BorderLayout.CENTER); doLayout(); fMain.pack(); }
private void initComponent() { // Create the logger first, because the action listeners // need to refer to it. logger = new JTextArea(8, 50); logger.setMargin(new Insets(5, 5, 5, 5)); logger.setEditable(false); JScrollPane logScrollPane = new JScrollPane(logger); // Create a file chooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // Create the open button. We use the image from the JLF // Graphics Repository (but we extracted it from the jar). openButton = new JButton("Chose NetBeans ...", createImageIcon("images/open.gif")); openButton.addActionListener(GuiFriendlizerApp.this); // Create the save button. We use the image from the JLF // Graphics Repository (but we extracted it from the jar). patchButton = new JButton("Do Patch", createImageIcon("images/patch.gif")); patchButton.addActionListener(GuiFriendlizerApp.this); patchButton.setEnabled(false); // For layout purposes, put the buttons in a separate panel JPanel buttonPanel = new JPanel(); // use FlowLayout buttonPanel.add(openButton); buttonPanel.add(patchButton); // Add the buttons and the logger to this panel. add(buttonPanel, BorderLayout.PAGE_START); add(logScrollPane, BorderLayout.CENTER); }
static JPanel getPanel() { //Now layout the LogPanel. It will be added to the tabs in the main class. //Create the log first, because the action listeners //need to refer to it. logArea = new JTextArea(30,20); logArea.setMargin(new Insets(5, 5, 5, 5)); logArea.setEditable(false); JScrollPane logScrollPane = new JScrollPane(logArea); //Create a panel of the log and its label JPanel logPanel = new JPanel(); logPanel.setLayout(new BorderLayout()); logPanel.setBorder(BorderFactory.createTitledBorder(GT._("Log and Error Messages:"))); logPanel.add(logScrollPane); return logPanel; }
public FileChooserDemo() { super(new BorderLayout()); // Create the log first, because the action listeners // need to refer to it. log = new JTextArea(5, 20); log.setMargin(new Insets(5, 5, 5, 5)); log.setEditable(false); JScrollPane logScrollPane = new JScrollPane(log); // Create a file chooser fc = new JFileChooser(); // Uncomment one of the following lines to try a different // file selection mode. The first allows just directories // to be selected (and, at least in the Java look and feel, // shown). The second allows both files and directories // to be selected. If you leave these lines commented out, // then the default mode (FILES_ONLY) will be used. // // fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); // Create the open button. We use the image from the JLF // Graphics Repository (but we extracted it from the jar). openButton = new JButton("Open a File...", createImageIcon("images/Open16.gif")); openButton.addActionListener(this); // Create the save button. We use the image from the JLF // Graphics Repository (but we extracted it from the jar). saveButton = new JButton("Save a File...", createImageIcon("images/Save16.gif")); saveButton.addActionListener(this); // For layout purposes, put the buttons in a separate panel JPanel buttonPanel = new JPanel(); // use FlowLayout buttonPanel.add(openButton); buttonPanel.add(saveButton); // Add the buttons and the log to this panel. add(buttonPanel, BorderLayout.PAGE_START); add(logScrollPane, BorderLayout.CENTER); }
public Splitter() { super(new BorderLayout()); // Create the demo's UI. startButton = new JButton("Start"); startButton.setActionCommand("start"); startButton.addActionListener(this); startButton.setVisible(false); taskOutput = new JTextArea(30, 130); taskOutput.setMargin(new Insets(5, 5, 5, 5)); taskOutput.setEditable(false); JPanel panel = new JPanel(); panel.add(startButton); add(panel, BorderLayout.PAGE_START); add(new JScrollPane(taskOutput), BorderLayout.CENTER); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); startButton.doClick(); }
/** Metoda vytváří okno "Zálohování souborů" a jeho komponenty */ private void init() { oknoVytvorPdf = new JDialog(); oknoVytvorPdf.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); oknoVytvorPdf.setTitle("Zálohování souborů"); oknoVytvorPdf.setLocation(400, 350); oknoVytvorPdf.setSize(400, 200); oknoVytvorPdf.setLayout(null); krokLabel = new JLabel("Zálohuj vše na FTP"); Font pismo = new Font("Arial", Font.BOLD, 14); krokLabel.setFont(pismo); oknoVytvorPdf.add(krokLabel); krokLabel.setBounds(90, 10, 250, 20); startButton = new JButton("Start"); startButton.setActionCommand("start"); startButton.setBounds(250, 110, 120, 25); startButton.addActionListener(new Start()); progressBar = new JProgressBar(0, 100); progressBar.setBounds(20, 60, 350, 25); progressBar.setValue(0); progressBar.setStringPainted(true); taskOutput = new JTextArea(5, 20); taskOutput.setMargin(new Insets(5, 5, 5, 5)); taskOutput.setEditable(false); oknoVytvorPdf.add(startButton); oknoVytvorPdf.add(progressBar); vybratButton = new JButton("Zpět"); oknoVytvorPdf.add(vybratButton); vybratButton.setBounds(20, 110, 120, 25); vybratButton.addActionListener(new Zpet()); }
private void initializeComponents() { this.setTitle("Synchro - Kopierassistent"); this.setBounds(0, 0, 550, 600); this.setResizable(true); this.setLayout(null); this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); this.addWindowListener(this); mainPanel = new JPanel(); mainPanel.setBounds(0, 0, this.getWidth() - 20, 25); // fcPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); mainPanel.setLayout(null); btnBackup = new JButton("Backup"); btnBackup.setBounds(this.getWidth() / 2, 0, this.getWidth() / 2 - 20, mainPanel.getHeight()); btnBackup.addActionListener(this); mainPanel.add(btnBackup); this.add(mainPanel); fcPanel = new JPanel(); fcPanel.setBounds(10, 40, this.getWidth(), 260); // fcPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); fcPanel.setLayout(null); quellLabel = new JLabel("Bitte Quellverzeichnis auswählen"); quellLabel.setBounds(10, 5, 320, 20); fcPanel.add(quellLabel); quellListModel = new DefaultListModel<>(); quellJList = new JList<ListItem>(quellListModel); quellJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); quellJList.setLayoutOrientation(JList.VERTICAL); quellJList.addListSelectionListener(this); listBoxScroller = new JScrollPane(quellJList); listBoxScroller.setBounds(0, 30, 315, 100); fcPanel.add(listBoxScroller); btnQAuswahl = new JButton("Quellverz. hinzufügen"); btnQAuswahl.setBounds(320, 30, 200, 25); btnQAuswahl.addActionListener(this); fcPanel.add(btnQAuswahl); btnQEntfernen = new JButton("Quellverz. entfernen"); btnQEntfernen.setBounds(320, 60, 200, 25); btnQEntfernen.addActionListener(this); fcPanel.add(btnQEntfernen); zielLabel = new JLabel("Bitte Zielverzeichnis auswählen"); zielLabel.setBounds(10, 135, 320, 20); fcPanel.add(zielLabel); zielListModel = new DefaultListModel<>(); zielJList = new JList<ListItem>(zielListModel); zielJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); zielJList.setLayoutOrientation(JList.VERTICAL); zielJList.addListSelectionListener(this); listBoxScroller2 = new JScrollPane(zielJList); listBoxScroller2.setBounds(0, 160, 315, 100); fcPanel.add(listBoxScroller2); btnZAuswahl = new JButton("Zielverz. hinzufügen"); btnZAuswahl.setBounds(320, 160, 200, 25); btnZAuswahl.addActionListener(this); fcPanel.add(btnZAuswahl); btnZEntfernen = new JButton("Zielverz. entfernen"); btnZEntfernen.setBounds(320, 190, 200, 25); btnZEntfernen.addActionListener(this); fcPanel.add(btnZEntfernen); this.add(fcPanel); ButtonGroup bGrp = new ButtonGroup(); optionPanel = new JPanel(); optionPanel.setBounds(10, 300 + 10, this.getWidth() - 40, 90); optionPanel.setPreferredSize(new Dimension(this.getWidth() - 40, 90)); // optionPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); optionPanel.setLayout(new GridLayout(3, 1)); nUebSchr = new JRadioButton("Keine Dateien überschreiben"); nUebSchr.addItemListener(this); bGrp.add(nUebSchr); optionPanel.add(nUebSchr); ueSchr = new JRadioButton("Neuere Dateien überschreiben"); ueSchr.addItemListener(this); bGrp.add(ueSchr); optionPanel.add(ueSchr); aUeSchr = new JRadioButton("Alle Dateien überschreiben"); aUeSchr.addItemListener(this); bGrp.add(aUeSchr); optionPanel.add(aUeSchr); this.add(optionPanel); syncPanel = new JPanel(); syncPanel.setBounds( 10, optionPanel.getY() + optionPanel.getHeight() + 10, this.getWidth() - 30, 25); // syncPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); syncPanel.setLayout(new BorderLayout()); btnSync = new JButton("Sync it!"); btnSync.setBounds(0, 0, 150, (syncPanel.getHeight() / 3)); btnSync.addActionListener(this); btnSync.setPreferredSize(new Dimension(150, (syncPanel.getHeight() / 3))); btnSync.setMaximumSize(new Dimension(150, (syncPanel.getHeight() / 3))); syncPanel.add(btnSync, BorderLayout.LINE_START); btnAbbruch = new JButton("Abbrechen"); btnAbbruch.setBounds(0, 0, 150, (syncPanel.getHeight() / 3)); btnAbbruch.addActionListener(this); btnAbbruch.setPreferredSize(new Dimension(150, (syncPanel.getHeight() / 3))); btnAbbruch.setMaximumSize(new Dimension(150, (syncPanel.getHeight() / 3))); btnAbbruch.setVisible(false); syncPanel.add(btnAbbruch, BorderLayout.LINE_END); progressBar = new JProgressBar(JProgressBar.HORIZONTAL); progressBar.setBorderPainted(true); progressBar.setPreferredSize(new Dimension(300, (syncPanel.getHeight() / 3))); progressBar.setForeground(Color.RED); progressBar.setStringPainted(true); progressBar.setVisible(true); syncPanel.add(progressBar, BorderLayout.CENTER); this.add(syncPanel); logPanel = new JPanel(); logPanel.setBounds( 10, syncPanel.getY() + syncPanel.getHeight() + 10, this.getWidth() - 30, 105); logPanel.setLayout(new BorderLayout()); textArea = new JTextArea(); textArea.setMargin(new Insets(3, 3, 3, 3)); textArea.setBackground(Color.black); textArea.setForeground(Color.LIGHT_GRAY); textArea.setAutoscrolls(true); textArea.setFocusable(false); textAreaScroller = new JScrollPane(textArea); DefaultCaret caret = (DefaultCaret) textArea.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); textAreaScroller.setBounds(0, 0, syncPanel.getWidth(), 50); logPanel.add(textAreaScroller, BorderLayout.CENTER); this.add(logPanel, BorderLayout.SOUTH); }
public void setInputPanel() throws IOException { final String newline = "\n"; final JTextArea log = new JTextArea(2, 28); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); input.setLayout(gridbag); // Create the log first, because the action listeners // need to refer to it. log.setMargin(new Insets(1, 1, 1, 1)); log.setEditable(false); JScrollPane logScrollPane = new JScrollPane(log); // Create a file chooser final JFileChooser fc = new JFileChooser(); // Create the open button ImageIcon openIcon = new ImageIcon("Images/open.gif"); JButton openButton = new JButton("Open a File...", openIcon); openButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int returnVal = fc.showOpenDialog(prologApplet.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); String name = file.getName(); String path = file.getAbsolutePath(); try { FileInputStream inps = new FileInputStream(path); ch = 0; ss = ""; while (ch != -1) { ch = inps.read(); ss = ss + (char) ch; } inps.close(); } catch (Exception exc) { System.out.println("" + e); } code.selectAll(); code.cut(); code.append(ss); log.append("Opening: " + name + "." + newline); } else { log.append("Open command cancelled by user." + newline); } } }); // Create the save button ImageIcon saveIcon = new ImageIcon("Images/save.gif"); JButton saveButton = new JButton("Save a File...", saveIcon); saveButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int returnVal = fc.showSaveDialog(prologApplet.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); // this is where a real application would save the file. log.append("Saving: " + file.getName() + "." + newline); } else { log.append("Save command cancelled by user." + newline); } } }); // For layout purposes, put the buttons in a separate panel JPanel buttonPanel = new JPanel(); buttonPanel.add(openButton); buttonPanel.add(saveButton); // Explicitly set the focus sequence. // rimossi poichè deprecati // openButton.setNextFocusableComponent(saveButton); // saveButton.setNextFocusableComponent(openButton); // Add the buttons and the log to the frame // Container contentPane = getContentPane(); // contentPane.add(buttonPanel, BorderLayout.NORTH); // contentPane.add(logScrollPane, BorderLayout.CENTER); c.gridx = 0; c.gridy = 0; c.gridwidth = 3; c.fill = GridBagConstraints.NONE; gridbag.setConstraints(buttonPanel, c); input.add(buttonPanel); c.gridx = 0; c.gridy = 1; c.gridwidth = 3; c.fill = GridBagConstraints.NONE; gridbag.setConstraints(logScrollPane, c); input.add(logScrollPane); JLabel label1 = new JLabel("Codice:"); c.gridx = 0; c.gridy = 2; c.gridwidth = 3; c.fill = GridBagConstraints.NONE; gridbag.setConstraints(label1, c); input.add(label1); c.gridx = 0; c.gridy = 3; c.gridwidth = 3; c.fill = GridBagConstraints.HORIZONTAL; gridbag.setConstraints(scrollPaneC, c); input.add(scrollPaneC); JLabel label2 = new JLabel("GOAL clause:"); c.gridx = 0; c.gridy = 4; // c.weightx=1; c.gridwidth = 3; c.fill = GridBagConstraints.NONE; gridbag.setConstraints(label2, c); input.add(label2); c.gridx = 0; c.gridy = 5; c.gridwidth = 3; c.fill = GridBagConstraints.HORIZONTAL; gridbag.setConstraints(gl, c); input.add(gl); c.gridx = 0; c.gridy = 6; c.weightx = 0.3; c.gridwidth = 1; gridbag.setConstraints(compile, c); input.add(compile); compile.addActionListener(this); c.gridx = 1; c.gridy = 6; c.weightx = 0.3; c.gridwidth = 1; gridbag.setConstraints(compileG, c); input.add(compileG); compileG.addActionListener(this); c.gridx = 2; c.gridy = 6; c.weightx = 0.3; c.gridwidth = 1; gridbag.setConstraints(run, c); input.add(run); run.addActionListener(this); Color c1 = new Color(166, 209, 241); code.setBackground(c1); code.setAutoscrolls(true); code.setEditable(true); /* mb1 input.add(load); input.add(scrollPaneC); input.add(gl); */ input.setBorder(BorderFactory.createEtchedBorder()); }
public fileBackupProgram(JFrame frame) { super(new BorderLayout()); this.frame = frame; errorDialog = new CustomDialog(frame, "Please enter a new name for the error log", this); errorDialog.pack(); moveDialog = new CustomDialog(frame, "Please enter a new name for the move log", this); moveDialog.pack(); printer = new FilePrinter(); timers = new ArrayList<>(); log = new JTextArea(5, 20); log.setMargin(new Insets(5, 5, 5, 5)); log.setEditable(false); JScrollPane logScrollPane = new JScrollPane(log); Object obj; copy = true; listModel = new DefaultListModel(); // destListModel = new DefaultListModel(); directoryList = new directoryStorage(); // Create a file chooser fc = new JFileChooser(); // Create the menu bar. menuBar = new JMenuBar(); // Build the first menu. menu = new JMenu("File"); menu.getAccessibleContext() .setAccessibleDescription("The only menu in this program that has menu items"); menuBar.add(menu); editError = new JMenuItem("Save Error Log As..."); editError .getAccessibleContext() .setAccessibleDescription("Change the name of the error log file"); editError.addActionListener(new ErrorListener()); menu.add(editError); editMove = new JMenuItem("Save Move Log As..."); editMove .getAccessibleContext() .setAccessibleDescription("Change the name of the move log file"); editMove.addActionListener(new MoveListener()); menu.add(editMove); exit = new JMenuItem("Exit"); exit.getAccessibleContext().setAccessibleDescription("Exit the Program"); exit.addActionListener(new CloseListener()); menu.add(exit); frame.setJMenuBar(menuBar); // Uncomment one of the following lines to try a different // file selection mode. The first allows just directories // to be selected (and, at least in the Java look and feel, // shown). The second allows both files and directories // to be selected. If you leave these lines commented out, // then the default mode (FILES_ONLY) will be used. // fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); openButton = new JButton(openString); openButton.setActionCommand(openString); openButton.addActionListener(new OpenListener()); destButton = new JButton(destString); destButton.setActionCommand(destString); destButton.addActionListener(new DestListener()); // Create the save button. We use the image from the JLF // Graphics Repository (but we extracted it from the jar). saveButton = new JButton(saveString); saveButton.setActionCommand(saveString); saveButton.addActionListener(new SaveListener()); URL imageURL = getClass().getResource(greenButtonIcon); ImageIcon greenSquare = new ImageIcon(imageURL); startButton = new JButton("Start", greenSquare); startButton.setSize(60, 20); startButton.setHorizontalTextPosition(AbstractButton.LEADING); startButton.setActionCommand("Start"); startButton.addActionListener(new StartListener()); imageURL = getClass().getResource(redButtonIcon); ImageIcon redSquare = new ImageIcon(imageURL); stopButton = new JButton("Stop", redSquare); stopButton.setSize(60, 20); stopButton.setHorizontalTextPosition(AbstractButton.LEADING); stopButton.setActionCommand("Stop"); stopButton.addActionListener(new StopListener()); copyButton = new JRadioButton("Copy"); copyButton.setActionCommand("Copy"); copyButton.setSelected(true); copyButton.addActionListener(new RadioListener()); moveButton = new JRadioButton("Move"); moveButton.setActionCommand("Move"); moveButton.addActionListener(new RadioListener()); ButtonGroup group = new ButtonGroup(); group.add(copyButton); group.add(moveButton); // For layout purposes, put the buttons in a separate panel JPanel optionPanel = new JPanel(); GroupLayout layout = new GroupLayout(optionPanel); optionPanel.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); layout.setHorizontalGroup( layout.createSequentialGroup().addComponent(copyButton).addComponent(moveButton)); layout.setVerticalGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(copyButton) .addComponent(moveButton))); JPanel buttonPanel = new JPanel(); // use FlowLayout layout = new GroupLayout(buttonPanel); buttonPanel.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); layout.setHorizontalGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(openButton) .addComponent(optionPanel)) .addComponent(destButton) .addComponent(startButton) .addComponent(stopButton) // .addComponent(saveButton) ); layout.setVerticalGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(openButton) .addComponent(destButton) .addComponent(startButton) .addComponent(stopButton) // .addComponent(saveButton) ) .addComponent(optionPanel)); buttonPanel.add(optionPanel); /* buttonPanel.add(openButton); buttonPanel.add(destButton); buttonPanel.add(startButton); buttonPanel.add(stopButton); buttonPanel.add(saveButton); buttonPanel.add(listLabel); buttonPanel.add(copyButton); buttonPanel.add(moveButton); */ destButton.setEnabled(false); startButton.setEnabled(false); stopButton.setEnabled(false); // Add the buttons and the log to this panel. // add(logScrollPane, BorderLayout.CENTER); JLabel listLabel = new JLabel("Monitored Directory:"); listLabel.setLabelFor(list); // Create the list and put it in a scroll pane. list = new JList(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0); list.addListSelectionListener(this); list.setVisibleRowCount(8); JScrollPane listScrollPane = new JScrollPane(list); JPanel listPane = new JPanel(); listPane.setLayout(new BorderLayout()); listPane.add(listLabel, BorderLayout.PAGE_START); listPane.add(listScrollPane, BorderLayout.CENTER); listSelectionModel = list.getSelectionModel(); listSelectionModel.addListSelectionListener(new SharedListSelectionHandler()); // monitored, destination, waitInt, check destination = new JLabel("Destination Directory: "); waitField = new JFormattedTextField(); // waitField.setValue(240); waitField.setEditable(false); waitField.addPropertyChangeListener(new FormattedTextListener()); waitInt = new JLabel("Wait Interval (in minutes)"); // waitInt.setLabelFor(waitField); checkField = new JFormattedTextField(); checkField.setSize(1, 10); // checkField.setValue(60); checkField.setEditable(false); checkField.addPropertyChangeListener(new FormattedTextListener()); check = new JLabel("Check Interval (in minutes)"); // check.setLabelFor(checkField); fireButton = new JButton(fireString); fireButton.setActionCommand(fireString); fireButton.addActionListener(new FireListener()); JPanel fieldPane = new JPanel(); // fieldPane.add(destField); layout = new GroupLayout(fieldPane); fieldPane.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); layout.setHorizontalGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(waitInt) .addComponent(check)) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(waitField, 60, 60, 60) .addComponent(checkField, 60, 60, 60))); layout.setVerticalGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(waitInt) .addComponent(waitField)) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(check) .addComponent(checkField))); JPanel labelPane = new JPanel(); labelPane.setLayout(new BorderLayout()); labelPane.add(destination, BorderLayout.PAGE_START); labelPane.add(fieldPane, BorderLayout.CENTER); layout = new GroupLayout(labelPane); labelPane.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); layout.setHorizontalGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(destination) .addComponent(fieldPane))); layout.setVerticalGroup( layout.createSequentialGroup().addComponent(destination).addComponent(fieldPane)); // labelPane.add(destination); // labelPane.add(fieldPane); try { // Read from disk using FileInputStream FileInputStream f_in = new FileInputStream(LOG_DIRECTORY + "\\save.data"); // Read object using ObjectInputStream ObjectInputStream obj_in = new ObjectInputStream(f_in); // Read an object directoryList = (directoryStorage) obj_in.readObject(); ERROR_LOG_NAME = (String) obj_in.readObject(); MOVE_LOG_NAME = (String) obj_in.readObject(); if (ERROR_LOG_NAME instanceof String) { printer.changeErrorLogName(ERROR_LOG_NAME); } if (MOVE_LOG_NAME instanceof String) { printer.changeMoveLogName(MOVE_LOG_NAME); } if (directoryList instanceof directoryStorage) { System.out.println("found object"); // directoryList = (directoryStorage) obj; Iterator<Directory> directories = directoryList.getDirectories(); Directory d; while (directories.hasNext()) { d = directories.next(); try { listModel.addElement(d.getDirectory().toRealPath()); } catch (IOException x) { printer.printError(x.toString()); } int index = list.getSelectedIndex(); if (index == -1) { list.setSelectedIndex(0); } index = list.getSelectedIndex(); Directory dir = directoryList.getDirectory(index); destButton.setEnabled(true); checkField.setValue(dir.getInterval()); waitField.setValue(dir.getWaitInterval()); checkField.setEditable(true); waitField.setEditable(true); // directoryList.addNewDirectory(d); // try { // listModel.addElement(d.getDirectory().toString()); // } catch (IOException x) { // printer.printError(x.toString()); // } // timer = new Timer(); // timer.schedule(new CopyTask(d.directory, d.destination, d.getWaitInterval(), printer, // d.copy), 0, d.getInterval()); } } else { System.out.println("did not find object"); } obj_in.close(); } catch (ClassNotFoundException x) { printer.printError(x.getLocalizedMessage()); System.err.format("Unable to read"); } catch (IOException y) { printer.printError(y.getLocalizedMessage()); } // Layout the text fields in a panel. JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); buttonPane.add(fireButton); buttonPane.add(Box.createHorizontalStrut(5)); buttonPane.add(new JSeparator(SwingConstants.VERTICAL)); buttonPane.add(Box.createHorizontalStrut(5)); buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(buttonPanel, BorderLayout.PAGE_START); add(listPane, BorderLayout.LINE_START); // add(destListScrollPane, BorderLayout.CENTER); add(fieldPane, BorderLayout.LINE_END); add(labelPane, BorderLayout.CENTER); add(buttonPane, BorderLayout.PAGE_END); }
public ProcessFrame(Properties theProperties) { super(new BorderLayout()); // myFile = theFile; myProperties = theProperties; Properties props = System.getProperties(); props.put("http.proxyHost", myProperties.getProperty("PROXYHOST")); props.put("http.proxyPort", myProperties.getProperty("PROXYPORT")); // Create the demo's UI. StartButton = new JButton("Start"); StartButton.setActionCommand("start"); StartButton.addActionListener(this); cancelButton = new JButton("Cancel"); cancelButton.setActionCommand("cancel"); cancelButton.addActionListener(this); cancelButton.setEnabled(false); myDownloadOptions = new JComboBox(myDownloadOptionsStr); progressBar = new JProgressBar(0, 100); progressBar.setValue(0); progressBar.setStringPainted(true); progressBar2 = new JProgressBar(0, 100); progressBar2.setValue(0); progressBar2.setStringPainted(true); progressBar3 = new JProgressBar(0, 100); progressBar4 = new JProgressBar(0, 100); progressBar5 = new JProgressBar(0, 100); progressBar3.setValue(0); progressBar3.setStringPainted(true); progressBar4.setValue(0); progressBar4.setStringPainted(true); progressBar5.setValue(0); progressBar5.setStringPainted(true); taskOutput = new JTextArea(5, 20); final JPopupMenu taskPopupMenu = new JPopupMenu(); JMenuItem clearMenuItem = new JMenuItem("Clear"); clearMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { if (actionEvent.getActionCommand().equals("Clear")) { taskOutput.setText(""); } } }); taskPopupMenu.add(clearMenuItem); taskOutput.setMargin(new Insets(5, 5, 5, 5)); taskOutput.setEditable(false); taskOutput.addMouseListener( new MouseAdapter() { private void showIfPopupTrigger(MouseEvent mouseEvent) { if (mouseEvent.isPopupTrigger()) { taskPopupMenu.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY()); } } public void mousePressed(MouseEvent mouseEvent) { showIfPopupTrigger(mouseEvent); } public void mouseReleased(MouseEvent mouseEvent) { showIfPopupTrigger(mouseEvent); } }); JPanel panel = new JPanel(); JPanel panel2 = new JPanel(); panel.setLayout(new GridBagLayout()); panel2.setLayout(new GridBagLayout()); panel.add( progressBar4, new GridBagConstraints( 2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(11, 11, 0, 0), 0, 0)); panel.add( new JLabel("TOTAL"), new GridBagConstraints( 1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 11, 0, 0), 0, 0)); panel.add( progressBar, new GridBagConstraints( 2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(11, 11, 0, 0), 0, 0)); panel.add( new JLabel("REMOTE DOWNLOAD"), new GridBagConstraints( 1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 11, 0, 0), 0, 0)); panel.add( progressBar2, new GridBagConstraints( 2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(11, 11, 0, 0), 0, 0)); panel.add( new JLabel("REMOTE SPLIT"), new GridBagConstraints( 1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 11, 0, 0), 0, 0)); panel.add( progressBar3, new GridBagConstraints( 2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(11, 11, 0, 0), 0, 0)); panel.add( new JLabel("LOCAL DOWNLOAD"), new GridBagConstraints( 1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 11, 0, 0), 0, 0)); panel.add( progressBar5, new GridBagConstraints( 2, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(11, 11, 0, 0), 0, 0)); panel.add( new JLabel("LOCAL JOIN"), new GridBagConstraints( 1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 11, 0, 0), 0, 0)); panel2.add( myDownloadOptions, new GridBagConstraints( 1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(4, 13, 4, 0), 0, 0)); panel2.add( StartButton, new GridBagConstraints( 2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(4, 13, 4, 0), 0, 0)); panel2.add( cancelButton, new GridBagConstraints( 3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(4, 13, 4, 0), 0, 0)); add(panel, BorderLayout.PAGE_START); add(panel2, BorderLayout.CENTER); add(new JScrollPane(taskOutput), BorderLayout.PAGE_END); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }