List of usage examples for javax.swing BorderFactory createLineBorder
public static Border createLineBorder(Color color, int thickness)
From source file:com.uniteddev.Unity.Login.java
public static void setup() throws IOException, InterruptedException, FontFormatException { //fonts//from w w w.j a v a 2s . c o m roboto_thin = Font.createFont(Font.TRUETYPE_FONT, Unity.class.getResourceAsStream("/res/Roboto-Thin.ttf")); roboto_regular = Font.createFont(Font.TRUETYPE_FONT, Unity.class.getResourceAsStream("/res/Roboto-Regular.ttf")); // main window = new Window(Unity.title, Unity.favicon, Unity.background, 791, 527); release = new Label(Unity.release, Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 12)); server_lbl = new Label("Server:", Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 12)); server_stat_lbl = new Label("Offline", Color.RED, roboto_regular.deriveFont(Font.PLAIN, 12)); settingsButton = new Button(); settingsButton.setImage("/res/gear.png"); settingsButton.removeDecorations(); settingsButton.addActionListener(new settingsButton_action()); // splash screen update_lbl = new Label("Updating", Color.WHITE, roboto_thin.deriveFont(Font.PLAIN, 32)); progress = new ProgressBar(new Color(255, 255, 255, 100), new Color(255, 255, 255, 255)); progress.removeDecorations(); progressText = new Label("Ready.", Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14)); // login screen username = new TextField(prefs.get("username", ""), Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14)); password = new PasswordField(Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14)); username_lbl = new Label("Username:", Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14)); password_lbl = new Label("Password:", Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14)); loginButton = new Button("Login", Color.WHITE, roboto_thin.deriveFont(Font.PLAIN, 28)); loginButton.setBorder(BorderFactory.createLineBorder(Color.WHITE, 1)); loginButton.center(); loginButton.addActionListener(new loginButton_action()); invalid_login_lbl = new Label("Invalid Login", Color.RED, roboto_regular.deriveFont(Font.PLAIN, 14)); invalid_login_lbl.setVisible(false); // settings screen settings_lbl = new Label("Settings", Color.WHITE, roboto_thin.deriveFont(Font.PLAIN, 32)); deleteButton = new Button(); deleteButton.setImage("/res/recycle.png"); deleteButton.removeDecorations(); deleteButton.addActionListener(new deleteButton_action()); ram_size = new TextField(prefs.get("ram_size", default_ram), Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14)); ram_lbl = new Label("RAM Usage (MB):", Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14)); invalid_ram_lbl = new Label(Color.RED, roboto_regular.deriveFont(Font.PLAIN, 14)); invalid_ram_lbl.setVisible(false); saveButton = new Button("Save", Color.WHITE, roboto_thin.deriveFont(Font.PLAIN, 28)); saveButton.setBorder(BorderFactory.createLineBorder(Color.WHITE, 1)); saveButton.center(); saveButton.addActionListener(new saveButton_action()); // sizing and layout release.setBounds(5, window.getHeight() - 50, 140, 20); server_lbl.setBounds(5, window.getHeight() - 50, 140, 20); server_stat_lbl.setBounds(45, window.getHeight() - 50, 200, 20); update_lbl.setBounds(115, 20, 320, 50); progress.setBounds(20, 75, 320, 10); progressText.setBounds(20, 90, 320, 20); username.setBounds(155, 30, 115, 20); password.setBounds(155, 60, 115, 20); username_lbl.setBounds(80, 30, 115, 20); password_lbl.setBounds(79, 60, 115, 20); loginButton.setBounds(110, 110, 140, 40); invalid_login_lbl.setBounds(135, 165, 140, 20); settingsButton.setBounds(window.getWidth() - 45, window.getHeight() - 65, 32, 32); settings_lbl.setBounds(115, 5, 320, 50); deleteButton.setBounds(155, 50, 32, 32); ram_size.setBounds(175, 90, 115, 20); ram_lbl.setBounds(60, 90, 115, 20); saveButton.setBounds(110, 125, 140, 40); // setup screens login_window = new Label(); login_window.setBounds(216, 180, 360, 200); login_window.add(update_lbl); login_window.add(progress); login_window.add(progressText); login_window.add(username); login_window.add(password); login_window.add(username_lbl); login_window.add(password_lbl); login_window.add(loginButton); login_window.add(invalid_login_lbl); login_window.add(settings_lbl); login_window.add(deleteButton); login_window.add(ram_size); login_window.add(invalid_ram_lbl); login_window.add(ram_lbl); login_window.add(saveButton); // setup and show window window.addComponent(release); window.addComponent(server_lbl); window.addComponent(server_stat_lbl); window.addComponent(login_window); window.addComponent(settingsButton); window.getRootPane().setDefaultButton(loginButton); window.setLocationRelativeTo(null); release.setVisible(false); window.setVisible(true); start(); }
From source file:Proiect.uploadFTP.java
public uploadFTP() { uploadFTP.setIconImage(/*w w w . jav a 2s . com*/ Toolkit.getDefaultToolkit().getImage(getClass().getClassLoader().getResource("assets/ico.png"))); uploadFTP.setUndecorated(true); uploadFTP.getRootPane().setBorder(BorderFactory.createLineBorder(Encrypter.color_black, 2)); uploadFTP.setSize(400, 240); uploadFTP.setLocationRelativeTo(Encrypter.Center); uploadFTP.setResizable(false); uploadFTP.setVisible(true); cm.registerComponent(uploadFTP); uploadFTP.setLayout(new BorderLayout()); pan1.setLayout(new BorderLayout()); pan2.setLayout(new BorderLayout()); inpan1.setLayout(new GridLayout(6, 2, 0, 10)); inpan2.setLayout(new GridLayout(1, 2, 20, 0)); pan3.setLayout(new BorderLayout()); pan4.setLayout(new FlowLayout()); uploadFTP.add(pan3, BorderLayout.EAST); pan3.add(adv, BorderLayout.SOUTH); uploadFTP.add(pan1, BorderLayout.NORTH); pan1.add(titleFTP, BorderLayout.WEST); pan1.add(exit, BorderLayout.EAST); uploadFTP.add(pan2, BorderLayout.CENTER); pan2.add(inpan1, BorderLayout.NORTH); inpan1.add(adress); inpan1.add(adressf); inpan1.add(user); inpan1.add(userf); inpan1.add(pass); inpan1.add(passf); inpan1.add(folder); inpan1.add(folderf); inpan1.add(filen); inpan1.add(filenf); inpan1.add(status); pan2.add(inpan2, BorderLayout.SOUTH); inpan2.add(browsef); inpan2.add(connect); uploadFTP.add(pan4, BorderLayout.WEST); propFTP(); actionFTP(); /* BOF Load state */ try { FileInputStream fileStream = new FileInputStream( ClassLoader.getSystemResource("upload.prop").getPath()); ObjectInputStream os = new ObjectInputStream(fileStream); adressf.setText(os.readObject().toString()); userf.setText(os.readObject().toString()); passf.setText(os.readObject().toString()); os.close(); fileStream.close(); } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } catch (ClassNotFoundException e1) { e1.printStackTrace(); } /* EOF Load state */ }
From source file:CubaHSQLDBServer.java
private CubaHSQLDBServer() { Font monospaced = Font.decode("monospaced"); statusArea = new JTextArea(2, 80); statusArea.setFont(monospaced);/*from w w w .j a va 2 s.c o m*/ statusArea.setMargin(new Insets(5, 5, 5, 5)); exceptionArea = new JTextArea(26, 80); exceptionArea.setFont(monospaced); exceptionArea.setMargin(new Insets(5, 5, 5, 5)); JPanel exceptionWrapperContainer = new JPanel(); exceptionWrapperContainer.setLayout(new BorderLayout(0, 0)); exceptionWrapperContainer.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); exceptionWrapperContainer.add(exceptionArea); JPanel statusWrapperContainer = new JPanel(); statusWrapperContainer.setLayout(new BorderLayout(0, 0)); statusWrapperContainer.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); statusWrapperContainer.add(statusArea); addCopyPopup(statusArea); addCopyPopup(exceptionArea); exceptionBox = new JPanel(); LayoutBuilder.create(exceptionBox, BoxLayout.Y_AXIS).addSpace(5).addComponent(exceptionWrapperContainer); LayoutBuilder.create(this.getContentPane(), BoxLayout.X_AXIS).addSpace(5).addContainer(BoxLayout.Y_AXIS) .addSpace(5).addComponent(statusWrapperContainer).addComponent(exceptionBox).addSpace(5) .returnToParent().addSpace(5); statusArea.setEditable(false); exceptionArea.setEditable(false); exceptionBox.setVisible(false); exceptionArea.setBackground(new Color(255, 255, 212)); this.pack(); this.setResizable(true); this.setTitle("HSQLDB Server"); try { this.setIconImage(ImageIO.read(getClass().getResourceAsStream("/icons/database.png"))); } catch (IOException e) { throw new IllegalStateException("Unable to find icon for HSQLDB window"); } }
From source file:org.interreg.docexplore.management.manage.ManageComponent.java
@SuppressWarnings("serial") public ManageComponent(MainWindow win, final ManageHandler handler, boolean editable, boolean showPages) { super(new BorderLayout()); this.win = win; this.handler = handler; this.bookList = new JList(new CollectionNode(this)); setBorder(BorderFactory.createLineBorder(Color.black, 1)); bookList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); bookList.setCellRenderer(new ManageCellRenderer()); //tree.setRowHeight(52); add(new JScrollPane(bookList), BorderLayout.CENTER); if (editable) { bookList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { int index = bookList.locationToIndex(e.getPoint()); if (index < 0 || !bookList.getCellBounds(index, index).contains(e.getPoint())) return; handler.bookOpened((Book) bookList.getModel().getElementAt(index)); }//from w w w . ja v a 2 s.com } }); this.toolbar = new ManageToolbar(this); add(toolbar, BorderLayout.NORTH); bookList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; int count = bookList.getSelectedIndices().length; toolbar.deleteButton.setEnabled(count > 0); toolbar.editButton.setEnabled(count == 1); // toolbar.processButton.setEnabled(count == 1); toolbar.exportButton.setEnabled(count == 1); } }); } bookList.setBackground(new JPanel().getBackground()); getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "DEL"); getActionMap().put("DEL", new AbstractAction() { public void actionPerformed(ActionEvent arg0) { @SuppressWarnings({ "unchecked", "rawtypes" }) Vector<Book> books = new Vector(Arrays.asList(bookList.getSelectedValues())); if (books.size() > 0 && handler.booksDeleted(books)) { ((CollectionNode) bookList.getModel()).reload(); bookList.clearSelection(); bookList.repaint(); } } }); }
From source file:edu.ku.brc.af.ui.db.ViewBasedDisplayFrame.java
@Override public void createUI() { setBackground(viewBasedPanel.getBackground()); JScrollPane scrollPane = UIHelper.createScrollPane(viewBasedPanel, true); scrollPane.setBorder(BorderFactory.createLineBorder(getBackground(), 8)); contentPanel = scrollPane;//from w ww . j a va 2s.c o m super.createUI(); viewBasedPanel.setOkCancelBtns(okBtn, cancelBtn); Integer width = (Integer) UIManager.get("ScrollBar.width"); if (width == null) { width = (new JScrollBar()).getPreferredSize().width; } Dimension dim1 = getPreferredSize(); dim1.height += width * 2; if (!UIHelper.isMacOS()) { dim1.width += width; } setSize(dim1); if (cancelBtn != null) { addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { cancelBtn.doClick(); } }); } else if (okBtn != null) { okBtn.setEnabled(true); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { okBtn.doClick(); } }); } viewBasedPanel.setOkCancelBtns(okBtn, cancelBtn); addAL(okBtn); addAL(cancelBtn); addAL(applyBtn); addAL(helpBtn); }
From source file:com.okmich.hackerday.client.tool.dashboard.ReportItemPanel.java
public void onMouseClick() { setBorder(BorderFactory.createLineBorder(Color.RED, 1)); }
From source file:components.SpinnerDemo3.java
public SpinnerDemo3(boolean cycleMonths) { super(new SpringLayout()); String[] labels = { "Month: ", "Year: ", "Another Date: " }; int numPairs = labels.length; calendar = Calendar.getInstance(); JFormattedTextField ftf = null; //Add the first label-spinner pair. String[] monthStrings = getMonthStrings(); //get month names SpinnerListModel monthModel = null; if (cycleMonths) { //use custom model monthModel = new CyclingSpinnerListModel(monthStrings); } else { //use standard model monthModel = new SpinnerListModel(monthStrings); }//from w w w . j av a2s . com JSpinner spinner = addLabeledSpinner(this, labels[0], monthModel); //Tweak the spinner's formatted text field. ftf = getTextField(spinner); if (ftf != null) { ftf.setColumns(8); //specify more width than we need ftf.setHorizontalAlignment(JTextField.RIGHT); } //Add second label-spinner pair. int currentYear = calendar.get(Calendar.YEAR); SpinnerModel yearModel = new SpinnerNumberModel(currentYear, //initial value currentYear - 100, //min currentYear + 100, //max 1); //step //If we're cycling, hook this model up to the month model. if (monthModel instanceof CyclingSpinnerListModel) { ((CyclingSpinnerListModel) monthModel).setLinkedModel(yearModel); } spinner = addLabeledSpinner(this, labels[1], yearModel); //Make the year be formatted without a thousands separator. spinner.setEditor(new JSpinner.NumberEditor(spinner, "#")); //Add the third label-spinner pair. Date initDate = calendar.getTime(); calendar.add(Calendar.YEAR, -100); Date earliestDate = calendar.getTime(); calendar.add(Calendar.YEAR, 200); Date latestDate = calendar.getTime(); SpinnerDateModel dateModel = new SpinnerDateModel(initDate, earliestDate, latestDate, Calendar.YEAR);//ignored for user input dateSpinner = spinner = addLabeledSpinner(this, labels[2], dateModel); spinner.setEditor(new JSpinner.DateEditor(spinner, "MM/yyyy")); //Tweak the spinner's formatted text field. ftf = getTextField(spinner); if (ftf != null) { ftf.setHorizontalAlignment(JTextField.RIGHT); ftf.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 3)); } spinner.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); //XXX: No easy way to get to the buttons and change their border. setSeasonalColor(dateModel.getDate()); //initialize color //Listen for changes on the date spinner. dateSpinner.addChangeListener(this); //Lay out the panel. SpringUtilities.makeCompactGrid(this, numPairs, 2, //rows, cols 10, 10, //initX, initY 6, 10); //xPad, yPad }
From source file:ome.formats.importer.gui.FileQueueTable.java
/** * Set up and display the file queue table *//*from w w w.j a va 2s . c o m*/ FileQueueTable() { // ----- Variables ----- // Debug Borders Boolean debugBorders = false; // Size of the add/remove/refresh buttons (which are square). int buttonSize = 40; // Add graphic for the refresh button //String refreshIcon = "gfx/recycled.png"; // Add graphic for add button String addIcon = "gfx/add.png"; // Remove graphics for remove button String removeIcon = "gfx/remove.png"; // Width of the status columns int statusWidth = 100; // ----- GUI Layout Elements ----- // Start layout here setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); setBorder(BorderFactory.createEmptyBorder(6, 5, 9, 8)); JPanel buttonPanel = new JPanel(); if (debugBorders == true) buttonPanel.setBorder(BorderFactory.createLineBorder(Color.red, 1)); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.PAGE_AXIS)); // refreshBtn = addButton("+", refreshIcon, null); // refreshBtn.setMaximumSize(new Dimension(buttonSize, buttonSize)); // refreshBtn.setPreferredSize(new Dimension(buttonSize, buttonSize)); // refreshBtn.setMinimumSize(new Dimension(buttonSize, buttonSize)); // refreshBtn.setSize(new Dimension(buttonSize, buttonSize)); // refreshBtn.setActionCommand(Actions.REFRESH); // refreshBtn.addActionListener(this); addBtn = GuiCommonElements.addBasicButton(null, addIcon, null); addBtn.setMaximumSize(new Dimension(buttonSize, buttonSize)); addBtn.setPreferredSize(new Dimension(buttonSize, buttonSize)); addBtn.setMinimumSize(new Dimension(buttonSize, buttonSize)); addBtn.setSize(new Dimension(buttonSize, buttonSize)); addBtn.setActionCommand(FileQueueHandler.ADD); addBtn.addActionListener(this); addBtn.setToolTipText("Add files to the import queue."); removeBtn = GuiCommonElements.addBasicButton(null, removeIcon, null); removeBtn.setMaximumSize(new Dimension(buttonSize, buttonSize)); removeBtn.setPreferredSize(new Dimension(buttonSize, buttonSize)); removeBtn.setMinimumSize(new Dimension(buttonSize, buttonSize)); removeBtn.setSize(new Dimension(buttonSize, buttonSize)); removeBtn.setActionCommand(FileQueueHandler.REMOVE); removeBtn.addActionListener(this); removeBtn.setToolTipText("Remove files from the import queue."); buttonPanel.add(Box.createRigidArea(new Dimension(0, 60))); //buttonPanel.add(refreshBtn); buttonPanel.add(Box.createVerticalGlue()); buttonPanel.add(addBtn); buttonPanel.add(Box.createRigidArea(new Dimension(0, 5))); buttonPanel.add(removeBtn); buttonPanel.add(Box.createVerticalGlue()); buttonPanel.add(Box.createRigidArea(new Dimension(0, 60))); add(buttonPanel); add(Box.createRigidArea(new Dimension(5, 0))); JPanel queuePanel = new JPanel(); if (debugBorders == true) queuePanel.setBorder(BorderFactory.createLineBorder(Color.red, 1)); queuePanel.setLayout(new BoxLayout(queuePanel, BoxLayout.PAGE_AXIS)); //queuePanel.add(Box.createRigidArea(new Dimension(0,10))); JPanel labelPanel = new JPanel(); labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.LINE_AXIS)); JLabel label = new JLabel("Import Queue:"); labelPanel.add(label); labelPanel.add(Box.createHorizontalGlue()); groupBtn = GuiCommonElements.addBasicButton("Group: ", null, "Current Group"); groupBtn.setToolTipText("The user group you are logged into."); //groupBtn.setEnabled(false); labelPanel.add(groupBtn); queuePanel.add(labelPanel); queuePanel.add(Box.createRigidArea(new Dimension(0, 5))); TableColumnModel cModel = getQueue().getColumnModel(); headerCellRenderer = new MyTableHeaderRenderer(); fileCellRenderer = new LeftDotRenderer(); dpCellRenderer = new CenterTextRenderer(); statusCellRenderer = new CenterTextRenderer(); // Create a custom header for the table cModel.getColumn(0).setHeaderRenderer(headerCellRenderer); cModel.getColumn(1).setHeaderRenderer(headerCellRenderer); cModel.getColumn(2).setHeaderRenderer(headerCellRenderer); cModel.getColumn(0).setCellRenderer(fileCellRenderer); cModel.getColumn(1).setCellRenderer(dpCellRenderer); cModel.getColumn(2).setCellRenderer(statusCellRenderer); // Set the width of the status column TableColumn statusColumn = getQueue().getColumnModel().getColumn(2); statusColumn.setPreferredWidth(statusWidth); statusColumn.setMaxWidth(statusWidth); statusColumn.setMinWidth(statusWidth); SelectionListener listener = new SelectionListener(getQueue()); getQueue().getSelectionModel().addListSelectionListener(listener); //queue.getColumnModel().getSelectionModel() // .addListSelectionListener(listener); // Hide 3rd to 6th columns TableColumnModel tcm = getQueue().getColumnModel(); TableColumn projectColumn = tcm.getColumn(6); tcm.removeColumn(projectColumn); TableColumn userPixelColumn = tcm.getColumn(6); tcm.removeColumn(userPixelColumn); TableColumn userSpecifiedNameColumn = tcm.getColumn(6); tcm.removeColumn(userSpecifiedNameColumn); TableColumn datasetColumn = tcm.getColumn(3); tcm.removeColumn(datasetColumn); TableColumn pathColumn = tcm.getColumn(3); tcm.removeColumn(pathColumn); TableColumn archiveColumn = tcm.getColumn(3); tcm.removeColumn(archiveColumn); // Add the table to the scollpane JScrollPane scrollPane = new JScrollPane(getQueue()); queuePanel.add(scrollPane); JPanel importPanel = new JPanel(); importPanel.setLayout(new BoxLayout(importPanel, BoxLayout.LINE_AXIS)); clearDoneBtn = GuiCommonElements.addBasicButton("Clear Done", null, null); clearFailedBtn = GuiCommonElements.addBasicButton("Clear Failed", null, null); importBtn = GuiCommonElements.addBasicButton("Import", null, null); importPanel.add(Box.createHorizontalGlue()); importPanel.add(clearDoneBtn); clearDoneBtn.setEnabled(false); clearDoneBtn.setActionCommand(FileQueueHandler.CLEARDONE); clearDoneBtn.addActionListener(this); clearDoneBtn.setToolTipText("Clear all 'done' entries from the import queue."); importPanel.add(Box.createRigidArea(new Dimension(0, 5))); importPanel.add(clearFailedBtn); clearFailedBtn.setEnabled(false); clearFailedBtn.setActionCommand(FileQueueHandler.CLEARFAILED); clearFailedBtn.addActionListener(this); clearFailedBtn.setToolTipText("Clear all 'failed' entries from the import queue."); importPanel.add(Box.createRigidArea(new Dimension(0, 10))); importPanel.add(importBtn); importBtn.setEnabled(false); importBtn.setActionCommand(FileQueueHandler.IMPORT); importBtn.addActionListener(this); importBtn.setToolTipText("Begin importing files."); GuiCommonElements.enterPressesWhenFocused(importBtn); queuePanel.add(Box.createRigidArea(new Dimension(0, 5))); queuePanel.add(importPanel); add(queuePanel); }
From source file:org.openadaptor.auxil.connector.ui.TableUIConnector.java
/** * Create the GUI and show it. For thread safety, * this method should be invoked from the * event-dispatching thread./*from ww w . java2s.c o m*/ */ private void initialiseGUI() { guiIsActive = true; log.debug("Initialising UI"); //Create and set up the window. frame = new JFrame(name); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new WindowListener() { public void windowClosing(WindowEvent arg0) { log.debug("WindowClosing"); guiIsActive = false; disconnect(); } public void windowActivated(WindowEvent arg0) { } public void windowClosed(WindowEvent arg0) { } public void windowDeactivated(WindowEvent arg0) { } public void windowDeiconified(WindowEvent arg0) { } public void windowIconified(WindowEvent arg0) { } public void windowOpened(WindowEvent arg0) { } }); //Create and set up the content pane. tablePanel = new JPanel(new BorderLayout()); tablePanel.setOpaque(true); //content panes must be opaque frame.setContentPane(tablePanel); //Create the data model for the table. tableModel = new SimpleTableModel(columnNames); tableModel.addRow(); table = new JTable(tableModel); table.setShowGrid(true); table.setBorder(BorderFactory.createLineBorder(Color.lightGray, 1)); table.setPreferredScrollableViewportSize(new Dimension(500, 70)); //Create the scroll pane and add the table to it. JScrollPane scrollPane = new JScrollPane(table); tablePanel.add(scrollPane, BorderLayout.CENTER); JPanel buttonPanel = createButtonPanel(BUTTON_NAMES); tablePanel.add(buttonPanel, BorderLayout.SOUTH); //Display the window. frame.pack(); frame.setVisible(true); log.debug("UI initialised"); }
From source file:org.datavyu.controllers.component.TrackController.java
/** * Creates a new TrackController./*w ww . j a v a2 s. c o m*/ * * @param trackPainter the track painter for this controller to manage. */ public TrackController(final MixerModel mixerModel, final TrackPainter trackPainter) { isMoveable = true; view = new JPanel(); view.setLayout(new MigLayout("fillx, ins 0", "[]0[]")); view.setBorder(BorderFactory.createLineBorder(TrackConstants.BORDER_COLOR, 1)); this.trackPainter = trackPainter; this.mixerModel = mixerModel; trackModel = new TrackModel(); trackModel.setState(TrackState.NORMAL); trackModel.clearBookmarks(); trackModel.setLocked(false); trackPainter.setMixerView(mixerModel); trackPainter.setTrackModel(trackModel); mixerModel.getViewportModel().addPropertyChangeListener(this); listenerList = new EventListenerList(); final TrackPainterListener painterListener = new TrackPainterListener(); trackPainter.addMouseListener(painterListener); trackPainter.addMouseMotionListener(painterListener); menu = new JPopupMenu(); menu.setName("trackPopUpMenu"); setBookmarkMenuItem = new JMenuItem("Set bookmark"); setBookmarkMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { TrackController.this.setBookmarkAction(); } }); clearBookmarkMenuItem = new JMenuItem("Clear bookmarks"); clearBookmarkMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { TrackController.this.clearBookmarkAction(); } }); menu.add(setBookmarkMenuItem); menu.add(clearBookmarkMenuItem); trackPainter.add(menu); // Create the Header panel and its components trackLabel = new JLabel("", SwingConstants.CENTER); trackLabel.setName("trackLabel"); trackLabel.setHorizontalAlignment(SwingConstants.CENTER); trackLabel.setHorizontalTextPosition(SwingConstants.CENTER); iconLabel = new JLabel("", SwingConstants.CENTER); iconLabel.setHorizontalAlignment(SwingConstants.CENTER); iconLabel.setHorizontalTextPosition(SwingConstants.CENTER); header = new JPanel(new MigLayout("ins 0, wrap 6")); header.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createMatteBorder(0, 0, 0, 1, TrackConstants.BORDER_COLOR), BorderFactory.createEmptyBorder(2, 2, 2, 2))); header.setBackground(Color.LIGHT_GRAY); // Normally I would use pushx instead of defining the width, but in this // case I defined the width because span combined with push makes the // first action icon cell push out as well. 136 was calculated from // 140 pixels minus 2 minus 2 (from the empty border defined above). header.add(trackLabel, "span 6, w 136!, center, growx"); header.add(iconLabel, "span 6, w 136!, h 32!, center, growx"); // Set up the button used for locking/unlocking track movement { lockUnlockButton = new JButton(TrackConstants.UNLOCK_ICON); lockUnlockButton.setName("lockUnlockButton"); lockUnlockButton.setContentAreaFilled(false); lockUnlockButton.setBorderPainted(false); lockUnlockButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { handleLockUnlockButtonEvent(e); } }); Map<String, String> constraints = Maps.newHashMap(); constraints.put("width", Integer.toString(TrackConstants.ACTION_BUTTON_WIDTH)); constraints.put("height", Integer.toString(TrackConstants.ACTION_BUTTON_HEIGHT)); String template = "cell 0 2, w ${width}!, h ${height}!"; StrSubstitutor sub = new StrSubstitutor(constraints); header.add(lockUnlockButton, sub.replace(template)); } // Set up the button used for hiding/showing a track's data viewer { visibleButton = new JButton(TrackConstants.VIEWER_HIDE_ICON); visibleButton.setName("visibleButton"); visibleButton.setContentAreaFilled(false); visibleButton.setBorderPainted(false); visibleButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { handleVisibleButtonEvent(e); } }); Map<String, String> constraints = Maps.newHashMap(); constraints.put("width", Integer.toString(TrackConstants.ACTION_BUTTON_WIDTH)); constraints.put("height", Integer.toString(TrackConstants.ACTION_BUTTON_HEIGHT)); String template = "cell 1 2, w ${width}!, h ${height}!"; StrSubstitutor sub = new StrSubstitutor(constraints); header.add(visibleButton, sub.replace(template)); } // Set up the button used for removing a track and its plugin { rubbishButton = new JButton(TrackConstants.DELETE_ICON); rubbishButton.setName("rubbishButton"); rubbishButton.setContentAreaFilled(false); rubbishButton.setBorderPainted(false); rubbishButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { handleDeleteButtonEvent(e); } }); Map<String, String> constraints = Maps.newHashMap(); constraints.put("width", Integer.toString(TrackConstants.ACTION_BUTTON_WIDTH)); constraints.put("height", Integer.toString(TrackConstants.ACTION_BUTTON_HEIGHT)); String template = "cell 5 2, w ${width}!, h ${height}!"; StrSubstitutor sub = new StrSubstitutor(constraints); header.add(rubbishButton, sub.replace(template)); } // Add the header to our layout. { Map<String, String> constraints = Maps.newHashMap(); constraints.put("width", Integer.toString(TrackConstants.HEADER_WIDTH)); constraints.put("height", Integer.toString(TrackConstants.CARRIAGE_HEIGHT)); String template = "w ${width}!, h ${height}!"; StrSubstitutor sub = new StrSubstitutor(constraints); view.add(header, sub.replace(template)); } // Add the track carriage to our layout. { Map<String, String> constraints = Maps.newHashMap(); constraints.put("height", Integer.toString(TrackConstants.CARRIAGE_HEIGHT)); String template = "pushx, growx, h ${height}!"; StrSubstitutor sub = new StrSubstitutor(constraints); view.add(trackPainter, sub.replace(template)); } view.validate(); }