List of usage examples for javax.swing JSeparator JSeparator
public JSeparator()
From source file:Main.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); JMenu menu = new JMenu("File"); ComponentOrientation ori = ComponentOrientation.LEFT_TO_RIGHT; menu.applyComponentOrientation(ori); bar.add(menu);/*from ww w. jav a 2 s . c o m*/ menu.add(new JMenuItem("Close")); menu.add(new JSeparator()); // SEPARATOR menu.add(new AbstractAction("Exit") { @Override public void actionPerformed(ActionEvent arg0) { System.out.println("action"); } }); setJMenuBar(bar); add(new JLabel("A placeholder")); pack(); setSize(300, 300); setVisible(true); }
From source file:Main.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); JMenu menu = new JMenu("File"); ComponentOrientation ori = ComponentOrientation.LEFT_TO_RIGHT; menu.applyComponentOrientation(ori); bar.add(menu);/*from w ww . j a v a2s.com*/ menu.add(new JMenuItem("Close")); menu.add(new JSeparator()); // SEPARATOR menu.add(new JMenuItem("Exit")); setJMenuBar(bar); add(new JLabel("A placeholder")); pack(); setSize(300, 300); setVisible(true); menu.insert(new AbstractAction("Action") { @Override public void actionPerformed(ActionEvent arg0) { } }, 0); }
From source file:Main.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); JMenu menu = new JMenu(new AbstractAction("File") { @Override//from w w w. j a v a 2s. c o m public void actionPerformed(ActionEvent arg0) { System.out.println("action"); } }); bar.add(menu); menu.add(new JMenuItem("Close")); menu.add(new JSeparator()); // SEPARATOR menu.add(new AbstractAction("Exit") { @Override public void actionPerformed(ActionEvent arg0) { System.out.println("action"); } }); setJMenuBar(bar); add(new JLabel("A placeholder")); pack(); setSize(300, 300); setVisible(true); }
From source file:MainClass.java
public MainClass() { popup = new JPopupMenu(); slider = new SliderMenuItem(); popup.add(slider);//w w w .j a v a 2 s . com popup.add(new JSeparator()); JMenuItem ticks = new JCheckBoxMenuItem("Slider Tick Marks"); ticks.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { slider.setPaintTicks(!slider.getPaintTicks()); } }); JMenuItem labels = new JCheckBoxMenuItem("Slider Labels"); labels.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { slider.setPaintLabels(!slider.getPaintLabels()); } }); popup.add(ticks); popup.add(labels); }
From source file:Main.java
/** * Swing menus are looking pretty bad on Linux when the GTK LaF is used (See * bug #6925412). It will most likely never be fixed anytime soon so this * method provides a workaround for it. It uses reflection to change the GTK * style objects of Swing so popup menu borders have a minimum thickness of * 1 and menu separators have a minimum vertical thickness of 1. *///from w ww. j a v a2s.c om public static void installGtkPopupBugWorkaround() { // Get current look-and-feel implementation class LookAndFeel laf = UIManager.getLookAndFeel(); Class<?> lafClass = laf.getClass(); // Do nothing when not using the problematic LaF if (!lafClass.getName().equals("com.sun.java.swing.plaf.gtk.GTKLookAndFeel")) return; // We do reflection from here on. Failure is silently ignored. The // workaround is simply not installed when something goes wrong here try { // Access the GTK style factory Field field = lafClass.getDeclaredField("styleFactory"); boolean accessible = field.isAccessible(); field.setAccessible(true); Object styleFactory = field.get(laf); field.setAccessible(accessible); // Fix the horizontal and vertical thickness of popup menu style Object style = getGtkStyle(styleFactory, new JPopupMenu(), "POPUP_MENU"); fixGtkThickness(style, "yThickness"); fixGtkThickness(style, "xThickness"); // Fix the vertical thickness of the popup menu separator style style = getGtkStyle(styleFactory, new JSeparator(), "POPUP_MENU_SEPARATOR"); fixGtkThickness(style, "yThickness"); } catch (Exception e) { // Silently ignored. Workaround can't be applied. } }
From source file:MenuElementExample.java
public MenuElementExample() { popup = new JPopupMenu(); slider = new SliderMenuItem(); popup.add(slider);//from w w w .j av a 2s . co m popup.add(new JSeparator()); JMenuItem ticks = new JCheckBoxMenuItem("Slider Tick Marks"); ticks.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { slider.setPaintTicks(!slider.getPaintTicks()); } }); JMenuItem labels = new JCheckBoxMenuItem("Slider Labels"); labels.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { slider.setPaintLabels(!slider.getPaintLabels()); } }); popup.add(ticks); popup.add(labels); popup.addPopupMenuListener(new PopupPrintListener()); addMouseListener(new MousePopupListener()); }
From source file:cz.lidinsky.editor.Menu.java
protected JMenuItem loadMenuItem(Properties settings, String key) { try {//from w w w .j a va 2 s. co m String temp = settings.getProperty(key + "_menu_items"); JMenuItem menuItem; if (temp != null) { JMenu menu = new JMenu(); String menuItems[] = temp.split(" "); for (String item : menuItems) { if (item.equals("|")) { menu.add(new JSeparator()); } else { menu.add(loadMenuItem(settings, item)); } } menuItem = menu; } else { menuItem = new JMenuItem(); } // set the menu item label setLabel(menuItem, settings.getProperty(key + "_menu_label")); // action String actionKey = settings.getProperty(key + "_menu_action"); if (actionKey != null) { menuItem.setAction(Action.getAction(settings, actionKey)); } return menuItem; } catch (Exception e) { // TODO: throw new AssertionError(); } }
From source file:net.chunkyhosting.Roe.computer.CHGManager.gui.dialogs.DownloadNotice.java
public DownloadNotice(HashMap<JSONObject, URL> downloads) { this.setDownloads(downloads); JPanel basic = new JPanel(); basic.setLayout(new BoxLayout(basic, BoxLayout.Y_AXIS)); add(basic);/*from w ww.ja v a 2 s . c om*/ JPanel topPanel = new JPanel(new BorderLayout(0, 0)); topPanel.setMaximumSize(new Dimension(450, 0)); JLabel hint = new JLabel("CHGManager Download Manager"); hint.setBorder(BorderFactory.createEmptyBorder(0, 25, 0, 0)); topPanel.add(hint); JSeparator separator = new JSeparator(); separator.setForeground(Color.gray); topPanel.add(separator, BorderLayout.SOUTH); basic.add(topPanel); JPanel textPanel = new JPanel(new BorderLayout()); textPanel.setBorder(BorderFactory.createEmptyBorder(15, 25, 15, 25)); this.setTextPanel(new JTextPane()); this.getTextPanel().setContentType("text/html"); String text = "<p><b>Some files are missing from your CHGManager install. Don't worry. We're trying to download them. Please don't close this panel!</b></p>"; this.getText().add(text); this.getTextPanel().setText(text); this.getTextPanel().setEditable(false); JScrollPane sp = new JScrollPane(); sp.setSize(this.getTextPanel().getSize()); basic.add(sp); //basic.add(textPanel); JPanel boxPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 20, 0)); basic.add(boxPanel); JPanel bottom = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton close = new JButton("Close"); bottom.add(close); basic.add(bottom); bottom.setMaximumSize(new Dimension(450, 0)); this.setTitle("CHGManager Download Manager"); this.setResizable(false); this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); this.setLocationRelativeTo(null); this.setVisible(true); try { Thread.sleep(2000); } catch (InterruptedException e) { } this.startDownload(); }
From source file:de.wusel.partyplayer.gui.dialog.ChangePasswordDialog.java
private void initUI() { setLayout(new MigLayout("fill", "[] [grow] []")); add(new JLabel("Altes Passwort:")); add(oldPasswordField, "grow, span, wrap"); add(new JLabel("Neues Passwort:")); add(newPasswordField, "grow, span, wrap"); add(new JSeparator(), "newline push, span, grow, aligny top, wrap"); JPanel buttonPanel = new JPanel(new MigLayout("insets 0 0 0 0, fill")); final JButton cancelButton = new JButton("cancel"); cancelButton.addActionListener(new ActionListener() { @Override/* w w w. j a va2s . c o m*/ public void actionPerformed(ActionEvent e) { cancel(); } }); buttonPanel.add(cancelButton, "split 2, tag cancel"); final JButton okButton = new JButton("ok"); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ok(); } }); buttonPanel.add(okButton, "tag ok"); add(buttonPanel, "span 3, growx"); }
From source file:org.jfree.chart.demo.RightPanel.java
public RightPanel(int x, int y, int width, int height, String baude[], String name[]) { setBackground(new Color(176, 199, 246)); this.width = width; this.height = height; Data[0] = "8"; Data[1] = "9"; Name = name;//from w w w .j av a 2s . co m Baude = baude; setLayout(new GridLayout(8, 1, 0, 0)); lblName = new JLabel("Name"); lblName.setHorizontalAlignment(SwingConstants.CENTER); lblName.setFont(new Font("Arial", 15, 16)); add(lblName); comboBox = new JComboBox(Name); comboBox.setFont(new Font("Arial", 15, 16)); add(comboBox); JLabel lblBaude = new JLabel("Baude"); lblBaude.setFont(new Font("Arial", 15, 16)); lblBaude.setHorizontalAlignment(SwingConstants.CENTER); add(lblBaude); final JComboBox comboBox_1 = new JComboBox(Baude); comboBox_1.setFont(new Font("Arial", 15, 16)); add(comboBox_1); JLabel lblDataSize = new JLabel("Data size"); lblDataSize.setHorizontalAlignment(SwingConstants.CENTER); lblDataSize.setFont(new Font("Arial", 15, 16)); add(lblDataSize); final JComboBox comboBox_2 = new JComboBox(Data); comboBox_2.setFont(new Font("Arial", 15, 16)); add(comboBox_2); JSeparator separator = new JSeparator(); add(separator); btnOpen = new JButton("Open"); btnOpen.setFont(new Font("Arial", 15, 16)); btnOpen.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (btnOpen.getText() == "Open") { btnOpen.setText("Close"); open = true; int baude = 9600, data = 8; try { baude = Integer.parseInt((String) comboBox_1.getSelectedItem()); data = Integer.parseInt((String) comboBox_2.getSelectedItem()); } catch (Exception e) { errors += "Enter correct Bauderate\n"; error_flag = true; } comport = new Comport((String) comboBox.getSelectedItem(), baude, data); comport.start(); } else { comport.flag = false; btnOpen.setText("Open"); open = false; comport.close(); // comport.stop(); System.out.println("Comport = " + comport.isAlive()); System.out.println("Comport life = " + comport.get_life()); } } }); add(btnOpen); setBounds(x + 50, y, width - 40, height - 20); err.setBounds(x + 50, y, 50, 50); //add(err); }