Click here to Skip to main content
15,895,792 members
Everything / AWT

AWT

AWT

Great Reads

by Vitaly Shelest
Demonstrates a simple technique for embedding WPF/.NET Components into Java GUI
by Marijan Nikic
An animated random string selection wheel class written in Java AWT
by Akshay Bapat
Did it for the sake of a mini-project... Watch out for my real project...
by forest.house
This article illustrates the application of ATL/WTL by building a simple text editor based on the WTL objects

Latest Articles

by Marijan Nikic
An animated random string selection wheel class written in Java AWT
by forest.house
This article illustrates the application of ATL/WTL by building a simple text editor based on the WTL objects
by Vitaly Shelest
Demonstrates a simple technique for embedding WPF/.NET Components into Java GUI
by Akshay Bapat
Did it for the sake of a mini-project... Watch out for my real project...

All Articles

Sort by Score

AWT 

2 Jun 2013 by AlphaDeltaTheta
When you minimize and maximize your applet (in applet viewer or webbrowser), a fresh call to update is made after clearing the entire screen. So in update, you only paint the last line... therefore all your lines disappear. Think of some alternate mechanism such as storing all lines in a stack...
17 Jun 2013 by Shubhashish_Mandal
The error told you what is the issue. You are using GridBagConstraints cons = new GridBagContraints();instead of GridBagConstraints cons = new GridBagConstraints();And again in case of TitledBorder you have to import the required apiimport javax.swing.border.TitledBorder
9 Jan 2017 by Richard MacCutchan
1. The KeyListener will not know which shape you are referring to, you can only capture that information via the mouse.2. You would need to know where the focus is, i.e what shape was last clicked. You also need to decide how many pixels of a shape constitute each key press.
3 Jan 2021 by Richard MacCutchan
The problem is simply that you do not have a URL in your call to desktop.browse(oURL);. You try to capture the contents of turl at the time that you are creating the frame window, but there is no text there at that point. You should change your...
1 Nov 2011 by vigin
how to connect java applet with access database? . I want to store some datas enterd in text field of applet to database and retreive it back and display again in applet. Please help with code of it
1 Nov 2011 by TorstenH.
No way - That is really possible???[^]
19 Jul 2016 by Spacez Ly Wang
'm just beginner of Java.I'm trying to unicode (display) correctly Myanmar texts on Java GUI ( Swing/Awt ).I have four TrueType fonts which support Myanmar unicode texts. There are Myanmar3, Padauk, Tharlon, Myanmar Text ( Window 8 built-in ).You may need the fonts before the code. Google...
20 Dec 2012 by TorstenH.
Yepp - that can be...well, let's say "complicated". I have to deal with several languages in my applications, that's always fun:1. the machine has to be able to display the languageWhen you're able to change keyboard layout to the specific language, then the machine should be capable to...
22 Apr 2013 by nameJulian
Hi there, if you are using java 7 i suggest using a KeyboardFocusManager. Use it something like this:public class yourClass{ KeyBoardFocusManager manager; public void aMethod(){ //doing something with your frame in this method //like add components,...
26 May 2013 by AG007
public class xy extends Applet implements MouseListener,ActionListener{ Button b; int x1, y1,x2,y2; public void init() { b=new Button("Draw Line"); add(b); x1=y1=x2=y2=0; b.addActionListener(this); } public void actionPerformed(ActionEvent...
15 Jun 2013 by sash_kp
import java.awt.*;import javax.swing.*;JPanel middlePanel = new JPanel(); middlePanel.setLayout(new GridBagLayout()); GridBagConstraints cons = new GridBagContraints(); cons.weightx = 1.0; cons.weighty = 1.0; middlePanel.setBorder(new TitledBorder(new...
1 Oct 2013 by Member 10276989
I have downloaded a snake game project from the internet, initially this project contains three java files namely1. Engine.java 2. Snake.java 3. Gameoard.javawhen i runs Engine.java, game starts running .Now i have done some modification in it to improve the interactivity of the...
2 Oct 2013 by Nagy Vilmos
My recommendation would be to do have actionPerformed call sepperate methods for each button:public class Demo extends JFrame implements ActionListener{ private JButton first; private JButton second; private JButton third; public Demo() { ...
27 Jan 2014 by Gigabyte Giant
A couple changes I recommend you make, that might help, are to not use Calendar, it requires to much unnecessary work. As:Calendar stop = Calendar.getInstance();Calendar start = Calendar.getInstance();long lstart = start.getTimeInMillis();long lstop = stop.getTimeInMillis();int istart...
12 Apr 2014 by HuggableAlien
Hello, I am making a Windows 8 style Nimbus skin for my Java application, and this involved customizing the title bar's buttons, such as using windows 8 X buttons etc. My issue is that in Windows 8, the maximize and minimize buttons are the same color as the title bar, this is fine when the...
9 Nov 2014 by Member 11220065
in my project i have to develop query area and query builder how to generate dynamic sql for tables in graph area
13 Mar 2015 by Darren_vms
Without the exception I'm still going to take a punt at the answerObject selectedItem = urlCombo.getSelectedItem();scUrlCurrent = selectedItem.toString();try changing that toscURLCurrent = (String) urlCombo.getSelectedItem();See if that helps/Darren
18 Feb 2016 by Member 12335940
I have a sceleton code for creating chart. I draw the frame. You only fulfill this source code.https://gist.github.com/anonymous/ef021bf009b6cc20ab31What I have tried:I couldn't find enough knowledge about AIOTrade and I don't understand how should I use it. Please help. Thaks.
23 Aug 2016 by Zre
Hi, I haven't used your code to test the following, but...Could you surround your code with a "try/catch" for the exception handling?You can choose how to handle the exception any way you want in the catch area.Also, not related to your query, could you use "switch/case" instead of the...
9 Jan 2017 by GaneshRfromSpace
My UI consists of 8 rounded rectangle shapes and each shape when chosen by keyboard's navigation buttons (Up and Down) should display a distinct frame. When I tried to add key listener to the shapes.. ((Component)homeShape).addKeyListener(new KeyListener(){ @Override public...
9 Jan 2017 by GaneshRfromSpace
The below code places my 8 shapes in 8 distinct positions.Shape aShape = new RoundRectangle2D.Double(60,112,310,60,10,10);Shape bShape = new RoundRectangle2D.Double(60,194,310,60,10,10);Shape cShape = new RoundRectangle2D.Double(60,276,310,60,10,10);Shape dShape = new...
9 Jan 2017 by Richard MacCutchan
This is the same issue you asked at Can I add key listener to graphical shapes in java AWT ?[^]. And I already explained that to scroll shapes you need to calculate the new positions based on how many pixels to move per keypress. You then redraw the shape at the new position.
18 Jan 2017 by GaneshRfromSpace
I have written a code which creates graphical shapes and displays on the screen with the fonts/strings written on it.To do this I extended the Frame class, and its paint() method was overriden and graphical shapes were created and rendered on the screen. Now I wanted to display different...
2 Jan 2018 by Member 13604495
package cubaawt1; import java.awt.*; public class L1F1044 { L1F1044() { Frame f = new Frame(""); f.setBackground(Color.pink); f.setSize(360,400); f.setLayout(new BorderLayout()); //menu bar declaration MenuBar menubar =...
2 Jan 2018 by CPallini
Did you try Google, didn't you? See, for instance: How Do I Convert My Programs to Swing?[^].
2 Feb 2018 by CPallini
I guess you have to complete the actionPerformed method public void actionPerformed(ActionEvent e){ // do useful stuff here //.. } //
21 Feb 2018 by Member 13689569
I would like to add a Jtable into my ordering system. And the function if the page should be like this : Staff need to enter the details in text field to add a customer, when the staff successfully enter the data of the customer, the data will auto insert to table and into the text file. If the...
3 Jan 2021 by Mr.Corona
I made this script with gui to open url. Here is the script - import javax.swing.*; import java.io.*; import java.awt.*; import java.awt.event.*; import java.awt.Desktop; import java.net.URI; import java.awt.Desktop; import java.net.URL;...
29 May 2021 by Rahul Negi 2021
Object class present in java.lang.package. java.lang.package imported by default in java. Object class contains Event handling classes and awt. So why we need to import java.awt when we use awt in java...since it should be in lang.package which...
29 May 2021 by Richard MacCutchan
Quote: Object class contains Event handling classes and awt. No, object is the base of all classes and contains almost nothing. See java.awt Class Hierarchy (Java Platform SE 7 )[^].
29 May 2021 by Rahul Negi 2021
i am learning awt and i am confused in java hierarchy. So since java.lang imported by default and it contains Object class. Object class is base class to all class. So when lang package is imported by default, will all the derived class of...
29 May 2021 by OriginalGriff
No. Objects know about things they are derived from, all the way back to object - but no class should know about anything that is derived from it. So if ClassA derives from ClassB, and ClassC derives from ClassA, then: ClassC can use anything in...
29 May 2021 by Richard MacCutchan
Why have you reposted this question? I gave you a link to the answer yesterday at Can you explain package hierachy in java.[^]. I suggest that before you try to learn awt you spend time learning Java and the inheritance rules, starting with...
26 Apr 2009 by Vitaly Shelest
Demonstrates a simple technique for embedding WPF/.NET Components into Java GUI
6 Jul 2020 by Marijan Nikic
An animated random string selection wheel class written in Java AWT
3 Apr 2009 by Akshay Bapat
Did it for the sake of a mini-project... Watch out for my real project...
7 Aug 2011 by forest.house
This article illustrates the application of ATL/WTL by building a simple text editor based on the WTL objects
29 Jun 2008 by kaushik_sathupadi
A step by step guide to implement Mouse Gestures based commands in your Swing applications
13 Apr 2013 by Khaled Mohamed El Sawy
Before i ask this question i have been working to find the conversions from swing and AWT in java to android I made an application about remote access that works fine on the computer and while rewriting it on the ADT i figured out some problems in my code that uses the java GUI like swing and...
28 Jan 2009 by Eric Beijer
A simulation of Minesweeper by Microsoft with improvement, I think
16 Jun 2013 by H.Brydon
You are missing an import spec for GridBagConstraints, which seems to be in "java.awt.GridBagConstraints". If you are using Eclipse, it will tell you this if you hover over the statement with the error and will optionally insert the correct include for you.Same again (similar solution) for...
31 May 2021 by Farooq Ali 2021
I have been making this project without drag and drop in Java Swing and I have been encountered with an issue where the panel behind my shown panel in card layout do not disposes, i.e : my panel is transparent , so the panel behind it is also...
19 Apr 2013 by themrpacu
It's unbelievable nobody has noticed it. KeyTyped does not react to arrowkeys!http://www.leepoint.net/notes-java/GUI-lowlevel/keyboard/keyboard.html[^]
27 Jan 2014 by Member 10553233
I don't know much about how this would work and Calendar, and this causes the game to freeze, but it is an essential part of the game and can not be chopped off. Trust me this is where the error is and this is what needs to be changed. I will also give you my imports. If you do need some more...
23 Aug 2016 by Member 12694752
import java.awt.*;import javax.swing.*;import java.awt.event.*;public class CheckBoxDemonstration extends JFrame implements ItemListener{ //As you can see, we are now implementing another listener called ItemListener. This listener is the appropriate listener for check boxes....
11 Sep 2012 by AhmdAxf
Hi All,I am working on a project similar to embedding opengl inside java in which a an animated figure is drawn into an AWT canvas using JNI and AWT native interface. I have a third party application software whose method for live video is providing the same functionality. I have played...
19 Apr 2013 by themrpacu
Why don't I get printouts after typing arrowkeys? I get the image and the striped panel.What other information would be needed to identify the problem?public class MyFrame extends Frame { public MyFrame(String title) { super(title); Container panel = new...
17 Jun 2013 by sash_kp
Thanks for helping..Its solved now. Imported javax.swing.border.TitledBorderjavax.swing.border.EtchedBorderAnd made the spelling correct for GridBagConstraints cons = new **GridBagConstraints()**; instead of GridBagConstraints cons = new **GridBagContraints()**; Thanks...
13 Mar 2015 by Member 11096170
import java.awt.Dimension;import java.awt.Point;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.ItemEvent;import javafx.application.Platform;import javafx.embed.swing.JFXPanel;import javafx.scene.Group;import...
2 Feb 2018 by Member 13658198
I've tried so many time to where to put the '}' but error keeps coming out. So, where should I place the last '}' ? What I have tried: import java.text.*; import javax.swing.JLabel; import java.awt.BorderLayout; import java.awt.*; import java.awt.event.*; import java.awt.event.ActionEvent;...
20 Dec 2022 by gamedevgod
i am maeing a game and i am puting all of the stuff on a JLayeredPane but it is not showing hear is my code: import java.awt.Color; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import...