awt

JOptionPane YES NO OPTION [duplicate]

笑着哭i 提交于 2019-12-21 05:38:11
问题 This question already has answers here : JOptionPane Yes or No window (8 answers) Closed 3 years ago . I got an JOptionPane and yes and no buttons. But, whichever button you click it still exists. HELP! Heres the code: int dialogButton = JOptionPane.YES_NO_OPTION; JOptionPane.showConfirmDialog (null, "Are you sure?","WARNING", dialogButton); if(dialogButton == JOptionPane.YES_OPTION) { System.exit(0); if(dialogButton == JOptionPane.NO_OPTION) { remove(dialogButton); } } 回答1: You should

Java clipboard ignores user copy if not SwingUtilities.invokeLater()

徘徊边缘 提交于 2019-12-21 05:36:09
问题 Problem: Setting clipboard content in Java programmatically and then getting clipboard text never reflects manual clipboard content changes. But postponing getting of clipboard text via SwingUtilities.invokeLater() until all Swing events have been dealt with does reflect current and later manual clipboard content changes. Setting clipboard content programmatically again returns to broken behavior. Question: Why is this? Is this a Java bug / undocumented&intended? Reproduction: Change to Swing

Disabling 'paste' in a jTextfield

非 Y 不嫁゛ 提交于 2019-12-21 05:07:41
问题 I have an app that is written in Swing, awt. I want to prevent users from pasting values into the textfields. is there any way to do this without using action listeners? 回答1: You can just call setTransferHandler with a null parameter like this: textComponent.setTransferHandler(null); This will disable all copy/paste actions on the field. 回答2: The best way is to remove action associated with CTRL+V keystroke in components ActionMap. 回答3: The simplest way it to say: textComponent.setEditable

java.lang.NoClassDefFoundError: java.awt.Container

心不动则不痛 提交于 2019-12-21 03:55:09
问题 I am trying to install Visual Paradigm for UML. During the installation it crashes. This is the stack trace: Unpacking JRE ... Preparing JRE ... Starting Installer ... java.lang.NoClassDefFoundError: java.awt.Container at com.install4j.runtime.installer.frontend.headless.AbstractHeadlessScreenExecutor.init(Unknown Source) at com.install4j.runtime.installer.frontend.headless.ConsoleScreenExecutor.<init>(Unknown Source) at com.install4j.runtime.installer.frontend.headless

[Oracle] 10.2.0.1安装数据库报java Exception

谁都会走 提交于 2019-12-20 17:32:30
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 报错如下: [oracle@rac01 database]$ ./runInstaller -ignoreSysPrereqs Starting Oracle Universal Installer... Checking installer requirements... Checking operating system version: must be redhat-3, SuSE-9, redhat-4, UnitedLinux-1.0, asianux-1 or asianux-2 Passed All installer requirements met. Preparing to launch Oracle Universal Installer from /tmp/OraInstall2019-06-17_05-03-40PM. Please wait ...[oracle@rac01 database]$ Oracle Universal Installer, Version 10.2.0.1.0 Production Copyright (C) 1999, 2005, Oracle. All rights reserved. Exception java.lang

Find composite location on screen

狂风中的少年 提交于 2019-12-20 12:54:13
问题 I am implementing a on screen keyboard in Java for SWT and AWT. One important thing is to move the keyboard to a position where the selected text field can show and is not lying behind the on screen keyboard. For AWT i can detect the position of the current selected component with Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); if (owner == null) { return; } Point ownerLocation = owner.getLocationOnScreen(); Dimension ownerSize = owner.getSize(); How

What is the difference between listeners and adapters?

天涯浪子 提交于 2019-12-20 10:25:10
问题 I'm trying to differentiate between listeners and adapters. Are they pretty much the same but in listeners you have to implement all the methods in the interface, but with adapters you have an option to only implement the methods you need so the code is cleaners and easier to read? I also got told that adapters enable instantiation with only one implementation and you can't instantiate listeners, I don't fully understand this. Can someone please explain which one is better to use and things

JTextArea scroll to bottom only if text is appended

*爱你&永不变心* 提交于 2019-12-20 07:11:17
问题 I am trying to create a JTextArea which scrolls to bottom every time a text is appended to that text area. Otherwise, the user should be able to scroll top and see previous message. I used this code: JTextArea terminalText = new JTextArea(); JPanel terminal = new JPanel(); terminal.setLayout(new BorderLayout()); add(terminal); //Adds the terminal to mother JPanel //I added scrollbar to my JTextArea JScrollPane scroll = new JScrollPane(terminalText); terminal.add(scroll, BorderLayout.CENTER);

Class is not abstract and does not override abstract method AWT Program

最后都变了- 提交于 2019-12-20 07:09:58
问题 import java.awt.*; import java.awt.event.*; public class QuadraticSolver extends Frame implements ActionListener, WindowListener { private TextField tfX2; private TextField tfX; private TextField tfNum; private TextField tfVal1; private TextField tfVal2; private TextField tfRoots; private Label lblX2; private Label lblX; private Label lblNum; private Label lblVal1; private Label lblVal2; private Label lblRoots; private Button btnCheckRoots; private Button btnCalc; private Button btnClear;

Leaving a trace while painting on a transparent JPanel

南笙酒味 提交于 2019-12-20 06:47:25
问题 I am relatively new graphics programmer in Java and here is a simple program I was trying. Here is the full code: broken into 3 classes. Class 1: import javax.swing.*; import java.awt.*; import java.awt.event.*; public class MyPanelB extends JPanel { int x=0; int y=0; public void paintComponent(Graphics g) { x=x+1; y=y+1; setOpaque(false); //setBackground(Color.cyan); g.setColor(Color.red); g.fillRect(x,y,x+1,y+1); } } Class 2: import javax.swing.*; import java.awt.*; import java.awt.event.*;