Skip to main content

Buttons disappear and frame not scrolling

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
No replies
Man_1
Offline
Joined: 2013-10-03

This is the part of code where Buttons appear after i hover with mouse and scrolling is not happening when i intended to do.
I have a paint below the buttons which should be scrollable.. is not scrolling...
I have tried my best .......can anyone tell me where i am wrong ...
Please do reply

public javax.swing.JButton jButton1;
public javax.swing.JButton jButton2;
public javax.swing.JButton jButton3;
public TextField jTextField1;
BufferedImage bufferedImage;
int tk;
final JPanel tp = new JPanel();//JPanel cards;
Graphics g;
public secondapp(String tt)
{ this.gst = tt;
Graphics g;
initComponents();
repaint();

}

public void initComponents()
{

JFrame frame = new JFrame("secondapp");
jTextField1 = new TextField();
tp.add(jTextField1);

JButton jButton3 = new JButton();jButton3.setText("Export");tp.add(jButton3);jButton3.setVisible(true);//jButton3.setBounds(8,82, 5, 180);
JButton jButton1 = new JButton();tp.add(jButton1);jButton1.setText("Gene in Query Genome");tp.add(jButton1);jButton1.setVisible(true);//jButton1.setPreferredSize(new Dimension(10, 10));
JButton jButton2 = new JButton();tp.add(jButton2);jButton2.setText("Gene in Reference Genome");tp.add(jButton2);jButton2.setVisible(true);

fon1=new Font("Sanserif",Font.BOLD,12);
fon2=new Font("Sanserif",Font.BOLD,11);
fon3=new Font("TimesRoman",Font.PLAIN,12);//TimesRoman Courier JScrollBar jsb1 = new javax.swing.JScrollBar(JScrollBar.VERTICAL);tp.add(jsb1);

JScrollPane jp = new JScrollPane(tp);
JEditorPane ep = new JEditorPane();
jp.setViewportView(ep);
frame.getContentPane().add(jp);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(1400,1000);

jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()

.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 205, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 255, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2))
.addGroup(layout.createSequentialGroup()
.addGap(118, 118, 118)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(75, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(17, 17, 17)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
)
);
this.setLayout(layout);
frame.pack();
addMouseListener(this);
}