List of usage examples for javax.swing JRootPane PLAIN_DIALOG
int PLAIN_DIALOG
To view the source code for javax.swing JRootPane PLAIN_DIALOG.
Click Source Link
From source file:Main.java
public static void main(String[] args) { String subject[] = { "Math", " English", "SQL", " java", " c ", " c++ ", " cobol ", "this is a test" }; JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList<String> list = new JList<String>(subject); JScrollPane s = new JScrollPane(list); s.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); s.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); f.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG); f.add(s);/*from w ww .j a v a 2 s . c o m*/ f.setSize(300, 300); f.setVisible(true); }
From source file:Main.java
public Main() { setTitle("like JDialog"); setSize(new Dimension(500, 100)); setUndecorated(true);/* ww w . j ava 2 s .c o m*/ setResizable(false); getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG); setLocationRelativeTo(null); setDefaultCloseOperation(EXIT_ON_CLOSE); }
From source file:Main.java
/** * Initialises the {@link JDialog} for the {@link JComponent}. * /*from w w w. j a v a 2s .c o m*/ * @param dialog * @param component * @param parentComponent */ private static void initDialog(final JDialog dialog, final JComponent component, final Component parentComponent) { dialog.setResizable(true); dialog.setComponentOrientation(component.getComponentOrientation()); Container contentPane = dialog.getContentPane(); contentPane.setLayout(new BorderLayout()); contentPane.add(component, BorderLayout.CENTER); final int buttonWidth = 75; final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); buttonPanel.setBorder(BorderFactory.createEmptyBorder(2, 4, 4, 4)); buttonPanel.add(Box.createHorizontalGlue()); @SuppressWarnings("serial") final Action closeAction = new AbstractAction("Close") { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } }; final JButton button = new JButton(closeAction); fixWidth(button, buttonWidth); buttonPanel.add(button); contentPane.add(buttonPanel, BorderLayout.SOUTH); if (JDialog.isDefaultLookAndFeelDecorated()) { boolean supportsWindowDecorations = UIManager.getLookAndFeel().getSupportsWindowDecorations(); if (supportsWindowDecorations) { dialog.setUndecorated(true); component.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG); } } dialog.pack(); dialog.setLocationRelativeTo(parentComponent); WindowAdapter adapter = new WindowAdapter() { // private boolean gotFocus = false; public void windowClosing(WindowEvent we) { fireAction(we.getSource(), closeAction, "close"); } }; dialog.addWindowListener(adapter); dialog.addWindowFocusListener(adapter); }
From source file:com.m4rc310.cb.builders.ComponentBuilder.java
public void _showDialog(Object objAnnotated, String ref, Object relative, Object... args) { if (objAnnotated != null) { objectAnnotated = objAnnotated;/*from w w w.j ava2 s . c om*/ // Class[] classArgs = new Class[args.length]; // MethodUtils.method(objectAnnotated, "setValuesToSearch", classArgs).invoke(args[0]); } else { objectAnnotated = getNewInstanceObjectAnnotated(ref, args); } Class<? extends Object> objectAnnotatedClass = objectAnnotated.getClass(); dialog = new JDialogDefalt(); if (objectAnnotatedClass.isAnnotationPresent(Amethod.class)) { Amethod am = objectAnnotatedClass.getDeclaredAnnotation(Amethod.class); final String methodOnError = am.methodOnError(); LogServer.getInstance().debug(null, "Adicionando Listener de erro: {0}", methodOnError); if (!methodOnError.isEmpty()) { dialog.addPropertyChangeListener("onError", (PropertyChangeEvent evt) -> { getTargetsForMethodName(methodOnError).stream().forEach((tar) -> { MethodUtils.declaredMethod(tar, methodOnError, String.class, String.class) .invoke(evt.getPropertyName(), evt.getNewValue()); }); }); } } Adialog ad = objectAnnotatedClass.getDeclaredAnnotation(Adialog.class); String title = getString(ad.title(), ref); if (ad.debug()) { title = getString("title.title.mode.debug", title); } dialog.setTitle(title); dialog.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { MethodUtils.method(objectAnnotated, "setComponentsBuilder", ComponentBuilder.class) .invoke(ComponentBuilder.this); MethodUtils.method(objectAnnotated, "setDialog", Dialog.class).invoke(dialog); MethodUtils.method(objectAnnotated, "setGui", GuiUtils.class).invoke(gui); } }); dialog.setLayout(new MigLayout(ad.layoutDialog())); dialog.abiliteCloseOnESC(); putContainer(objectAnnotated.hashCode(), dialog); addTargets(objectAnnotated); loadAllFields(objectAnnotated, objectAnnotated.getClass()); buildAllComponents(); printDialog(); dialog.setFontSize(ad.fontSize()); dialog.setModal(ad.modal()); dialog.setResizable(ad.resizable()); dialog.pack(); dialog.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG); dialog.setLocationRelativeTo((Component) relative); dialog.showWindow(); }