List of usage examples for javax.swing Box createRigidArea
public static Component createRigidArea(Dimension d)
From source file:eu.apenet.dpt.standalone.gui.APETabbedPane.java
private JComponent makeCheckboxesXsd() { xsdPanel.setLayout(new BoxLayout(xsdPanel, BoxLayout.PAGE_AXIS)); xsdPanel.add(schemaLabel);/* w w w . jav a 2 s. co m*/ JRadioButton radioButton; for (Xsd_enum xsdEnum : Xsd_enum.values()) { radioButton = new JRadioButton(xsdEnum.getReadableName()); if (xsdEnum.getReadableName().equals(retrieveFromDb.retrieveDefaultXsd())) radioButton.setSelected(true); radioButton.addActionListener(new XsdSelectorListener(dataPreparationToolGUI)); dataPreparationToolGUI.getGroupXsd().add(radioButton); xsdPanel.add(radioButton); xsdPanel.add(Box.createRigidArea(new Dimension(0, 10))); } for (XsdObject additionalXsd : retrieveFromDb.retrieveAdditionalXsds()) { radioButton = new JRadioButton(additionalXsd.getName()); radioButton.addActionListener(new XsdSelectorListener(dataPreparationToolGUI)); dataPreparationToolGUI.getGroupXsd().add(radioButton); xsdPanel.add(radioButton); xsdPanel.add(Box.createRigidArea(new Dimension(0, 10))); } return xsdPanel; }
From source file:pcgen.gui2.tabs.SummaryInfoTab.java
private void initMiddlePanel(JPanel middlePanel) { middlePanel.setLayout(new GridLayout(2, 1)); JPanel statsPanel = new JPanel(); setPanelTitle(statsPanel, LanguageBundle.getString("in_sumAbilityScores")); //$NON-NLS-1$ statsPanel.setLayout(new BoxLayout(statsPanel, BoxLayout.Y_AXIS)); StatTableModel.initializeTable(statsTable); JScrollPane pane = new JScrollPane(statsTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER) { @Override//from w w w. j av a2 s.c o m public Dimension getMaximumSize() { //This prevents the scroll pane from taking up more space than it needs. return super.getPreferredSize(); } }; pane.setBorder(BorderFactory.createEmptyBorder()); JPanel statsBox = new JPanel(); statsBox.setLayout(new BoxLayout(statsBox, BoxLayout.X_AXIS)); statsBox.add(Box.createHorizontalGlue()); statsBox.add(pane); statsBox.add(Box.createHorizontalGlue()); statsPanel.add(statsBox); JPanel statTotalPanel = new JPanel(); statTotalPanel.setLayout(new BoxLayout(statTotalPanel, BoxLayout.X_AXIS)); //this makes box layout use the statTotalPanel to distribute extra space statTotalPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); statTotalPanel.add(Box.createHorizontalGlue()); FontManipulation.title(statTotalLabel); statTotalPanel.add(statTotalLabel); statTotalPanel.add(statTotal); FontManipulation.title(modTotalLabel); statTotalPanel.add(modTotalLabel); statTotalPanel.add(modTotal); statTotalPanel.add(Box.createHorizontalGlue()); generateRollsButton.setText(LanguageBundle.getString("in_sumGenerate_Rolls")); //$NON-NLS-1$ statTotalPanel.add(generateRollsButton); rollMethodButton.setText(LanguageBundle.getString("in_sumRoll_Method")); //$NON-NLS-1$ statTotalPanel.add(Box.createRigidArea(new Dimension(5, 0))); statTotalPanel.add(rollMethodButton); statTotalPanel.add(Box.createHorizontalGlue()); statsPanel.add(statTotalPanel); middlePanel.add(statsPanel); InfoPaneHandler.initializeEditorPane(infoPane); pane = new JScrollPane(infoPane); setPanelTitle(pane, LanguageBundle.getString("in_sumStats")); //$NON-NLS-1$ middlePanel.add(pane); }
From source file:org.apache.jmeter.protocol.http.control.gui.WebServiceSamplerGui.java
/** * Create a panel containing the proxy server details * * @return the panel//from ww w . j av a 2 s . c o m */ private final JPanel getProxyServerPanel() { JPanel proxyServer = new JPanel(); proxyServer.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); proxyServer.add(useProxy); useProxy.addActionListener(this); useProxy.setToolTipText(proxyToolTip); proxyServer.add(Box.createRigidArea(new Dimension(5, 0))); proxyServer.add(getProxyHostPanel()); proxyServer.add(Box.createRigidArea(new Dimension(5, 0))); proxyServer.add(getProxyPortPanel()); return proxyServer; }
From source file:ro.nextreports.designer.datasource.ConnectionDialog.java
private void create() { this.getContentPane().setLayout(new GridBagLayout()); this.addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { resize();// w ww . j av a 2s .c o m } }); JPanel p = new JPanel(new GridBagLayout()); backColor = p.getBackground(); mName = new JTextField(); mDriver = new JTextField(); //mDriver.setBackground(backColor); mURL = new JTextField(); //mURL.setBackground(backColor); mUser = new JTextField(); //mUser.setBackground(backColor); mPassword = new JPasswordField(); mPassword.setEchoChar('*'); //mPassword.setBackground(backColor); txaStatus = new JTextArea(); txaStatus.setEditable(false); txaStatus.setBackground(backColor); scr = new JScrollPane(txaStatus); scr.setSize(220, 50); scr.setBorder(new TitledBorder(STATUS)); types = new JComboBox(); types.addItemListener(this); urlFormatLabel = new JLabel(); Font font = urlFormatLabel.getFont().deriveFont(Font.BOLD, 10); urlFormatLabel.setFont(font); urlButton = new JButton(); urlButton.setPreferredSize(buttonDim); urlButton.setMinimumSize(buttonDim); urlButton.setMaximumSize(buttonDim); urlButton.setIcon(ImageUtil.getImageIcon("url_edit")); urlButton.setToolTipText(I18NSupport.getString("connection.dialog.tags.tooltip")); urlButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { editUrl(); } }); for (DriverTemplate template : templates) { types.addItem(template.getType()); } types.setSelectedItem(DEFAULT_DRIVER_TYPE); auto = new JCheckBox(I18NSupport.getString("connection.dialog.auto")); if (viewOnly) { mName.setEditable(false); types.setEnabled(false); mDriver.setEditable(false); mURL.setEditable(false); mUser.setEditable(false); mPassword.setEditable(false); urlButton.setEnabled(false); } p.add(new JLabel(I18NSupport.getString("connection.dialog.name")), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(mName, new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(new JLabel(I18NSupport.getString("connection.dialog.type")), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(types, new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(new JLabel(I18NSupport.getString("connection.dialog.driver")), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(mDriver, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(new JLabel(I18NSupport.getString("connection.dialog.url")), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(mURL, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 0), 0, 0)); p.add(urlButton, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); if (!viewOnly) { p.add(urlFormatLabel, new GridBagConstraints(1, 4, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0)); } p.add(new JLabel(I18NSupport.getString("connection.dialog.user")), new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(mUser, new GridBagConstraints(1, 5, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(new JLabel(I18NSupport.getString("connection.dialog.password")), new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(mPassword, new GridBagConstraints(1, 6, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); if (!viewOnly) { p.add(auto, new GridBagConstraints(1, 7, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); } JButton okBtn, disBtn, drvBtn, addBtn, propBtn; okBtn = new JButton(I18NSupport.getString("connection.dialog.test"), ImageUtil.getImageIcon("database_connect")); okBtn.setMnemonic('T'); okBtn.setActionCommand("ConnectOk"); okBtn.setToolTipText(I18NSupport.getString("connection.dialog.test.tooltip")); okBtn.addActionListener(this); disBtn = new JButton(I18NSupport.getString("connection.dialog.disconnect"), ImageUtil.getImageIcon("database")); disBtn.setMnemonic('D'); disBtn.setActionCommand("Disconnect"); disBtn.setToolTipText(I18NSupport.getString("connection.dialog.disconnect")); disBtn.addActionListener(this); drvBtn = new JButton(I18NSupport.getString("connection.dialog.add.driver"), ImageUtil.getImageIcon("add_driver")); drvBtn.setMnemonic('A'); drvBtn.setActionCommand("AddDriver"); drvBtn.setToolTipText(I18NSupport.getString("connection.dialog.add.driver.tooltip")); drvBtn.addActionListener(this); propBtn = new JButton(I18NSupport.getString("connection.dialog.properties"), ImageUtil.getImageIcon("properties")); propBtn.setMnemonic('P'); propBtn.setActionCommand("Properties"); propBtn.setToolTipText(I18NSupport.getString("connection.dialog.properties.tooltip")); propBtn.addActionListener(this); addBtn = new JButton(ImageUtil.getImageIcon("database_export")); if (oldDataSource == null) { addBtn.setText(I18NSupport.getString("connection.dialog.save")); addBtn.setToolTipText(I18NSupport.getString("connection.dialog.save.tooltip")); addBtn.setMnemonic('S'); } else { addBtn.setText(I18NSupport.getString("connection.dialog.modify")); addBtn.setToolTipText(I18NSupport.getString("connection.dialog.modify.tooltip")); addBtn.setMnemonic('M'); } addBtn.setActionCommand("AddDataSource"); addBtn.addActionListener(this); JPanel btnPanel = new JPanel(); btnPanel.setLayout(new BoxLayout(btnPanel, BoxLayout.X_AXIS)); btnPanel.add(Box.createHorizontalGlue()); btnPanel.add(propBtn); btnPanel.add(Box.createRigidArea(new Dimension(5, 5))); btnPanel.add(okBtn); btnPanel.add(Box.createRigidArea(new Dimension(5, 5))); //btnPanel.add(disBtn); //btnPanel.add(Box.createRigidArea(new Dimension(5, 5))); btnPanel.add(addBtn); // btnPanel.add(Box.createRigidArea(new Dimension(5, 5))); // btnPanel.add(drvBtn); SwingUtil.equalizeButtonSizes(btnPanel); if (!viewOnly) { p.add(btnPanel, new GridBagConstraints(0, 8, 3, 1, 1.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(scr, new GridBagConstraints(0, 9, 3, 1, 1.0, 1.0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); } this.getContentPane().add(p, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); if (oldDataSource != null) { mName.setText(oldDataSource.getName()); types.setSelectedItem(oldDataSource.getType()); mDriver.setText(oldDataSource.getDriver()); mURL.setText(oldDataSource.getUrl()); mUser.setText(oldDataSource.getUser()); mPassword.setText(oldDataSource.getPassword()); } }
From source file:org.openmicroscopy.shoola.env.ui.TaskBarView.java
/** * Helper method to create the window's toolbars panel. * This panel contains all the predefined toolbars (file, connect, and * help) as well as those specified by {@link TaskBar}. * * @return The window's toolbars panel.//from ww w . ja v a 2 s.co m */ private JPanel createToolBarsPanel() { createButtons(); JToolBar file = createToolBar(), connect = createToolBar(), help = createToolBar(); file.add(buttons[EXIT_BTN]); connect.add(buttons[CONNECT_BTN]); connect.add(buttons[DISCONNECT_BTN]); help.add(buttons[HELP_BTN]); JPanel bars = new JPanel(), outerPanel = new JPanel(); bars.setBorder(null); bars.setLayout(new BoxLayout(bars, BoxLayout.X_AXIS)); bars.add(file); bars.add(connect); bars.add(help); outerPanel.setBorder(null); outerPanel.setLayout(new BoxLayout(outerPanel, BoxLayout.X_AXIS)); outerPanel.add(bars); outerPanel.add(Box.createRigidArea(new Dimension(100, 16))); outerPanel.add(Box.createHorizontalGlue()); return outerPanel; }
From source file:org.openmicroscopy.shoola.agents.measurement.view.IntensityView.java
/** * Create the button panel to the right of the summary table. * @return see above./* w ww . ja va 2s .c o m*/ */ private JPanel createButtonPanel() { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(Box.createRigidArea(new Dimension(0, 10))); panel.add(Box.createRigidArea(new Dimension(0, 10))); JPanel intensityPanel = UIUtilities.buildComponentPanel(showIntensityTable); UIUtilities.setDefaultSize(intensityPanel, new Dimension(175, 32)); panel.add(intensityPanel); panel.add(Box.createRigidArea(new Dimension(0, 10))); JPanel savePanel = UIUtilities.buildComponentPanel(saveButton); UIUtilities.setDefaultSize(savePanel, new Dimension(175, 32)); panel.add(savePanel); panel.add(Box.createVerticalGlue()); return panel; }
From source file:wigraph.ShortestPathRelation.java
/** * *//*from ww w.j a v a 2 s.c om*/ private JPanel setUpControls() { JPanel jp = new JPanel(); jp.setBackground(Color.WHITE); jp.setLayout(new BoxLayout(jp, BoxLayout.PAGE_AXIS)); jp.setBorder(BorderFactory.createLineBorder(Color.black, 3)); // jp_ss - word wist 1 (ss) horizontal panel JPanel jp_wl1 = new JPanel(); jp_wl1.setLayout(new BoxLayout(jp_wl1, BoxLayout.X_AXIS)); JLabel word1_label = new JLabel("List of words 1 separated by comma");//, Label.RIGHT) word_set1 = new JTextField(20); word1_label.setDisplayedMnemonic('W'); word_set1.setFocusAccelerator('W'); word_set1.setText(INITIAL_WORD_SET1); jp_wl1.add(word1_label); jp_wl1.add(word_set1); // jp_ss - word wist 1 (ss) horizontal panel JPanel jp_wl2 = new JPanel(); jp_wl2.setLayout(new BoxLayout(jp_wl2, BoxLayout.X_AXIS)); JLabel word2_label = new JLabel("List of words 2");//, Label.RIGHT) word_set2 = new JTextField(20); word2_label.setDisplayedMnemonic('o'); word_set2.setFocusAccelerator('o'); word_set2.setText(INITIAL_WORD_SET2); jp_wl2.add(word2_label); jp_wl2.add(word_set2); jp_wl2.add(Box.createRigidArea(new Dimension(5, 0))); jp_wl2.add(search_path_btn); jp.add(jp_wl1); jp.add(jp_wl2); result_len = new JTextField(20); jp.add(result_len); jp.add(new JLabel("Select a pair of vertices for which a shortest path will be displayed")); JPanel jp2 = new JPanel(); jp2.add(new JLabel("vertex from", SwingConstants.LEFT)); jp2.add(getSelectionBox(true)); jp2.setBackground(Color.white); JPanel jp3 = new JPanel(); jp3.add(new JLabel("vertex to", SwingConstants.LEFT)); jp3.add(getSelectionBox(false)); jp3.setBackground(Color.white); jp.add(jp2); jp.add(jp3); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); JComboBox modeBox = graphMouse.getModeComboBox(); jp.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); jp.add(modeBox); return jp; }
From source file:com.haulmont.cuba.desktop.App.java
protected JComponent createBottomPane() { JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(BorderFactory.createLineBorder(Color.gray)); panel.setPreferredSize(new Dimension(0, 20)); ServerSelector serverSelector = AppBeans.get(ServerSelector.NAME); String url = serverSelector.getUrl(serverSelector.initContext()); if (url == null) url = "?"; final JLabel connectionStateLab = new JLabel( messages.formatMainMessage("statusBar.connected", getUserFriendlyConnectionUrl(url))); panel.add(connectionStateLab, BorderLayout.WEST); JPanel rightPanel = new JPanel(); BoxLayout rightLayout = new BoxLayout(rightPanel, BoxLayout.LINE_AXIS); rightPanel.setLayout(rightLayout);//from www .ja v a2 s. c o m UserSession session = connection.getSession(); JLabel userInfoLabel = new JLabel(); String userInfo = messages.formatMainMessage("statusBar.user", session.getUser().getName(), session.getUser().getLogin()); userInfoLabel.setText(userInfo); rightPanel.add(userInfoLabel); JLabel timeZoneLabel = null; if (session.getTimeZone() != null) { timeZoneLabel = new JLabel(); String timeZone = messages.formatMainMessage("statusBar.timeZone", AppBeans.get(TimeZones.class).getDisplayNameShort(session.getTimeZone())); timeZoneLabel.setText(timeZone); rightPanel.add(Box.createRigidArea(new Dimension(5, 0))); rightPanel.add(timeZoneLabel); } panel.add(rightPanel, BorderLayout.EAST); if (isTestMode()) { panel.setName("bottomPane"); userInfoLabel.setName("userInfoLabel"); if (timeZoneLabel != null) timeZoneLabel.setName("timeZoneLabel"); connectionStateLab.setName("connectionStateLab"); } return panel; }
From source file:net.technicpack.launcher.ui.LauncherFrame.java
private void initComponents() { BorderLayout layout = new BorderLayout(); setLayout(layout);//from w ww .j a v a 2 s.co m ///////////////////////////////////////////////////////////// //HEADER ///////////////////////////////////////////////////////////// JPanel header = new JPanel(); header.setLayout(new BoxLayout(header, BoxLayout.LINE_AXIS)); header.setBackground(COLOR_BLUE); header.setForeground(COLOR_WHITE_TEXT); header.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 10)); this.add(header, BorderLayout.PAGE_START); ImageIcon headerIcon = resources.getIcon("platform_icon_title.png"); JButton headerLabel = new JButton(headerIcon); headerLabel.setBorder(BorderFactory.createEmptyBorder(5, 8, 5, 0)); headerLabel.setContentAreaFilled(false); headerLabel.setFocusPainted(false); headerLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); headerLabel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { DesktopUtils.browseUrl("http://beta.technicpack.net/"); } }); header.add(headerLabel); header.add(Box.createRigidArea(new Dimension(6, 0))); ActionListener tabListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectTab(e.getActionCommand()); } }; discoverTab = new HeaderTab(resources.getString("launcher.title.discover"), resources); header.add(discoverTab); discoverTab.setActionCommand(TAB_DISCOVER); discoverTab.addActionListener(tabListener); modpacksTab = new HeaderTab(resources.getString("launcher.title.modpacks"), resources); modpacksTab.setIsActive(true); modpacksTab.setHorizontalTextPosition(SwingConstants.LEADING); modpacksTab.addActionListener(tabListener); modpacksTab.setActionCommand(TAB_MODPACKS); header.add(modpacksTab); newsTab = new HeaderTab(resources.getString("launcher.title.news"), resources); newsTab.setLayout(null); newsTab.addActionListener(tabListener); newsTab.setActionCommand(TAB_NEWS); header.add(newsTab); CountCircle newsCircle = new CountCircle(); newsCircle.setBackground(COLOR_RED); newsCircle.setForeground(COLOR_WHITE_TEXT); newsCircle.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS_BOLD, 14)); newsTab.add(newsCircle); newsCircle.setBounds(10, 17, 25, 25); header.add(Box.createHorizontalGlue()); JPanel rightHeaderPanel = new JPanel(); rightHeaderPanel.setOpaque(false); rightHeaderPanel.setLayout(new BoxLayout(rightHeaderPanel, BoxLayout.PAGE_AXIS)); rightHeaderPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); JPanel windowGadgetPanel = new JPanel(); windowGadgetPanel.setOpaque(false); windowGadgetPanel.setLayout(new BoxLayout(windowGadgetPanel, BoxLayout.LINE_AXIS)); windowGadgetPanel.setAlignmentX(RIGHT_ALIGNMENT); ImageIcon minimizeIcon = resources.getIcon("minimize.png"); JButton minimizeButton = new JButton(minimizeIcon); minimizeButton.setBorder(BorderFactory.createEmptyBorder()); minimizeButton.setContentAreaFilled(false); minimizeButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); minimizeButton.setFocusable(false); minimizeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { minimizeWindow(); } }); windowGadgetPanel.add(minimizeButton); ImageIcon closeIcon = resources.getIcon("close.png"); JButton closeButton = new JButton(closeIcon); closeButton.setBorder(BorderFactory.createEmptyBorder()); closeButton.setContentAreaFilled(false); closeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { closeWindow(); } }); closeButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); closeButton.setFocusable(false); windowGadgetPanel.add(closeButton); rightHeaderPanel.add(windowGadgetPanel); rightHeaderPanel.add(Box.createVerticalGlue()); JButton launcherOptionsLabel = new JButton(resources.getString("launcher.title.options")); launcherOptionsLabel.setIcon(resources.getIcon("options_cog.png")); launcherOptionsLabel.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 14)); launcherOptionsLabel.setForeground(COLOR_WHITE_TEXT); launcherOptionsLabel.setHorizontalAlignment(SwingConstants.RIGHT); launcherOptionsLabel.setHorizontalTextPosition(SwingConstants.LEADING); launcherOptionsLabel.setAlignmentX(RIGHT_ALIGNMENT); launcherOptionsLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); launcherOptionsLabel.setBorder(BorderFactory.createEmptyBorder()); launcherOptionsLabel.setContentAreaFilled(false); launcherOptionsLabel.setFocusPainted(false); launcherOptionsLabel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openLauncherOptions(); } }); rightHeaderPanel.add(launcherOptionsLabel); header.add(rightHeaderPanel); ///////////////////////////////////////////////////////////// // CENTRAL AREA ///////////////////////////////////////////////////////////// centralPanel = new TintablePanel(); centralPanel.setBackground(COLOR_CHARCOAL); centralPanel.setForeground(COLOR_WHITE_TEXT); centralPanel.setTintColor(COLOR_CENTRAL_BACK); this.add(centralPanel, BorderLayout.CENTER); centralPanel.setLayout(new BorderLayout()); modpackPanel = new ModpackInfoPanel(resources, iconRepo, logoRepo, backgroundRepo, avatarRepo, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openModpackOptions((ModpackModel) e.getSource()); } }, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { refreshModpackOptions((ModpackModel) e.getSource()); } }); modpackSelector.setInfoPanel(modpackPanel); playButton = modpackPanel.getPlayButton(); playButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof ModpackModel) { setupPlayButtonText((ModpackModel) e.getSource(), userModel.getCurrentUser()); } else if (installer.isCurrentlyRunning()) { installer.cancel(); setupPlayButtonText(modpackSelector.getSelectedPack(), userModel.getCurrentUser()); } else { launchModpack(); } } }); modpackPanel.getDeleteButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(LauncherFrame.this, resources.getString("modpackoptions.delete.confirmtext"), resources.getString("modpackoptions.delete.confirmtitle"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { modpackSelector.getSelectedPack().delete(); modpackSelector.forceRefresh(); } } }); infoSwap = new JPanel(); infoLayout = new CardLayout(); infoSwap.setLayout(infoLayout); infoSwap.setOpaque(false); newsInfoPanel = new NewsInfoPanel(resources, avatarRepo); infoSwap.add(discoverInfoPanel, "discover"); JPanel newsHost = new JPanel(); infoSwap.add(newsHost, "news"); JPanel modpackHost = new JPanel(); infoSwap.add(modpackHost, "modpacks"); centralPanel.add(infoSwap, BorderLayout.CENTER); newsSelector = new NewsSelector(resources, newsInfoPanel, platformApi, avatarRepo, newsCircle, settings); newsHost.setLayout(new BorderLayout()); newsHost.add(newsInfoPanel, BorderLayout.CENTER); newsHost.add(newsSelector, BorderLayout.WEST); modpackHost.setLayout(new BorderLayout()); modpackHost.add(modpackPanel, BorderLayout.CENTER); modpackHost.add(modpackSelector, BorderLayout.WEST); footer = new TintablePanel(); footer.setTintColor(COLOR_CENTRAL_BACK); footer.setBackground(COLOR_FOOTER); footer.setLayout(new BoxLayout(footer, BoxLayout.LINE_AXIS)); footer.setForeground(COLOR_WHITE_TEXT); footer.setBorder(BorderFactory.createEmptyBorder(3, 6, 3, 12)); userWidget = new UserWidget(resources, skinRepository); userWidget.setMaximumSize(userWidget.getPreferredSize()); footer.add(userWidget); JLabel dashText = new JLabel("| "); dashText.setForeground(LauncherFrame.COLOR_WHITE_TEXT); dashText.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 15)); footer.add(dashText); JButton logout = new JButton(resources.getString("launcher.user.logout")); logout.setBorder(BorderFactory.createEmptyBorder()); logout.setContentAreaFilled(false); logout.setFocusable(false); logout.setForeground(LauncherFrame.COLOR_WHITE_TEXT); logout.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); logout.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 15)); logout.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { logout(); } }); footer.add(logout); installProgress = new ProgressBar(); installProgress.setForeground(Color.white); installProgress.setBackground(LauncherFrame.COLOR_GREEN); installProgress.setBorder(BorderFactory.createEmptyBorder(5, 45, 4, 45)); installProgress.setIcon(resources.getIcon("download_icon.png")); installProgress.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 12)); installProgress.setVisible(false); footer.add(installProgress); installProgressPlaceholder = Box.createHorizontalGlue(); footer.add(installProgressPlaceholder); JLabel buildCtrl = new JLabel(resources.getString("launcher.build.text", resources.getLauncherBuild(), resources.getString("launcher.build." + settings.getBuildStream()))); buildCtrl.setForeground(COLOR_WHITE_TEXT); buildCtrl.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 14)); buildCtrl.setHorizontalTextPosition(SwingConstants.RIGHT); buildCtrl.setHorizontalAlignment(SwingConstants.RIGHT); footer.add(buildCtrl); this.add(footer, BorderLayout.PAGE_END); }
From source file:org.pdfsam.guiclient.commons.panels.JVisualPdfPageSelectionPanel.java
/** * panel initialization//from w w w . ja va 2s . c o m */ private void init() { setLayout(new GridBagLayout()); thumbnailList.setDrawDeletedItems(drawDeletedItems); if (dndSupport == DND_SUPPORT_FILES) { thumbnailList.setTransferHandler(new VisualListExportTransferHandler(pdfLoader)); } else if (dndSupport == DND_SUPPORT_JAVAOBJECTS) { thumbnailList.setTransferHandler(new VisualListTransferHandler()); } else if (dndSupport == DND_SUPPORT_FILES_AND_JAVAOBJECTS) { thumbnailList.setTransferHandler(new VisualListTransferHandler(pdfLoader)); } else { thumbnailList.setTransferHandler(new VisualListExportTransferHandler(null)); } thumbnailList.setDragEnabled(true); thumbnailList.setDropMode(DropMode.INSERT); pagesWorker = new PagesWorker(thumbnailList); thumbnailList.addKeyListener(new VisualPdfSelectionKeyAdapter(pagesWorker)); thumbnailList.addMouseListener(new PageOpenerMouseAdapter(thumbnailList)); if (showButtonPanel) { initButtonPanel(pagesWorker); initKeyListener(); } //JList orientation if (HORIZONTAL_ORIENTATION == orientation) { thumbnailList.setLayoutOrientation(JList.HORIZONTAL_WRAP); } else { if (wrap) { thumbnailList.setLayoutOrientation(JList.VERTICAL_WRAP); } } topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.LINE_AXIS)); topPanel.setPreferredSize(new Dimension(400, 30)); pdfSelectionActionListener = new VisualPdfSelectionActionListener(this, pdfLoader); if (topPanelStyle >= STYLE_TOP_PANEL_FULL) { //load button loadFileButton.setMargin(new Insets(1, 1, 1, 1)); loadFileButton.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Open")); loadFileButton.setPreferredSize(new Dimension(100, 30)); loadFileButton .setToolTipText(GettextResource.gettext(config.getI18nResourceBundle(), "Load a pdf document")); loadFileButton.setIcon(new ImageIcon(this.getClass().getResource("/images/add.png"))); loadFileButton.addKeyListener(new EnterDoClickListener(loadFileButton)); loadFileButton.setAlignmentX(Component.CENTER_ALIGNMENT); loadFileButton.setAlignmentY(Component.CENTER_ALIGNMENT); loadFileButton.setActionCommand(VisualPdfSelectionActionListener.ADD); loadFileButton.addActionListener(pdfSelectionActionListener); } documentProperties.setIcon(new ImageIcon(this.getClass().getResource("/images/info.png"))); documentProperties.setVisible(false); if (topPanelStyle >= STYLE_TOP_PANEL_MEDIUM) { clearButton.setMargin(new Insets(1, 1, 1, 1)); clearButton.setMinimumSize(new Dimension(30, 30)); clearButton.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Clear")); clearButton.setIcon(new ImageIcon(this.getClass().getResource("/images/clear.png"))); clearButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { resetPanel(); } }); } zoomInButton.setMargin(new Insets(1, 1, 1, 1)); zoomInButton.setMinimumSize(new Dimension(30, 30)); zoomInButton.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Zoom in")); zoomInButton.setIcon(new ImageIcon(this.getClass().getResource("/images/zoomin.png"))); zoomInButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { thumbnailList.incZoomLevel(); zoomOutButton.setEnabled(true); if (thumbnailList.getCurrentZoomLevel() >= JVisualSelectionList.MAX_ZOOM_LEVEL) { zoomInButton.setEnabled(false); } ((VisualListModel) thumbnailList.getModel()).elementsChanged(); } catch (Exception ex) { log.error(GettextResource.gettext(config.getI18nResourceBundle(), "Error setting zoom level."), ex); } } }); zoomOutButton.setMargin(new Insets(1, 1, 1, 1)); zoomOutButton.setMinimumSize(new Dimension(30, 30)); zoomOutButton.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Zoom out")); zoomOutButton.setIcon(new ImageIcon(this.getClass().getResource("/images/zoomout.png"))); zoomOutButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { thumbnailList.deincZoomLevel(); zoomInButton.setEnabled(true); if (thumbnailList.getCurrentZoomLevel() <= JVisualSelectionList.MIN_ZOOM_LEVEL) { zoomOutButton.setEnabled(false); } ((VisualListModel) thumbnailList.getModel()).elementsChanged(); } catch (Exception ex) { log.error(GettextResource.gettext(config.getI18nResourceBundle(), "Error setting zoom level."), ex); } } }); thumbnailList.setModel(new VisualListModel()); thumbnailList.setCellRenderer(new VisualListRenderer()); thumbnailList.setVisibleRowCount(-1); thumbnailList.setSelectionMode(selectionType); JScrollPane listScroller = new JScrollPane(thumbnailList); //preview item menuItemPreview.setIcon(new ImageIcon(this.getClass().getResource("/images/preview-viewer.png"))); menuItemPreview.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Preview")); menuItemPreview.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { int[] selection = thumbnailList.getSelectedIndices(); if (selection != null && selection.length == 1) { VisualPageListItem item = (VisualPageListItem) thumbnailList.getModel() .getElementAt(selection[0]); PagePreviewOpener.getInstance().openPreview(item.getParentFileCanonicalPath(), item.getDocumentPassword(), item.getPageNumber()); } } }); if (showContextMenu) { //popup final JMenuItem menuItemMoveUp = new JMenuItem(); menuItemMoveUp.setIcon(new ImageIcon(this.getClass().getResource("/images/up.png"))); menuItemMoveUp.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Move Up")); menuItemMoveUp.addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.MOVE_UP, pagesWorker)); popupMenu.add(menuItemMoveUp); final JMenuItem menuItemMoveDown = new JMenuItem(); menuItemMoveDown.setIcon(new ImageIcon(this.getClass().getResource("/images/down.png"))); menuItemMoveDown.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Move Down")); menuItemMoveDown .addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.MOVE_DOWN, pagesWorker)); popupMenu.add(menuItemMoveDown); final JMenuItem menuItemRemove = new JMenuItem(); menuItemRemove.setIcon(new ImageIcon(this.getClass().getResource("/images/remove.png"))); menuItemRemove.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Delete")); menuItemRemove.addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.REMOVE, pagesWorker)); popupMenu.add(menuItemRemove); //if elements are physically deleted i don't need this item if (drawDeletedItems) { final JMenuItem menuItemUndelete = new JMenuItem(); menuItemUndelete.setIcon(new ImageIcon(this.getClass().getResource("/images/remove.png"))); menuItemUndelete.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Undelete")); menuItemUndelete .addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.UNDELETE, pagesWorker)); popupMenu.add(menuItemUndelete); } //rotate item final JMenuItem menuItemRotate = new JMenuItem(); menuItemRotate.setIcon(new ImageIcon(this.getClass().getResource("/images/clockwise.png"))); menuItemRotate.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Rotate clockwise")); menuItemRotate .addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.ROTATE_CLOCK, pagesWorker)); popupMenu.add(menuItemRotate); //rotate anticlock item final JMenuItem menuItemAntiRotate = new JMenuItem(); menuItemAntiRotate.setIcon(new ImageIcon(this.getClass().getResource("/images/anticlockwise.png"))); menuItemAntiRotate .setText(GettextResource.gettext(config.getI18nResourceBundle(), "Rotate anticlockwise")); menuItemAntiRotate.addMouseListener( new VisualPdfSelectionMouseAdapter(PagesWorker.ROTATE_ANTICLOCK, pagesWorker)); popupMenu.add(menuItemAntiRotate); //reverse item final JMenuItem menuItemReverse = new JMenuItem(); menuItemReverse.setIcon(new ImageIcon(this.getClass().getResource("/images/reverse.png"))); menuItemReverse.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Reverse")); menuItemReverse.addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.REVERSE, pagesWorker)); popupMenu.add(menuItemReverse); enableSetOutputPathMenuItem(); addPopupShower(); } popupMenu.add(menuItemPreview); if (topPanelStyle >= STYLE_TOP_PANEL_FULL) { topPanel.add(Box.createRigidArea(new Dimension(5, 0))); topPanel.add(loadFileButton); } if (topPanelStyle >= STYLE_TOP_PANEL_MEDIUM) { topPanel.add(Box.createRigidArea(new Dimension(5, 0))); topPanel.add(clearButton); } topPanel.add(Box.createRigidArea(new Dimension(5, 0))); topPanel.add(documentProperties); topPanel.add(Box.createHorizontalGlue()); topPanel.add(zoomInButton); topPanel.add(Box.createRigidArea(new Dimension(5, 0))); topPanel.add(zoomOutButton); GridBagConstraints topConstraints = new GridBagConstraints(); topConstraints.fill = GridBagConstraints.BOTH; topConstraints.gridx = 0; topConstraints.gridy = 0; topConstraints.gridwidth = 3; topConstraints.gridheight = 1; topConstraints.insets = new Insets(5, 5, 5, 5); topConstraints.weightx = 1.0; topConstraints.weighty = 0.0; if (topPanelStyle > STYLE_TOP_PANEL_HIDE) { add(topPanel, topConstraints); } GridBagConstraints thumbConstraints = new GridBagConstraints(); thumbConstraints.fill = GridBagConstraints.BOTH; thumbConstraints.gridx = 0; thumbConstraints.gridy = 1; thumbConstraints.gridwidth = (showButtonPanel ? 2 : 3); thumbConstraints.gridheight = 2; thumbConstraints.insets = new Insets(5, 5, 5, 5); thumbConstraints.weightx = 1.0; thumbConstraints.weighty = 1.0; add(listScroller, thumbConstraints); if (showButtonPanel) { GridBagConstraints buttonsConstraints = new GridBagConstraints(); buttonsConstraints.fill = GridBagConstraints.BOTH; buttonsConstraints.gridx = 2; buttonsConstraints.gridy = 1; buttonsConstraints.gridwidth = 1; buttonsConstraints.gridheight = 2; buttonsConstraints.insets = new Insets(5, 5, 5, 5); buttonsConstraints.weightx = 0.0; buttonsConstraints.weighty = 1.0; add(buttonPanel, buttonsConstraints); } }